Trouble reading expressions between reactor sensors

I’m relatively new to reactor but I’ve been able to craft the activity that I want. I’m setting the dim level on my light switches depending on the time of day.

I have about 15 dimmers and to try and simplify tweaking the settings I tried to create one master sensor that had daytime and nighttime dim levels set for each of the dimmers. I then create a new sensor for each room that has the conditions for triggering setting the dim levels. For example I don’t want to reset the dim levels if any of the devices are on so I check time of day along with the “on” state of all the devices in the room to trigger the scene.

The problem I am having is even though I made the dim level variables global in the master sensor and I can see them in my other room level sensors.

I use getstate to read the values into variables in each sub sensor. The results for variables in the sub sensors look correct. They report the values I stored in the master sensor and appear to be strings.

When I try to use the variables to set something however, it looks like the variables always report as 0. I’ve tried wrapping the getstate() call in the tonumber() function but still no luck.

Any ideas on what could be wrong?

On a second topic is there anyway I can read the Vera device number from the device name? I currently need to embed some lua code in the sensor action section and it would be easier if I could just use the dimmer name in case I add or remove devices to the system.

Thanks for your help.

Please post Logic Summaries (Toosl tab) for your master sensor and one of your slaves that is typical of the lot. Be sure to read the posting instructions at the top of the report.

Here is the logic summary for the master sensor:

*************************************************** REACTOR LOGIC SUMMARY REPORT ***************************************************
   Version: 3.4 config 19226 cdata 19082 ui 19237 pluginDevice 495
    System: Vera version 1.7.4453 on Sercomm G450; loadtime 1575740558; systemReady 1575740576; Lua 5.1; JSON dkjson 1.2
Local time: 2019-12-08T14:29:00-0600; DST=0; Austin, Texas United States
House mode: plugin 1; system 1; tracking off
  Sun data: { "stamp": 2019342, "civdawn": 1575809335, "nautdawn": 1575807548, "sunset": 1575847842, "nautdusk": 1575851208, "latitude": 30.2672, "astrodusk": 1575852960, "longitude": -97.7431, "civdusk": 1575849420, "astrodawn": 1575805796, "sunrise": 1575810913 }
  Geofence: not running
