Jump to content

Control and Status in same "if".


Jimbo.Automates

Recommended Posts

I've been looking at updating my lights auto off programs to use new Ignore functionality in version 5 to disable motion and open/close sensors triggering the lights.  Currently I am using faston/fastoff to disable auto-on/off and thought the program below would also allow you to turn the light off when it was already off to disable, but this doesn't seem to work since they are the same switch?

AL FRO Manual Off 2 - [ID 0010][Parent 0017]

If
        'Outside / BackYard / Back Patio' is switched Fast Off
     Or (
             'Outside / BackYard / Back Patio' is switched Off
         And 'Outside / BackYard / Back Patio' Status is Off
        )
 
Then
        $s.AL.FRO.Mon  = 2
 
Else
   - No Actions - (To add one, press 'Action')
 
Switch was manually turned off when it was already off, or fast-off was sent, 
so disable auto/on off.

When the switch is on and you turn it off sometimes the variable gets set to 2 and sometimes it does not.

Link to comment

You're basically hitting a "race condition" in the ISY.

 

While you expect the tests triggered by incoming "is switched off" event to be fully processed before the incoming "Status is off" event, there is no guarantee this will be the case, as the internal evaluation of "if" conditions is not perfectly atomic.

 

You may be able to work around it by using multiple programs and/or variables.

Link to comment

You're basically hitting a "race condition" in the ISY.

 

While you expect the tests triggered by incoming "is switched off" event to be fully processed before the incoming "Status is off" event, there is no guarantee this will be the case, as the internal evaluation of "if" conditions is not perfectly atomic.

 

You may be able to work around it by using multiple programs and/or variables.

Thanks, I assumed it was a timing issue but was hoping someone had a elegant solution. I do have a workaround using a variable that tracks the switch status, and found thru experiments that a 1 second delay was necessary, so still not a great workaround.

 

Sent from my Pixel C using Tapatalk

Link to comment

Yes, that's what I do as well, but my wife asked if I could make them stay on if you turn them on when they are already on.  Seemed like an easy request :)

 

Enable sending an On only. Use a program for off. Use a trigger to disable the Off program.

Link to comment

Yes, that's what I do as well, but my wife asked if I could make them stay on if you turn them on when they are already on.  Seemed like an easy request :)

I have a variation of this in one case, but normal use includes time between turning it off and sending the second off command. I do not run into the "racing" issue. Yes, it sounds asif it should be easy. Perhaps operator training ( wait a few seconds between off commands)?

Link to comment

I have a variation of this in one case, but normal use includes time between turning it off and sending the second off command. I do not run into the "racing" issue. Yes, it sounds asif it should be easy. Perhaps operator training ( wait a few seconds between off commands)?

Ya that's probably what I will use unless someone has figured out a better way. Thanks.

 

Sent from my Pixel C using Tapatalk

Link to comment

You're basically hitting a "race condition" in the ISY.

 

While you expect the tests triggered by incoming "is switched off" event to be fully processed before the incoming "Status is off" event, there is no guarantee this will be the case, as the internal evaluation of "if" conditions is not perfectly atomic.

 

You may be able to work around it by using multiple programs and/or variables.

 

 

This is not correct. 

 

If

status off

and control off

 

Then

do something

 

Is logic that ISY handles just fine.   It will be true when the device status is off at the time of the off press and it will be false in any other state.

 

The reason your program is not working is almost certainly a comm issue.  ISY probably has the device status wrong at the time of the button press.  In other words, ISY has the device as being off when in fact it is not.

 

I probably have this same program written on 25 or more devices in my house.  I use it as a "night lite" feature.  If I am wandering about the bathroom or bedroom area at night, I can press the off paddle on any light and it turns on to 25%.

 

Below is one example of many and they only rarely mess up and when wrong, it is a comm issue.

Bath Night Lt. Can - [ID 0076][Parent 0083]

If
        'Master Bedroom / Master-Bath Cans L' Status is Off
    And 'Master Bedroom / Master-Bath Cans L' is switched Off
 
Then
        Set 'Master Bedroom / Master-Bath Cans L' On 25%
 
Else
   - No Actions - (To add one, press 'Action')
 


Link to comment

This is not correct.

 

If

status off

and control off

 

Then

do something

 

Is logic that ISY handles just fine. It will be true when the device status is off at the time of the off press and it will be false in any other state.

 

The reason your program is not working is almost certainly a comm issue. ISY probably has the device status wrong at the time of the button press. In other words, ISY has the device as being off when in fact it is not.

 

