Jump to content

Senior Nube - Is there a way to 'trace' program execution


SLP

Recommended Posts

Hi,

Sorry for the elementary question, but after reading the Cookbook, I'm still lost. In the below program, when I add the the content 'MovementSensor' (which I defined in Email customization screen) the notification fails. Being an old Cobol/Assembler programmer I was looking for a way to trace the below. I've looked at the various logs and don't see anything that looks like a way of tracing of the execution of program. The below works if I remove the content 'MovementSensor' so I was trying to figure out why...

Thank you in advance.

 

 

 

image.png.cb26bbe8e977e356b0820a3539564ad4.png

 

image.thumb.png.5b6b8d0ae4be5c09db4d4d825e310276.png

Link to comment
2 hours ago, SLP said:

Being an old Cobol/Assembler programmer I was looking for a way to trace the below.

There's nothing like trace that I'm aware of.

2 hours ago, SLP said:

The below works if I remove the content 'MovementSensor' so I was trying to figure out why...

image.png.cb26bbe8e977e356b0820a3539564ad4.png

If you click [Test] on the SLPPhone Group on the Configuration > Email/Notifications > Settings/Groups tab, do you get the test message?

Link to comment
1 minute ago, DaveStLou said:

There's nothing like trace that I'm aware of.

If you click test on the SLPPhone Group on the Configuration > Email/Notifications > Settings/Groups tab, do you get the test message?

Yes, I did the test button and got the text fairly quickly...

Link to comment

@lilyoyo1

I think the wait is because I don't yet understand how it all works, and I was concerned that it

might cycle through the program logic extremely fast, sending hundreds of texts etc. The sensor

seems to go to 'on' for about 15 seconds, before it cycles back to off, so I picked a 60 wait.

I think part of the issue is how I think about programming...I'm use to looping/branching etc, and I think I need to think more along triggering/interupt driven approach.

Link to comment
4 minutes ago, SLP said:

I think part of the issue is how I think about programming...I'm use to looping/branching etc, and I think I need to think more along triggering/interupt driven approach.

Not sure why the status would fluctuate like that but try Control instead of Status to get your trigger even. Status is a state and the program then is only true when it is on. As soon as it goes off the program is no longer true and the then will stop.

Link to comment
18 hours ago, SLP said:

@lilyoyo1

I think the wait is because I don't yet understand how it all works, and I was concerned that it

might cycle through the program logic extremely fast, sending hundreds of texts etc. The sensor

seems to go to 'on' for about 15 seconds, before it cycles back to off, so I picked a 60 wait.

I think part of the issue is how I think about programming...I'm use to looping/branching etc, and I think I need to think more along triggering/interupt driven approach.

A wait at the end does nothing.  It won't slow down successive cycles.

You're correct program execution happens fast,  queued mail make take slightly longer.

The fallacy in your logic about adding the wait, as just as soon as the status of the sensor changes, whatever is running is aborted.   to show you an example let's change the intent of this program.

If

    Sensor 1 status in On

then

     Turn on lamp

      Wait 10 min

     Turn off lamp

When Sensor 1 turns on it will immediately turn the lamp on and begin waiting 10 minutes.  When your sensor turns off 15 seconds later tho, the wait ends.  the sensor is reevaluated and since it's "status" and not "ON" anymore, Else (which is empty runs).   Since the sensor always times out at 15 seconds, the 10 minute wait will never finish.

---

to test your notifications, first make certain it sends from the mail interface.  then when its added to a program, Save the program, right click the program name and pick Run Then.  Did the notification work?  if so, the problem is with the If statement.  

 

Link to comment

Here's another idea that I've used: Break it into two programs.

First one sets a state variable to 1 when the motion sensor is on (or, if you want, control is on).

Second one sends the message when the state variable is 1 and then waits (as long as you want) before setting the variable back to 0.

That way you can test the notice by manually setting the variable to 1 and separately watch the variable turn to 1 when you set off the motion detector.

