I am trying to set a Variable in a Reactor Sensor and perform an action when the variable changes to equal “1”. As a test case (posted logic below) I created an expression “TestVar” with an empty expression, a first group (TestVariableChange) with a condition to check if “TestVar” equals “1”, and a second group (ChangeTestVariable) that checks the state of a light. The activity of the second group sets “TestVar” to “1” when the light is on and to “0” when the light is off.
What I expect to happen is when the light turns on the TestVariableChange is True because TestVar is set to “1” when the light comes on and when the light turns off TestVariableChange is False because TestVar is set to “0”. What I also expect to happen is if I manually change TestVar to “1” or “0” the TestVariableChange becomes True or False accordingly.
What actually happens is TestVariableChange lags behind the light as in when the light is off TestVariableChange is True (while TestVar is “0”) and when the light is on TestVariableChange is False (while testVar is “1”). Also, nothing happens if I manually change TestVar.
What I think is happening is the Reactor Sensor is not re-evaluating conditions when the TestVar changes and sees the change when some other condition causes a re-evaluate, such as the light coming on/off. I believe it lags the light because when the light state changes, Reactor re-evaluates the conditions, sees the value of TestVar before the action changes TestVar (so it is the previous value).
Am I misunderstanding variables and how they work in Reactor or is there some other underlying issue?
*************************************************** REACTOR LOGIC SUMMARY REPORT ***************************************************
Version: 3.0 config 301 cdata 19082 ui 19125 pluginDevice 342
System: Vera version 1.7.4453 on Sercomm G450; loadtime 1557342194; systemReady 1557342218; Lua 5.1
Local time: 2019-05-08T16:02:47-0400; DST=1
House mode: plugin 1; system 1; tracking off
Sun data:
Geofence: not running
====================================================================================================================================
Reactor Sensor 3 (#345)
Version 19082.1557343620 05/08/19 15:27:00
Message/status: Not tripped
Variable/expressions
0: TestVar [last "1"(string)] (exported)
Condition group "Reactor Sensor 3" (AND) false as of 15:13:15 <root>
&-F-group "TestVariableChange" (AND) false as of 16:02:27 <grpcvt7m9f>
| &-F-service Reactor Sensor 3 (345) urn:toggledbits-com:serviceId:ReactorValues/TestVar = 1 (match case) [1 => 0 at 16:02:27; F/F as of 16:02:27/16:02:27] <condcvsy514>
&-T-group "ChangeTestVariable" (AND) TRUE as of 16:02:27 <grpcvt8jnz>
| &-T-service LampDimmer (189) urn:upnp-org:serviceId:SwitchPower1/Status = 1 (match case) [0 => 1 at 16:02:27; T/T as of 16:02:27/16:02:27] <condcvt8xaj>
Activity grpcvt8jnz.true
Device 345 (Reactor Sensor 3) action urn:toggledbits-com:serviceId:ReactorSensor/SetVariable( VariableName=TestVar, NewValue=1 )
Activity grpcvt8jnz.false
Device 345 (Reactor Sensor 3) action urn:toggledbits-com:serviceId:ReactorSensor/SetVariable( VariableName=TestVar, NewValue=0 )
Events
05/08/19 15:26:32 devicewatch: device=189, old="1", name=LampDimmer, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="0"
05/08/19 15:26:33 condchange: newState=true, cond=condcvsy514, oldState=false
05/08/19 15:26:33 evalchange: newState=true, cond=condcvsy514, oldState=false
05/08/19 15:26:33 condchange: newState=true, cond=grpcvt7m9f, oldState=false
05/08/19 15:26:33 evalchange: newState=true, cond=grpcvt7m9f, oldState=false
05/08/19 15:26:33 condchange: newState=false, cond=condcvt8xaj, oldState=true
05/08/19 15:26:33 evalchange: newState=false, cond=condcvt8xaj, oldState=true
05/08/19 15:26:33 condchange: newState=false, cond=grpcvt8jnz, oldState=true
05/08/19 15:26:33 evalchange: newState=false, cond=grpcvt8jnz, oldState=true
05/08/19 15:26:33 startscene: scene=grpcvt8jnz.false, sceneName=grpcvt8jnz.false
05/08/19 15:26:33 runscene: scene=grpcvt8jnz.false, sceneName=grpcvt8jnz.false, group=1, notice=Starting scene group 1
05/08/19 15:26:33 endscene: scene=grpcvt8jnz.false, sceneName=grpcvt8jnz.false
05/08/19 15:27:00 configchange:
05/08/19 15:27:00 configchange:
05/08/19 15:27:01 condchange: newState=false, cond=condcvsy514, oldState=true
05/08/19 15:27:01 evalchange: newState=false, cond=condcvsy514, oldState=true
05/08/19 15:27:01 condchange: newState=false, cond=grpcvt7m9f, oldState=true
05/08/19 15:27:01 evalchange: newState=false, cond=grpcvt7m9f, oldState=true
05/08/19 15:27:11 devicewatch: device=189, old="0", name=LampDimmer, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="1"
05/08/19 15:27:12 condchange: newState=true, cond=condcvt8xaj, oldState=false
05/08/19 15:27:12 evalchange: newState=true, cond=condcvt8xaj, oldState=false
05/08/19 15:27:12 condchange: newState=true, cond=grpcvt8jnz, oldState=false
05/08/19 15:27:12 evalchange: newState=true, cond=grpcvt8jnz, oldState=false
05/08/19 15:27:12 startscene: scene=grpcvt8jnz.true, sceneName=grpcvt8jnz.true
05/08/19 15:27:12 runscene: scene=grpcvt8jnz.true, sceneName=grpcvt8jnz.true, group=1, notice=Starting scene group 1
05/08/19 15:27:12 endscene: scene=grpcvt8jnz.true, sceneName=grpcvt8jnz.true
05/08/19 16:02:20 devicewatch: device=189, old="1", name=LampDimmer, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="0"
05/08/19 16:02:21 condchange: newState=true, cond=condcvsy514, oldState=false
05/08/19 16:02:21 evalchange: newState=true, cond=condcvsy514, oldState=false
05/08/19 16:02:21 condchange: newState=true, cond=grpcvt7m9f, oldState=false
05/08/19 16:02:21 evalchange: newState=true, cond=grpcvt7m9f, oldState=false
05/08/19 16:02:21 condchange: newState=false, cond=condcvt8xaj, oldState=true
05/08/19 16:02:21 evalchange: newState=false, cond=condcvt8xaj, oldState=true
05/08/19 16:02:21 condchange: newState=false, cond=grpcvt8jnz, oldState=true
05/08/19 16:02:21 evalchange: newState=false, cond=grpcvt8jnz, oldState=true
05/08/19 16:02:21 startscene: scene=grpcvt8jnz.false, sceneName=grpcvt8jnz.false
05/08/19 16:02:21 runscene: scene=grpcvt8jnz.false, sceneName=grpcvt8jnz.false, group=1, notice=Starting scene group 1
05/08/19 16:02:21 endscene: scene=grpcvt8jnz.false, sceneName=grpcvt8jnz.false
05/08/19 16:02:26 devicewatch: device=189, old="0", name=LampDimmer, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="1"
05/08/19 16:02:27 condchange: newState=false, cond=condcvsy514, oldState=true
05/08/19 16:02:27 evalchange: newState=false, cond=condcvsy514, oldState=true
05/08/19 16:02:27 condchange: newState=false, cond=grpcvt7m9f, oldState=true
05/08/19 16:02:27 evalchange: newState=false, cond=grpcvt7m9f, oldState=true
05/08/19 16:02:27 condchange: newState=true, cond=condcvt8xaj, oldState=false
05/08/19 16:02:27 evalchange: newState=true, cond=condcvt8xaj, oldState=false
05/08/19 16:02:27 condchange: newState=true, cond=grpcvt8jnz, oldState=false
05/08/19 16:02:27 evalchange: newState=true, cond=grpcvt8jnz, oldState=false
05/08/19 16:02:27 startscene: scene=grpcvt8jnz.true, sceneName=grpcvt8jnz.true
05/08/19 16:02:27 runscene: scene=grpcvt8jnz.true, sceneName=grpcvt8jnz.true, group=1, notice=Starting scene group 1
05/08/19 16:02:27 endscene: scene=grpcvt8jnz.true, sceneName=grpcvt8jnz.true