I probably have this same program written on 25 or more devices in my house. I use it as a "night lite" feature. If I am wandering about the bathroom or bedroom area at night, I can press the off paddle on any light and it turns on to 25%.

 

Below is one example of many and they only rarely mess up and when wrong, it is a comm issue.

Bath Night Lt. Can - [ID 0076][Parent 0083]

If
        'Master Bedroom / Master-Bath Cans L' Status is Off
    And 'Master Bedroom / Master-Bath Cans L' is switched Off
 
Then
        Set 'Master Bedroom / Master-Bath Cans L' On 25%
 
Else
   - No Actions - (To add one, press 'Action')
 


I don't understand what you mean by, This is not correct? But, I double checked, and ISY knows the proper status, so not sure what else to do.

 

Sent from my Nexus 6P using Tapatalk

Link to comment

Exactly. The paddle action sends the control from the manual paddle action, and when the dimmer electronics change, the comm circuits send the new status of the dimmer

Of course it's all the same electronics, inside the Switchlinc case but two different sensing sources, the status being another result of the manual or remote control of the dimmer.

Sent from my SGH-I257M using Tapatalk

Link to comment

I don't understand what you mean by, This is not correct? But, I double checked, and ISY knows the proper status, so not sure what else to do.

 

Sent from my Nexus 6P using Tapatalk

I mean there is no race situation.

 

There were a few firmware versions where there was a bug in ISY code that made this program not work.  But neither 4.5.4 nor 5.0.10 have that bug, nor do must others.  Over the years as I have updated my firmware and have had these programs, there has been two times that I installed ISY updates that broke this logic.  Each time it was corrected with the next update after I pointed it out to Michel.

 

You can't check ISY status after it inappropriately runs and say that "status is correct".  At this point it will be correct, otherwise the program wouldn't have run at all (the program only runs when it receives a comm from the device and thus . . .got the comm and will show the correct status).  This is a mistake in status from an earlier button press turning it on which ISY would have not received that causes the false running.  If the device is actually in a not-off (on) state, and ISY thinks it is off, and you press the off paddle, the program will run inappropriately as true, setting your variable to 2.  This is the behavior you describe and is the behavior I, once in a blue moon, have seen in my system and when I put tracking programs on the status of the switch found that this only happens when ISY has the incorrect notion that the switch was off when it was not prior to pushing the off paddle.

Link to comment

I mean there is no race situation.

 

There were a few firmware versions where there was a bug in ISY code that made this program not work. But neither 4.5.4 nor 5.0.10 have that bug, nor do must others. Over the years as I have updated my firmware and have had these programs, there has been two times that I installed ISY updates that broke this logic. Each time it was corrected with the next update after I pointed it out to Michel.

 

You can't check ISY status after it inappropriately runs and say that "status is correct". At this point it will be correct, otherwise the program wouldn't have run at all (the program only runs when it receives a comm from the device and thus . . .got the comm and will show the correct status). This is a mistake in status from an earlier button press turning it on which ISY would have not received that causes the false running. If the device is actually in a not-off (on) state, and ISY thinks it is off, and you press the off paddle, the program will run inappropriately as true, setting your variable to 2. This is the behavior you describe and is the behavior I, once in a blue moon, have seen in my system and when I put tracking programs on the status of the switch found that this only happens when ISY has the incorrect notion that the switch was off when it was not prior to pushing the off paddle.

Sorry I didn't completely explain, but I checked the status before it inappropriately runs.

 

Sent from my Nexus 6P using Tapatalk

Link to comment

Sorry I didn't completely explain, but I checked the status before it inappropriately runs.

 

Sent from my Nexus 6P using Tapatalk

What firmware are you running?

 

I can tell you that a few versions of firmware did not have it right, I don't remember which ones, but I'm currently using 5.0.10 and this runs it correctly.  I use this program type every day many times per day and it works.  I have not installed every single firmware so I can't say for sure all the firmware that do not run it correctly, only that the vast majority that I have installed on my isy do it correctly.

 

The other thing is of course if you did a fast off instead of a regular off.

Link to comment

What firmware are you running?

 

I can tell you that a few versions of firmware did not have it right, I don't remember which ones, but I'm currently using 5.0.10 and this runs it correctly.  I use this program type every day many times per day and it works.  I have not installed every single firmware so I can't say for sure all the firmware that do not run it correctly, only that the vast majority that I have installed on my isy do it correctly.

 

I am on 5.0.10.   I don't have any issue with correctly detecting when off is pressed and the status is off, that works every time.  Where it gets messed up is when the status is on and control off is sent, sometimes it works and sometimes it doesn't, actually seemed like most of the time it didn't work, but I didn't count.  I will try a different switch tonight and see if the results are any different.