Here's what it would look like:

Program1 -

If
        'Sensor Z006 / Motion' Status is On
 
Then
        $State_01  = 1
 
Else
   - No Actions -

Program2 -

If
        $State_01 is 1
 
Then
        Send Notification to 'Email' content 'Alert'
        Wait  1 minute
        $State_01  = 0
 
Else
   - No Actions -

 

Link to comment

Hi...

Thank you for your various help(s). I'm still stuck. I'm trying learn how to have motion sensor send email with specific content (I've got the substitution thing down...) however I can't figure out what is wrong the below "Send Notification..." line.

I know the base notification wors when I use the "test" button option, it works, but only when all I have coded is "Send notification to "SLPUser" , but when I add to the end of the "send' line "Content SLPMail.1" it never arrives.

The triggering part of the "if' statement works fine.

The "SLPMail.1" entry and supporting screens are below, and I've saved and uploaded, enabled everything, and have also tried executing just the "Then" statement, and in all cases it works fine without the "Content" modifier but as soon as it's added, it fails. Below is how I coded the various supporting content screens:

I'm obviously missing something very basic. Any suggestions would be appreciated

image.png.0b29bfe08cb188b65cd013a627e61ae4.png

image.thumb.png.9325e3e8b8fed2d46bb4cc7ee1a85f16.png

image.thumb.png.7fd825774c7c8ff7f31c0635c0a5545f.png

image.thumb.png.a93f7e96255fc926721f66daea101004.png

Link to comment

@SLP,

First, an easier/clean way to copy programs to the forums is to right click on the program then select "Copy to Clipboard" (last menu item) then in the forum post just paste.  [Make sure you're not selecting "Export to clipboard" that's something else entirely. You want "COPY to clipboard"!]

It will look like this when you paste it to the forums:

 

New Program - [ID 0000][Parent 0000]

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')
 
Then
   - No Actions - (To add one, press 'Action')
 
Else
   - No Actions - (To add one, press 'Action')

(NOTE: This is a blank program used just to demonstrate)

 

Now, to your issue:

In the content window you want to clear out what is in the "from" line. That will overwrite your email SMTP settings for the "from" email and might mess up the send process. If you want it to appear to come from a different address you need to use the same format as in the "From" setting in the SMTP settings:  "First-Name Last-Name:Email-Address" (make sure you're including the colon between last name and email address!)

In the Subject and Body sections you can use variables found in the wiki for any range of items you want to be notified about.

Body Example: "The light turned on at ${sys.time} on ${sys.date}."

If I had a program that emailed me when a light turned on this would notify me the time and date it turned on. (Not really important to me, but you get might the idea.)

In your case it's failing because you have something in the "From" line. Take that out and you should get the message as you have it now.

Make sure to have something in the Subject and Body of the email. Otherwise the email won't send. The FROM is the only section that can be blank!

 

 

 

Link to comment

@SLP

As @Geddy points out... I belive your problem is here:

image.png.2b69b73b2e4b4a0763b512045ddd254e.png

Leave that line blank, especially using the default mail server.  it over-rides the From line in the email header.  Its looking for two parts which when formatted correctly are separated by a

First Last:myemail@example.com

when using the default mail server tho you should definitely leave this blank and let the default mail server specify the From header.  If you try to subsitute your own info here your going to run the risk of the notification getting hung up in spam filters, because mixing a different From than the Sending domain is something spammers commonly do.

so (Omit to use default)

Link to comment

@SLP with your background in programing, one thing that has been "hinted" at here is how the ISY is STATE driven programming method. If anything happens to the STATE of any item in the IF statement, the IF statement will be evaluated at that time, no matter where it is in its execution.  This wiki does a great job of how programs are executed within the ISY:

https://wiki.universal-devices.com/index.php?title=ISY-99i/ISY-26_INSTEON:Scope,_Precedence_and_Execution_Order

 

Example: 

Within the Then or Else clause of a program, statements are executed from top to bottom in the order in which they occur. When a statement calls another program, the called program begins executing, and the calling program immediately continues execution with the next statement in sequence--it does not wait for the called program to complete before continuing.

A series of statements within a Then clause (or within an Else clause), up to the next Wait or Repeat statement, are atomic. In other words, all such statements are executed before the conditions of the program are retested. The program's conditions are reevaluated each time a Wait or Repeat statement is encountered, and at the end of each iteration of a Repeat loop.

What this means is that if a program's Then clause changes a condition which causes the program's overall condition to become false (or if the program's Else clause changes a condition which causes the program's overall condition to become true), the current atomic statement group will complete, and at that point execution will transfer from the Then clause (or the Else clause) to the Else clause (or the Then clause).

Therefore, if a Then clause (or an Else clause) contains no Wait or Repeat statements, the entire clause is atomic, and will complete before the program's conditions are reevaluated.

Link to comment

Gentlemen,

Thank you all very much. I'm slowing beginning to think interrupt-driven, vs. branching-looping, so my apologies for the stupid questions.

Relative to the removing everything from the From: field, did that, re-saved etc, but the behavior is still the same, i.e. everyone works as expected and email notification arrives if I use default, but the second I put 'Content' field, it appears to do nothing. I erased everything and recreated everything to make sure I wasn't leaving odd in some cache, but same exact behavior.

I'm using 5.3.4 firmware and UI if that matters.

Link to comment

During 1/2 time it came to me that my name of 'SLPEmail.1' might be causing an issue because it

contains the word 'email' so I changed name to 'SLPOther' to remove the actual word 'email'  and it

now works as you all have suggested....maybe there are reserved words not allowed ??


Thank you again for taking so much time to educate me.

Link to comment
12 hours ago, SLP said:

During 1/2 time it came to me that my name of 'SLPEmail.1' might be causing an issue because it

contains the word 'email' so I changed name to 'SLPOther' to remove the actual word 'email'  and it

now works as you all have suggested....maybe there are reserved words not allowed ??


Thank you again for taking so much time to educate me.

WoW....  Not sure I would have ever guessed that one...   I wonder tho if it was the "Email' portion or the ".1" that the system didn't like...

Link to comment
During 1/2 time it came to me that my name of 'SLPEmail.1' might be causing an issue because it
contains the word 'email' so I changed name to 'SLPOther' to remove the actual word 'email'  and it
now works as you all have suggested....maybe there are reserved words not allowed ??

Thank you again for taking so much time to educate me.

Those companies spent millions on those ads and you’re thinking about your HA programs?!?!


Sent from my iPhone using Tapatalk
Link to comment
10 hours ago, MrBill said:

WoW....  Not sure I would have ever guessed that one...   I wonder tho if it was the "Email' portion or the ".1" that the system didn't like...

@MrBill.... I went back and tried various naming approaches... the inclusion of the '.1' etc worked fine, but as I added the work 'email' it failed. I went through all of the various documentation (like the cookbook and wiki) and could not find anything naming/variable/substitution reference to this issue. Thank you again for your help.

Link to comment

@SLP Thanks for checking on the naming conventions.  I know there's no documentation of prohibited naming.  Mentally filed away that "email" in the name of an email won't work. 

 

PS -- to get the @ mention tagging system to actually notify the person you type @ then part of the name @SLP until you see the name appear in a context menu that looks like this:image.png.de7bace598513ca252a980568cc7c5e2.png Once you see the persons name you must click on it which will change the text to a tag and likewise notify them of the mention.  In the above post you also quoted me so I got notified because of that... one, the other, or both works!  

 

 

Link to comment

Archived

This topic is now archived and is closed to further replies.


  • Recently Browsing

    • No registered users viewing this page.
  • Who's Online (See full list)

  • Forum Statistics

    • Total Topics
      36.6k
    • Total Posts
      368.2k
×
×
  • Create New...