Reactor Sensor for LightWave Scene Selector

I am trying to create a single sensor in Reactor to manage my LightWave Scene Controller switches but I am struggling. I am sure this is a limitation of the controller, not Reactor but hopefully, there is a solution.

LightWave Scene Controller
The scene controller has 6 buttons and is added via RFXtrx as two devices, a simple on/off switch (the two large buttons) and a group controller (Scene 1, 2, 3 & All Off buttons).
The on/off switch acts as expected and I have no problems controlling my devices via Reactor, the issue is with the group controller.
The group controller uses sl_SceneActivated or sl_SceneDeactivated in Reactor:
Scene 1 = sl_SceneActivated 111
Scene 2 = sl_SceneActivated 112
Scene 3 = sl_SceneActivated 113
All Off = sl_SceneDeactivated 100
Scene numbers are from this thread HERE. All of the above work as Device triggers in Vera Scenes but I would much rather use Reactor if possible.

The issue is that the All Off group is always triggered, whatever button is pressed. Also the last pressed Scene button group also remains triggered once All Off has been pressed

Here is the logic summary of me running through scenes 1-3 then All Off:

*************************************************** REACTOR LOGIC SUMMARY REPORT ***************************************************
   Version: 3.2 config 301 cdata 19082 ui 19143 pluginDevice 73
    System: Vera version 1.7.4320 on Sercomm NA301; loadtime 1561455876; systemReady 1561455890; Lua 5.1
Local time: 2019-06-25T11:18:27+0100; DST=1
House mode: plugin 2; system 2; tracking off
  Sun data: { "stamp": 2019176, "civdawn": 1561431433, "nautdawn": 1561427098, "sunset": 1561493910, "nautdusk": 1561501066, "latitude": 51.1953, "astrodusk": null, "longitude": 0.27363, "civdusk": 1561496732, "astrodawn": null, "sunrise": 1561434255 }
  Geofence: not running