Link to comment

I am on 5.0.10.   I don't have any issue with correctly detecting when off is pressed and the status is off, that works every time.  Where it gets messed up is when the status is on and control off is sent, sometimes it works and sometimes it doesn't, actually seemed like most of the time it didn't work, but I didn't count.  I will try a different switch tonight and see if the results are any different.

When it is actually on, and you press off, it should do nothing (run the blank else), so you are saying that it is running true and setting the variable to 2, when it should be nothing?

 

This would be akin to me pushing off when the light is on, and having it go off then back up to 25%.  My lights do not do this but extremely rarely, and back when I first created these programs, I tracked it and found that the only time I saw the problem is if ISY had the status wrong as being "off" when it was not.

 

If indeed you can demonstrate that for certain ISY had the status wrong, please report to Michel.  I tracked it by a program similar to this.

 

If 

status device x is off

or status device x is not off

Then

send notification device is %status      (use variable sub in the custom notify section to put in the status of the device)

 

To complete the tracking

 

If 

control device x is switched off

Then

send notification device x switched off

 

If 

control device x is switched on

The 

send notification device x is switched off

 

If

status $s.AL.FRO.Mon is 2

or

$s.AL.FRO.Mon is not 2

Then

send notification $s.AL.FRO.Mon = variable sub

 

With that series of programs you can track the events.

 

Like I said, the program you wrote is supposed to work per Michel and ISY logic, if it is not, then it is a bug.

 

You might add a system time stamp to the notifications as well just in case the emails pass through the email server out of order.

Link to comment

When it is actually on, and you press off, it should do nothing (run the blank else), so you are saying that it is running true and setting the variable to 2, when it should be nothing?

 

This would be akin to me pushing off when the light is on, and having it go off then back up to 25%.  My lights do not do this but extremely rarely, and back when I first created these programs, I tracked it and found that the only time I saw the problem is if ISY had the status wrong as being "off" when it was not.

 

If indeed you can demonstrate that for certain ISY had the status wrong, please report to Michel.  I tracked it by a program similar to this.

 

If 

status device x is off

or status device x is not off

Then

send notification device is %status      (use variable sub in the custom notify section to put in the status of the device)

 

The answer is Yes, to this question:  When it is actually on, and you press off, it should do nothing (run the blank else), so you are saying that it is running true and setting the variable to 2, when it should be nothing?

 

I will do more debugging, but I am glad to hear this is working for you, so there is hope for me :)  Appreciate your assistance.

 

I was hoping Michel would jump in and confirm, and if he doesn't I will ping him directly.

 

Thanks,

Jim

Link to comment

The answer is Yes, to this question:  When it is actually on, and you press off, it should do nothing (run the blank else), so you are saying that it is running true and setting the variable to 2, when it should be nothing?

 

I will do more debugging, but I am glad to hear this is working for you, so there is hope for me :)  Appreciate your assistance.

 

I was hoping Michel would jump in and confirm, and if he doesn't I will ping him directly.

 

Thanks,

Jim

 

I edited my previous post with a more complete logging of the events for debugging.

Link to comment
  • 3 weeks later...

I edited my previous post with a more complete logging of the events for debugging.

 

Just to follow up, I can confirm that this should work.   I was re-reading all the comments and was wondering if it wasn't working for me because this switch is an on/off not a dimmer, but I created a simple set of tests and they all work as expected.

===================================================================================
StCtTest - [ID 01CC][Parent 0043]

Folder Conditions for 'StCtTest'

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')
 
Then
   Allow the programs in this folder to run.
 



-----------------------------------------------------------------------------------
T 1 - [ID 01CD][Parent 01CC]

If
        'Outside / BackYard / Back Patio' is switched On
    And 'Outside / BackYard / Back Patio' Status is Off
 
Then
        $i.Test  = 1
 
Else
   - No Actions - (To add one, press 'Action')
 



-----------------------------------------------------------------------------------
T 2 - [ID 01CF][Parent 01CC]

If
        'Outside / BackYard / Back Patio' is switched On
    And 'Outside / BackYard / Back Patio' Status is On
 
Then
        $i.Test  = 2
 
Else
   - No Actions - (To add one, press 'Action')
 



-----------------------------------------------------------------------------------
T 3 - [ID 01D0][Parent 01CC]

If
        'Outside / BackYard / Back Patio' is switched Off
    And 'Outside / BackYard / Back Patio' Status is On
 
Then
        $i.Test  = 3
 