====================================================================================================================================
Light Level Settings (#500)
    Version 19082.20 12/08/19 14:22:18
    Message/status: Not tripped
    Variable/expressions
       0: office_night_dim_level   1 [last 1(number)] (exported)
       1: office_day_dim_level     30 [last 30(number)] (exported)
       2: TV_night_dim_level       30 [last 30(number)] (exported)
       3: TV_day_dim_level         45 [last 45(number)] (exported)
       4: breakfast_night_dim_level 30 [last 30(number)] (exported)
       5: breakfast_day_dim_level  100 [last 100(number)] (exported)
       6: living_night_dim_level   30 [last 30(number)] (exported)
       7: living_day_dim_level     100 [last 100(number)] (exported)
       8: master_night_dim_level   30 [last 30(number)] (exported)
       9: master_day_dim_level     100 [last 100(number)] (exported)
      10: laundry_night_dim_level  1 [last 1(number)] (exported)
      11: laundry_day_dim_level    30 [last 30(number)] (exported)
      12: kitchen_day_dim_level    100 [last 100(number)] (exported)
      13: kitchen_night_dim_level  30 [last 30(number)] (exported)
    Condition group "Light Level Config" (NUL)  false as of n/a <root>
    Events
        12/07/19 11:42:51 reload: notice=Luup reload
        12/07/19 11:42:51 start: 
        12/07/19 19:30:00 condchange: newState=false, cond=condky3srwn, oldState=true
        12/07/19 19:30:00 evalchange: newState=false, cond=condky3srwn, oldState=true
        12/07/19 19:30:00 condchange: newState=false, cond=grpky3se8n, oldState=true
        12/07/19 19:30:00 evalchange: newState=false, cond=grpky3se8n, oldState=true
        12/08/19 07:15:00 condchange: newState=true, cond=condky3srwn, oldState=false
        12/08/19 07:15:00 evalchange: newState=true, cond=condky3srwn, oldState=false
        12/08/19 07:15:00 condchange: newState=true, cond=grpky3se8n, oldState=false
        12/08/19 07:15:00 evalchange: newState=true, cond=grpky3se8n, oldState=false
        12/08/19 14:07:55 configchange: 
        12/08/19 14:15:55 configchange: 
        12/08/19 14:15:59 variable: oldval=100, variable=TV_day_dim_level, newval=75
        12/08/19 14:22:19 configchange: 
        12/08/19 14:22:20 variable: oldval=75, variable=TV_day_dim_level, newval=45
        12/08/19 14:22:23 configchange: 

And here is the logic summary for the room sensor trying to use those exported values:

*************************************************** REACTOR LOGIC SUMMARY REPORT ***************************************************
   Version: 3.4 config 19226 cdata 19082 ui 19237 pluginDevice 495
    System: Vera version 1.7.4453 on Sercomm G450; loadtime 1575740558; systemReady 1575740576; Lua 5.1; JSON dkjson 1.2
Local time: 2019-12-08T14:31:52-0600; DST=0; Austin, Texas United States
House mode: plugin 1; system 1; tracking off
  Sun data: { "stamp": 2019342, "civdawn": 1575809335, "nautdawn": 1575807548, "sunset": 1575847842, "nautdusk": 1575851208, "latitude": 30.2672, "astrodusk": 1575852960, "longitude": -97.7431, "civdusk": 1575849420, "astrodawn": 1575805796, "sunrise": 1575810913 }
  Geofence: not running
====================================================================================================================================
TV Light Config (#506)
    Version 19082.32 12/08/19 14:30:31
    Message/status: Not tripped
    Variable/expressions
       0: day_dim                  getstate( 500, "urn:toggledbits-com:serviceId:ReactorValues", "TV_day_dim_level" ) [last "45"(string)]
       1: night_dim                getstate( 500, "urn:toggledbits-com:serviceId:ReactorValues", "TV_night_dim_level" ) [last "30"(string)]
    Condition group "TV Light Config" (NUL)  false as of n/a <root>
      Z-T-group "Daytime" (AND)  TRUE as of 07:15:00 <grpky3k4ty>
      |     &-T-sun bet sunrise+0,sunset+120 [1575837109 => 1575837110 at 14:31:50; T/T as of 07:15:00/07:15:00] <condky3k5vy>
      Z-F-group "Device Config" (AND)  false as of 14:31:49 <grpky3ktcn>
      |     &-F-service TV Room (432) urn:upnp-org:serviceId:SwitchPower1/Status = 0 for ge 5s [1 => 0 at 14:31:29; T/F as of 14:31:29/14:31:49] <condky3kvjb>
      Z-F-group "Daytime Config" (AND)  false as of 14:31:49 <grpky3lgi9>
      |     &-T-grpstate (self) (-1) Daytime (grpky3k4ty) istrue [true at 07:15:00; T/T as of 07:15:00/07:15:00] <condky3lr3b>
      |     &-F-grpstate (self) (-1) Device Config (grpky3ktcn) istrue [true => false at 14:31:49; F/F as of 14:31:49/14:31:49] <condky3m4w8>
      Z-F-group "Nighttime Config" (AND)  false as of 12-07.00:00:21 <grpky3mc48>
      |     &-F-grpstate (self) (-1) Daytime (grpky3k4ty) isfalse [true at 07:15:00; F/F as of 07:15:00/07:15:00] <condky3mkof>
      |     &-F-grpstate (self) (-1) Device Config (grpky3ktcn) istrue [true => false at 14:31:49; F/F as of 14:31:49/14:31:49] <condky3mumn>
    Activity grpky3lgi9.true
        Run Lua:
             1: --- local dim_level = getstate( 500, "urn:toggledbits-com:serviceId:ReactorValues", "TV_day_dim_level" )
             2: local dim_level = day_dim
             3: --- local dim_level = "75"
             4: --- Setup TV Room Recessed
             5: luup.variable_set("urn:upnp-org:serviceId:Dimming1", "LoadLevelLast", dim_level, 432)
             6: luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetTarget", dim_level, 432)
    Activity grpky3mc48.true
        Run Lua:
             1: local dim_level  = night_dim
             2: --- Setup TV Room Recessed
             3: luup.variable_set("urn:upnp-org:serviceId:Dimming1", "LoadLevelLast", dim_level, 432)
             4: luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetTarget", dim_level, 432)
    Events
        12/08/19 14:31:05 evalchange: newState=true, cond=grpky3ktcn, oldState=false
        12/08/19 14:31:05 condchange: newState=true, cond=condky3m4w8, oldState=false
        12/08/19 14:31:05 evalchange: newState=true, cond=condky3m4w8, oldState=false
        12/08/19 14:31:05 condchange: newState=true, cond=grpky3lgi9, oldState=false
        12/08/19 14:31:05 evalchange: newState=true, cond=grpky3lgi9, oldState=false
        12/08/19 14:31:05 condchange: newState=true, cond=condky3mumn, oldState=false
        12/08/19 14:31:05 evalchange: newState=true, cond=condky3mumn, oldState=false
        12/08/19 14:31:05 devicewatch: device=506, old="0", name=TV Light Config, var=urn:toggledbits-com:serviceId:ReactorGroup/GroupStatus_grpky3ktcn, new="1"
        12/08/19 14:31:05 startscene: scene=grpky3lgi9.true, sceneName=grpky3lgi9.true
        12/08/19 14:31:05 runscene: scene=grpky3lgi9.true, sceneName=grpky3lgi9.true, group=1, notice=Starting scene group 1
        12/08/19 14:31:05 lua: script=rs506_scgrpky3lgi9.true_gr1_ac1, message=ERROR: Using uninitialized global variable day_dim
        12/08/19 14:31:05 endscene: scene=grpky3lgi9.true, sceneName=grpky3lgi9.true
        12/08/19 14:31:20 evalchange: newState=false, cond=condky3kvjb, oldState=true
        12/08/19 14:31:20 condchange: newState=false, cond=grpky3ktcn, oldState=true
        12/08/19 14:31:20 evalchange: newState=false, cond=grpky3ktcn, oldState=true
        12/08/19 14:31:20 condchange: newState=false, cond=condky3m4w8, oldState=true
        12/08/19 14:31:20 evalchange: newState=false, cond=condky3m4w8, oldState=true
        12/08/19 14:31:20 condchange: newState=false, cond=grpky3lgi9, oldState=true
        12/08/19 14:31:20 evalchange: newState=false, cond=grpky3lgi9, oldState=true
        12/08/19 14:31:20 condchange: newState=false, cond=condky3mumn, oldState=true
        12/08/19 14:31:20 evalchange: newState=false, cond=condky3mumn, oldState=true
        12/08/19 14:31:20 devicewatch: device=506, old="1", name=TV Light Config, var=urn:toggledbits-com:serviceId:ReactorGroup/GroupStatus_grpky3ktcn, new="0"
        12/08/19 14:31:27 devicewatch: device=432, old="0", name=TV Room, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="1"
        12/08/19 14:31:27 condchange: newState=false, cond=condky3kvjb, oldState=true
        12/08/19 14:31:29 devicewatch: device=432, old="1", name=TV Room, var=urn:upnp-org:serviceId:SwitchPower1/Status, new="0"
        12/08/19 14:31:29 condchange: newState=true, cond=condky3kvjb, oldState=false
        12/08/19 14:31:34 evalchange: newState=true, cond=condky3kvjb, oldState=false
        12/08/19 14:31:34 condchange: newState=true, cond=grpky3ktcn, oldState=false
        12/08/19 14:31:34 evalchange: newState=true, cond=grpky3ktcn, oldState=false
        12/08/19 14:31:34 condchange: newState=true, cond=condky3m4w8, oldState=false
        12/08/19 14:31:34 evalchange: newState=true, cond=condky3m4w8, oldState=false
        12/08/19 14:31:34 condchange: newState=true, cond=grpky3lgi9, oldState=false
        12/08/19 14:31:34 evalchange: newState=true, cond=grpky3lgi9, oldState=false
        12/08/19 14:31:34 condchange: newState=true, cond=condky3mumn, oldState=false
        12/08/19 14:31:34 evalchange: newState=true, cond=condky3mumn, oldState=false
        12/08/19 14:31:34 devicewatch: device=506, old="0", name=TV Light Config, var=urn:toggledbits-com:serviceId:ReactorGroup/GroupStatus_grpky3ktcn, new="1"
        12/08/19 14:31:34 startscene: scene=grpky3lgi9.true, sceneName=grpky3lgi9.true
        12/08/19 14:31:34 runscene: scene=grpky3lgi9.true, sceneName=grpky3lgi9.true, group=1, notice=Starting scene group 1
        12/08/19 14:31:34 lua: script=rs506_scgrpky3lgi9.true_gr1_ac1, message=ERROR: Using uninitialized global variable day_dim
        12/08/19 14:31:34 endscene: scene=grpky3lgi9.true, sceneName=grpky3lgi9.true
        12/08/19 14:31:49 evalchange: newState=false, cond=condky3kvjb, oldState=true
        12/08/19 14:31:49 condchange: newState=false, cond=grpky3ktcn, oldState=true
        12/08/19 14:31:49 evalchange: newState=false, cond=grpky3ktcn, oldState=true
        12/08/19 14:31:49 condchange: newState=false, cond=condky3m4w8, oldState=true
        12/08/19 14:31:49 evalchange: newState=false, cond=condky3m4w8, oldState=true
        12/08/19 14:31:49 condchange: newState=false, cond=grpky3lgi9, oldState=true
        12/08/19 14:31:49 evalchange: newState=false, cond=grpky3lgi9, oldState=true
        12/08/19 14:31:49 condchange: newState=false, cond=condky3mumn, oldState=true
        12/08/19 14:31:49 evalchange: newState=false, cond=condky3mumn, oldState=true
        12/08/19 14:31:49 devicewatch: device=506, old="1", name=TV Light Config, var=urn:toggledbits-com:serviceId:ReactorGroup/GroupStatus_grpky3ktcn, new="0"
    Devices
        ZWave (1) urn:schemas-micasaverde-com:device:ZWaveNetwork:1 (19/0); parent 0; plugin -
        TV Room (432) urn:schemas-upnp-org:device:DimmableLight:1 (2/0); parent 1; plugin -

You can see in the log that I tried to use all of the following to get the correct value from the master sensor:

local dim_level = getstate( 500, “urn:toggledbits-com:serviceId:ReactorValues”, “TV_day_dim_level” )
local dim_level = day_dim

Both of theses statements work correctly:

local dim_level = “75”
local dim_level = 75

Reactor expression variables are not local variables in the Run Lua code. You can access them, but honestly, you’re doing the actions the hard way.

All you need to do is a “Device Action” in the activity(ies), and put in {day_dim} or {night_dim} for the value (load level) parameter as the case may require. The {} will perform a substitution with the named variable’s value and send that on the action. No Lua required.

Your action should “Set dimming level” (which is a synonym for SetLoadLevelTarget UPnP action).

Thanks for the feedback, but I think I need to use LUA.

I’m trying to set the dim level without turning on the lights. There are several threads discussing this topic and my understanding is that combo is the only way to do it.

luup.variable_set(“urn:upnp-org:serviceId:Dimming1”, “LoadLevelLast”, dim_level, 432)
luup.call_action(“urn:upnp-org:serviceId:Dimming1”, “SetTarget”, dim_level, 432)

Other options either turn the lights on when you set the dim level variable or it doesn’t actually take.

My preference is not to write LUA code but unfortunately this is the only combo that works reliably.

Also I think that the LoadLevelLast variable isn’t in the standard lighting device description so it doesn’t show up in the list of options when I try to directly do a device action.

So with all of that said unless there is a way to do those calls outside of LUA I’m stuck with this approach.

OK. Then look at the wiki entry for the Run Lua action. There is a way to access the variable values there more easily.