====================================================================================================================================
Mood Switch Test (#271)
    Version 19082.2 06/25/19 10:49:18
    Message/status: Not tripped
    Condition group "Mood Switch Reader" (AND) false as of 10:49:20 <root>
      &-?-comment "Mood Switch Reader" <cond0>
      &-F-group "Main Switch On/Off" (AND) false as of 10:50:21 <grpertzoug>
      |     &-F-service MastBed Main Switch (219) urn:upnp-org:serviceId:SwitchPower1/Status change 0,1 [1 => 0 at 10:50:21; F/F as of 10:50:21/10:50:21] <condertzwex>
      &-F-group "Mood 1" (AND) false as of 11:17:57 <grperu0zh7>
      |     &-F-service MastBed Mood Switch (220) urn:micasaverde-com:serviceId:SceneController1/sl_SceneActivated = 111 [112 => 113 at 11:18:03; F/F as of 11:17:57/11:17:57] <conderu1ctw>
      &-F-group "Mood 2" (AND) false as of 11:18:03 <grperu1zbb>
      |     &-F-service MastBed Mood Switch (220) urn:micasaverde-com:serviceId:SceneController1/sl_SceneActivated = 112 [112 => 113 at 11:18:03; F/F as of 11:18:03/11:18:03] <conderu25vr>
      &-T-group "Mood 3" (AND) TRUE as of 11:18:03 <grperu2lve>
      |     &-T-service MastBed Mood Switch (220) urn:micasaverde-com:serviceId:SceneController1/sl_SceneActivated = 113 [112 => 113 at 11:18:03; T/T as of 11:18:03/11:18:03] <conderu2rqa>
      &-T-group "All Off" (AND) TRUE as of 10:49:20 <grperu3g0l>
      |     &-T-service MastBed Mood Switch (220) urn:micasaverde-com:serviceId:SceneController1/sl_SceneDeactivated = 100 [100 at 10:49:20; T/T as of 10:49:20/10:49:20] <conderu3l8l>
    Events
        06/25/19 10:49:20 condchange: newState=true, cond=conderu3l8l
        06/25/19 10:49:20 evalchange: newState=true, cond=conderu3l8l
        06/25/19 10:49:20 condchange: newState=true, cond=grperu3g0l
        06/25/19 10:49:20 evalchange: newState=true, cond=grperu3g0l
        06/25/19 10:49:20 condchange: newState=false, cond=root
        06/25/19 10:49:20 evalchange: newState=false, cond=root
        06/25/19 10:50:02 devicewatch: device=219, old="0", name=MastBed Main Switch, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="1"
        06/25/19 10:50:03 condchange: newState=true, cond=condertzwex, oldState=false
        06/25/19 10:50:03 evalchange: newState=true, cond=condertzwex, oldState=false
        06/25/19 10:50:03 condchange: newState=true, cond=grpertzoug, oldState=false
        06/25/19 10:50:03 evalchange: newState=true, cond=grpertzoug, oldState=false
        06/25/19 10:50:20 devicewatch: device=219, old="1", name=MastBed Main Switch, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="0"
        06/25/19 10:50:21 condchange: newState=false, cond=condertzwex, oldState=true
        06/25/19 10:50:21 evalchange: newState=false, cond=condertzwex, oldState=true
        06/25/19 10:50:21 condchange: newState=false, cond=grpertzoug, oldState=true
        06/25/19 10:50:21 evalchange: newState=false, cond=grpertzoug, oldState=true
        06/25/19 10:50:23 devicewatch: device=219, old="0", name=MastBed Main Switch, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="-1"
        06/25/19 10:50:23 devicewatch: device=219, old="-1", name=MastBed Main Switch, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="0"
        06/25/19 11:17:50 devicewatch: device=220, old="113", name=MastBed Mood Switch, var=urn:micasaverde-com:serviceId:SceneController1/sl_SceneActivated, new="111"
        06/25/19 11:17:51 condchange: newState=true, cond=conderu1ctw, oldState=false
        06/25/19 11:17:51 evalchange: newState=true, cond=conderu1ctw, oldState=false
        06/25/19 11:17:51 condchange: newState=true, cond=grperu0zh7, oldState=false
        06/25/19 11:17:51 evalchange: newState=true, cond=grperu0zh7, oldState=false
        06/25/19 11:17:51 condchange: newState=false, cond=conderu2rqa, oldState=true
        06/25/19 11:17:51 evalchange: newState=false, cond=conderu2rqa, oldState=true
        06/25/19 11:17:51 condchange: newState=false, cond=grperu2lve, oldState=true
        06/25/19 11:17:51 evalchange: newState=false, cond=grperu2lve, oldState=true
        06/25/19 11:17:56 devicewatch: device=220, old="111", name=MastBed Mood Switch, var=urn:micasaverde-com:serviceId:SceneController1/sl_SceneActivated, new="112"
        06/25/19 11:17:57 condchange: newState=false, cond=conderu1ctw, oldState=true
        06/25/19 11:17:57 evalchange: newState=false, cond=conderu1ctw, oldState=true
        06/25/19 11:17:57 condchange: newState=false, cond=grperu0zh7, oldState=true
        06/25/19 11:17:57 evalchange: newState=false, cond=grperu0zh7, oldState=true
        06/25/19 11:17:57 condchange: newState=true, cond=conderu25vr, oldState=false
        06/25/19 11:17:57 evalchange: newState=true, cond=conderu25vr, oldState=false
        06/25/19 11:17:57 condchange: newState=true, cond=grperu1zbb, oldState=false
        06/25/19 11:17:57 evalchange: newState=true, cond=grperu1zbb, oldState=false
        06/25/19 11:18:02 devicewatch: device=220, old="112", name=MastBed Mood Switch, var=urn:micasaverde-com:serviceId:SceneController1/sl_SceneActivated, new="113"
        06/25/19 11:18:03 condchange: newState=false, cond=conderu25vr, oldState=true
        06/25/19 11:18:03 evalchange: newState=false, cond=conderu25vr, oldState=true
        06/25/19 11:18:03 condchange: newState=false, cond=grperu1zbb, oldState=true
        06/25/19 11:18:03 evalchange: newState=false, cond=grperu1zbb, oldState=true
        06/25/19 11:18:03 condchange: newState=true, cond=conderu2rqa, oldState=false
        06/25/19 11:18:03 evalchange: newState=true, cond=conderu2rqa, oldState=false
        06/25/19 11:18:03 condchange: newState=true, cond=grperu2lve, oldState=false
        06/25/19 11:18:03 evalchange: newState=true, cond=grperu2lve, oldState=false
        06/25/19 11:18:08 devicewatch: device=219, old="0", name=MastBed Main Switch, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="-1"
        06/25/19 11:18:08 devicewatch: device=219, old="-1", name=MastBed Main Switch, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="0"
        06/25/19 11:18:08 devicewatch: device=220, old="100", name=MastBed Mood Switch, var=urn:micasaverde-com:serviceId:SceneController1/sl_SceneDeactivated, new="100"
        06/25/19 11:18:11 devicewatch: device=219, old="0", name=MastBed Main Switch, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="-1"
        06/25/19 11:18:11 devicewatch: device=219, old="-1", name=MastBed Main Switch, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="0"

Apologies for the lengthy post!!

Seems all is well for the 3 scene buttons. Those conditions will go true, so if you put them each in different groups, as you have already done, you can use the true activity of those groups to perform the needed actions.

The All Off is driven from a different variable (you know that, just calling it out to be noticed by anyone else reading), so it won’t change value with other button presses unless the underlying device/Vera/RFX plugin changes it. So that condition will remain true, probably forever.

Since you don’t have any actions configured, I think you’re assuming that’s a problem because the condition never resets. It is and it isn’t. It’s not a problem because the activity for the condition’s parent group will only run when the condition changes state (from false to true or true to false). The fact that it stays true does not mean that any (All Off) activity will be run again and again and again. This is not how Reactor operates. Reactor only initiates activities when the group state changes. So if the group goes true, as it has, the activity is run for that transition, but every subsequent evaluation of the condition will do nothing because the group remains true (there is no transition until the condition test is not met).

This behavior, however, is a problem for scene controllers, as they will re-write variable values with the same value (as you are seeing with sl_SceneDeactivated). So Reactor sees no change in the value, and therefore no change in the condition state, and therefore no change in group state, and… will not run activities after the first time. In order for that to change, the device/RFX plugin/Luup would need to write some other value to the variable. That’s not really desirable either, because rewriting these variables is a standard behavior of scene controllers.

I’ve done a lot with scene controllers in my own home, and I even have an unpublished plugin that I use for making several different types of scene controllers (Leviton 1-, 2- and 4-button, ZRC90, Enerwave SC-7, etc.) work the way I want them to. Along the way, I’ve discovered that scene controllers do some unique things, first and foremost of which is that they will rewrite variables with the same value, and that will actually pass through to a Luup watch (the last lines of the Events section of your logic summary actually demonstrates this). This is not at all consistent within Luup for all devices–many filter repeated values, but scene controllers (fortunately) do write same-value attempts.

I’ve been working on Reactor 3.3 for a few weeks, and a new “updated” operator is part of that work, exactly for detecting scenarios like this–I’ve already run into the 3.2 limitation in my own work/play. So while the current version (3.2) of Reactor cannot respond to the same-value rewrites on sl_SceneDeactivated, version 3.3 will bring this capability and deliver what you need.

So, stay tuned. I’m traveling at the moment, but I will make sure the new operator gets out to the stable release as soon as I get home (this weekend).

In the meanwhile, I would also look carefully at the Status variable. You are specifically looking for changes from 0 to 1, but note that in the last lines of the events in the summary, it goes from 0 to -1, so you may want to research what that means for the device and see how that might affect your first condition group. In addition, since it seems to bracket the setting of sl_SceneDeactivated you may be able to use that -1 value as an additional way of detecting “All Off” right now in advanced of my upcoming changes. That’s device-/plugin(RFXtrx)-dependent, so I can’t guide you there beyond that.

1 Like

Excellent news that something is already in the pipeline to solve this!
I will test with 3.3 once it is available and let you know.

Thanks for your help :slight_smile:

@rigpapa

I thought I’d have a play with using the 0 to -1, -1 to 0 status change in the main switch to detect an all off.
Even though it shown is the logic summary every time I press “All Off”, the reactor sensor never trips.

        06/26/19 16:11:25 devicewatch: device=219, old="0", name=MastBed Main Switch, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="-1"
        06/26/19 16:11:25 devicewatch: device=219, old="-1", name=MastBed Main Switch, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="0"
        06/26/19 16:11:25 devicewatch: device=220, old="100", name=MastBed Mood Switch, var=urn:micasaverde-com:serviceId:SceneController1/sl_SceneDeactivated, new="100"

Is it possible for a status change to be too fast for reactor to trip?

The fact that you are seeing it in the events means Reactor sees it. I would need to see the condition you set up.

I tried:
Changes from 0 to -1
Changes from -1 to 0
Changes from anything to -1
Changes from anything to 0
Changes from anything to anything.

As a proper fix is on the way I wouldn’t want to waste your time on it, just seemed odd that the sensor doesn’t trip

I’d actually like to see a full Logic Summary for this if you can reproduce it.

Here you go…

*************************************************** REACTOR LOGIC SUMMARY REPORT ***************************************************
   Version: 3.2 config 301 cdata 19082 ui 19143 pluginDevice 73
    System: Vera version 1.7.4320 on Sercomm NA301; loadtime 1561637968; systemReady 1561637983; Lua 5.1
Local time: 2019-06-27T14:43:30+0100; DST=1
House mode: plugin 1; system 1; tracking off
  Sun data: { "stamp": 2019178, "civdawn": 1561604290, "nautdawn": 1561599977, "sunset": 1561666707, "nautdusk": 1561673835, "latitude": 51.1953, "astrodusk": null, "longitude": 0.27363, "civdusk": 1561669522, "astrodawn": null, "sunrise": 1561607105 }
  Geofence: not running
====================================================================================================================================
MasterBed Reactor (#277)
    Version 19082.13 06/27/19 14:33:50
    Message/status: Not tripped
    Condition group "Master Bedroom" (AND) false as of 15:33:22 <root>
      &-F-group "Main Switch" (AND) false as of 15:33:22 <grpetjp6tt>
      |     &-F-service MastBed Main Switch (219) urn:upnp-org:serviceId:SwitchPower1/Status = 1 [-1 => 0 at 15:43:27; F/F as of 15:40:46/15:40:46] <condetjpjcy>
      |     &-T-group "Scene 1" (AND) TRUE as of 14:42:41 <grpetjq9dm>
      |     |     &-T-service MastBed Mood Switch (220) urn:micasaverde-com:serviceId:SceneController1/sl_SceneActivated = 111 [112 => 111 at 14:42:41; T/T as of 14:42:41/14:42:41] <condetjqe5e>
      |     &-F-group "Scene 2" (AND) false as of 14:42:41 <grpetjqfky>
      |     |     &-F-service MastBed Mood Switch (220) urn:micasaverde-com:serviceId:SceneController1/sl_SceneActivated = 112 [112 => 111 at 14:42:41; F/F as of 14:42:41/14:42:41] <condetjqksz>
      |     &-F-group "Scene 3" (AND) false as of 16:11:20 <grpetjqlwi>
      |     |     &-F-service MastBed Mood Switch (220) urn:micasaverde-com:serviceId:SceneController1/sl_SceneActivated = 113 [112 => 111 at 14:42:41; F/F as of 16:11:20/16:11:20] <condetjqsir>
      |     &-F-group "All Off" (AND) false as of 15:37:20 <grpetjqtuq>
      |     |     &-F-service MastBed Main Switch (219) urn:upnp-org:serviceId:SwitchPower1/Status change  [100 => 0 at 16:07:20; F/F as of 15:37:20/15:37:20] <condetjqyqy>
    Activity grpetjqlwi.true
        Device 102 (Master Bed Pendant) action urn:upnp-org:serviceId:Dimming1/SetLoadLevelTarget( newLoadlevelTarget="25" )
        Device 59 (Master Bedroom Spots) action urn:upnp-org:serviceId:Dimming1/SetLoadLevelTarget( newLoadlevelTarget="25" )
    Activity grpetjp6tt.false
        Device 102 (Master Bed Pendant) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue="0" )
    Activity grpetjp6tt.true
        Device 102 (Master Bed Pendant) action urn:upnp-org:serviceId:Dimming1/SetLoadLevelTarget( newLoadlevelTarget="100" )
    Activity grpetjqtuq.true
        Device 102 (Master Bed Pendant) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue="0" )
        Device 59 (Master Bedroom Spots) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue="0" )
    Activity grpetjq9dm.true
        Device 102 (Master Bed Pendant) action urn:upnp-org:serviceId:Dimming1/SetLoadLevelTarget( newLoadlevelTarget="75" )
        Device 59 (Master Bedroom Spots) action urn:upnp-org:serviceId:Dimming1/SetLoadLevelTarget( newLoadlevelTarget="75" )
    Activity grpetjqfky.true
        Device 102 (Master Bed Pendant) action urn:upnp-org:serviceId:Dimming1/SetLoadLevelTarget( newLoadlevelTarget="50" )
        Device 59 (Master Bedroom Spots) action urn:upnp-org:serviceId:Dimming1/SetLoadLevelTarget( newLoadlevelTarget="50" )
    Events
        06/27/19 13:19:37 start: 
        06/27/19 14:33:49 configchange: 
        06/27/19 14:34:22 devicewatch: device=219, old="0", name=MastBed Main Switch, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="-1"
        06/27/19 14:34:22 devicewatch: device=219, old="-1", name=MastBed Main Switch, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="0"
        06/27/19 14:34:28 devicewatch: device=219, old="0", name=MastBed Main Switch, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="-1"
        06/27/19 14:34:28 devicewatch: device=219, old="-1", name=MastBed Main Switch, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="0"
        06/27/19 14:34:34 devicewatch: device=219, old="0", name=MastBed Main Switch, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="-1"
        06/27/19 14:34:34 devicewatch: device=219, old="-1", name=MastBed Main Switch, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="0"
        06/27/19 14:42:40 devicewatch: device=220, old="112", name=MastBed Mood Switch, var=urn:micasaverde-com:serviceId:SceneController1/sl_SceneActivated, new="111"
        06/27/19 14:42:41 condchange: newState=true, cond=condetjqe5e, oldState=false
        06/27/19 14:42:41 evalchange: newState=true, cond=condetjqe5e, oldState=false
        06/27/19 14:42:41 condchange: newState=true, cond=grpetjq9dm, oldState=false
        06/27/19 14:42:41 evalchange: newState=true, cond=grpetjq9dm, oldState=false
        06/27/19 14:42:41 condchange: newState=false, cond=condetjqksz, oldState=true
        06/27/19 14:42:41 evalchange: newState=false, cond=condetjqksz, oldState=true
        06/27/19 14:42:41 condchange: newState=false, cond=grpetjqfky, oldState=true
        06/27/19 14:42:41 evalchange: newState=false, cond=grpetjqfky, oldState=true
        06/27/19 14:42:41 startscene: scene=grpetjq9dm.true, sceneName=grpetjq9dm.true
        06/27/19 14:42:41 runscene: scene=grpetjq9dm.true, sceneName=grpetjq9dm.true, group=1, notice=Starting scene group 1
        06/27/19 14:42:41 endscene: scene=grpetjq9dm.true, sceneName=grpetjq9dm.true
        06/27/19 14:42:48 devicewatch: device=219, old="0", name=MastBed Main Switch, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="-1"
        06/27/19 14:42:48 devicewatch: device=219, old="-1", name=MastBed Main Switch, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="0"
        06/27/19 14:42:58 devicewatch: device=220, old="111", name=MastBed Mood Switch, var=urn:micasaverde-com:serviceId:SceneController1/sl_SceneActivated, new="111"
        06/27/19 14:43:05 devicewatch: device=219, old="0", name=MastBed Main Switch, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="-1"
        06/27/19 14:43:05 devicewatch: device=219, old="-1", name=MastBed Main Switch, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="0"