Else
   - No Actions - (To add one, press 'Action')
 



-----------------------------------------------------------------------------------
T 4 - [ID 01E1][Parent 01CC]

If
        'Outside / BackYard / Back Patio' is switched Off
    And 'Outside / BackYard / Back Patio' Status is Off
 
Then
        $i.Test  = 4
 
Else
   - No Actions - (To add one, press 'Action')
 

I ran all of these many times and they all work a expected.  So now I need to figure out why they didn't work in my initial setup.

Link to comment

I figured out my issue.  When I wrote the above about it being a on/off and not a dimmer, I started thinking and modified the programs as below, which add faston/fastoff checks.

===================================================================================
StCtTest - [ID 01CC][Parent 0043]

Folder Conditions for 'StCtTest'

If
        $s.True is 1
 
Then
   Allow the programs in this folder to run.
 



-----------------------------------------------------------------------------------
T 1 - [ID 01CD][Parent 01CC]

If
        'Outside / BackYard / Back Patio' is switched On
    And 'Outside / BackYard / Back Patio' Status is Off
 
Then
        $i.Test  = 1
 
Else
   - No Actions - (To add one, press 'Action')
 



-----------------------------------------------------------------------------------
T 2 - [ID 01CF][Parent 01CC]

If
        (
             'Outside / BackYard / Back Patio' is switched On
         And 'Outside / BackYard / Back Patio' Status is On
        )
     Or 'Outside / BackYard / Back Patio' is switched Fast On
 
Then
        $i.Test  = 2
 
Else
   - No Actions - (To add one, press 'Action')
 



-----------------------------------------------------------------------------------
T 3 - [ID 01D0][Parent 01CC]

If
        'Outside / BackYard / Back Patio' is switched Off
    And 'Outside / BackYard / Back Patio' Status is On
 
Then
        $i.Test  = 3
 
Else
   - No Actions - (To add one, press 'Action')
 



-----------------------------------------------------------------------------------
T 4 - [ID 01E1][Parent 01CC]

If
        (
             'Outside / BackYard / Back Patio' is switched Off
         And 'Outside / BackYard / Back Patio' Status is Off
        )
     Or 'Outside / BackYard / Back Patio' is switched Fast Off
 
Then
        $i.Test  = 4
 
Else
   - No Actions - (To add one, press 'Action')
 

Now I can never get state 3 to happen, it always goes to 4, which is what I was originally seeing.

 

I know it doesn't make sense to have faston/fastoff for an on/off switch, but they are programs that I copy and modify for all, and this happened to be the first one I tested it on...

Link to comment

Just to follow up, I can confirm that this should work.   I was re-reading all the comments and was wondering if it wasn't working for me because this switch is an on/off not a dimmer, but I created a simple set of tests and they all work as expected.

===================================================================================
StCtTest - [ID 01CC][Parent 0043]

Folder Conditions for 'StCtTest'

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')
 
Then
   Allow the programs in this folder to run.
 



-----------------------------------------------------------------------------------
T 1 - [ID 01CD][Parent 01CC]

If
        'Outside / BackYard / Back Patio' is switched On
    And 'Outside / BackYard / Back Patio' Status is Off
 
Then
        $i.Test  = 1
 
Else
   - No Actions - (To add one, press 'Action')
 



-----------------------------------------------------------------------------------
T 2 - [ID 01CF][Parent 01CC]

If
        'Outside / BackYard / Back Patio' is switched On
    And 'Outside / BackYard / Back Patio' Status is On
 
Then
        $i.Test  = 2
 
Else
   - No Actions - (To add one, press 'Action')
 



-----------------------------------------------------------------------------------
T 3 - [ID 01D0][Parent 01CC]

If
        'Outside / BackYard / Back Patio' is switched Off
    And 'Outside / BackYard / Back Patio' Status is On
 
Then
        $i.Test  = 3
 
Else
   - No Actions - (To add one, press 'Action')
 



-----------------------------------------------------------------------------------
T 4 - [ID 01E1][Parent 01CC]

If
        'Outside / BackYard / Back Patio' is switched Off
    And 'Outside / BackYard / Back Patio' Status is Off
 
Then
        $i.Test  = 4
 
Else
   - No Actions - (To add one, press 'Action')
 

I ran all of these many times and they all work a expected.  So now I need to figure out why they didn't work in my initial setup.

 

This hasn't come up for quite a while but just a thought.....

 

Status devicename is On

 

may not test true if the dimmer is 1-99%

 

Try 

status devicename is NOT off

Link to comment

Archived

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


×
×
  • Create New...