This is with the All Off set to changes from anything to anything

Got it. Yeah, this is a race condition. The variable is being set to -1 and then back to 0 immediately with pretty much no useful delay between, so by the time Reactor requests the value, it’s already been put back to 0. What’s setting that back and forth so quickly?

image

This is the switch.
The area in red shows up as device 219, the area in blue shows up as device 220.
Hitting “ALL OFF” on device 220 is doing a fast reset of device 219

Is this RFXtrx operating 219 as an impulse switch? Scene? What’s doing the quick reset?

Here’s how it shows up in rfxtrx controller:
image
219 is a simple on/off switch. Status goes to 1 when you press the top button, 0 when you press the bottom button

OK, so how is the fast transition accomplished? Is it the RFXtrx plugin doing it automatically? What’s the configuration of “ALL OFF”?

I think rfxtrx is doing it automatically.
Which configuration? Reactor?

OK. I think I’ve got the picture.

The current stable release on Github (3.3develop-19178) should handle the RFXtrx transition a little better, at least for now.

This version also implements a new “updates” operator for device state conditions. This will trigger a true pulse (like the “changes” operator with no terminal values) when a state variable is rewritten if Vera sends watch callbacks for that change–Vera/Luup does not do that for all variables, but it does it for sl_SceneActivated and sl_SceneDeactivated, which is what we need.

If you would, please try your “ALL OFF” using the 0 → -1 check, to confirm that the timing fix works.

Once we’ve established that that is work, then you can go back to checking sl_SceneDeactivated.

Edit: install instructions, if needed…

  1. Go to the Github stable branch
  2. Click the green “Clone or download” button and choose “Download ZIP”
  3. Unzip the zip file to a folder.
  4. Upload the unzipped files by selecting them all and dragging the group to the upload tool at Apps > Develop apps > Luup files. This will also reload Luup after the uploads are done.
  5. Hard-refresh your browser.

Just managed to test.
All Off using 0 → -1 does work.
Using the new UPDATES operator also works. :smile::smile:

1 Like

Just confirming, you mean/tried “UPDATES”?

yes - UPDATES, not CHANGES.

1 Like

Woot! That’s awesome!

I’ve been moving my vera scenes to reactor over the weekend and have one final issue.
If I select a scene, then all off, then the same scene again the sensor will not trip as it is still tripped from before.
Is there any way round this?