Is This Possible

Hello, I have a hue outdoor motion sensor and am using AltHue in Vera the light sensor reports what I think is the light level (extremely high) as opposed to the actual lux level
image

If I create a virtual sensor is then possible have a calculation to reduce and display a lower lux level?

I have OCD so the 38571 compared to my other sensors is freaking me out :wink:
Thanks

It’s possible.

Great stuff, now i just need to figure out how…half way through my fishing book :wink:

Think about what the expression/variable is doing for you in the dimmer solution… :slight_smile:

Oh, and remember that getstate() returns a string, so you have to use tonumber() to convert it to a number first if you’re going to do math with it.

1 Like

Ok so I have created my virtual sensor and currently it displays the same lux as the actual device
image
I have created a reactor sensor


and divided the result by 1000
But I can’t seem to push this new value ie 0.231 back to the virtual sensor
a handy clue would be helpful…please

Cracked it like this…I think

So I think this is correct I just need to figure how to remove the decimal places :wink:

There’s a round() function that takes a number and a number of decimal places (e.g. round(1.25,0) will give you 1, where round(1.25,1) yields 1.3)

Ah OK so a bit like excel, thanks

Yes, it’s a bit of a blend of Excel, Lua, and C/C++/Java/JavaScript family. See also:

https://www.toggledbits.com/static/reactor/docs/Expressions-%26-Variables/

1 Like

Sorry but the round will that go in expressions or activities

Yes! :slight_smile: . . .

Both? :wink:
Thanks

Either. Where would it make most sense to you? I would choose the expressions, because then you see the actual result being assigned to the sensor in the Status view of the ReactorSensor.

ok thanks, struggling on then :wink:

ok I’m giving up for tonight ;-(
I have tried round in just about every combination I can think of…but obviously not the right one as I still cant get this to work
just one of many attempts

Please post logic summaries rather than screen shots. This gives us a better picture of everything in the ReactorSensor.

Thank you

*************************************************** REACTOR LOGIC SUMMARY REPORT ***************************************************
   Version: 3.7-20190 config 20190 cdata 20045 ui 20190 pluginDevice 526 LuaXP 1.0.2enh
    System: Vera version 1.7.4970 (7.31) on Sercomm G450 ID 36 (Vera Plus); loadtime 1599159991/1599160005; systemReady 1599160010
       Env: Lua 5.1; JSON dkjson 2.5+LPeg; UnsafeLua=nil/true
Local time: 2020-09-03T20:46:01+0100; DST=1; Leicester, England United Kingdom; formats %d/%m/%Y %H:%M:%S
House mode: plugin 1; system 1; tracking off
  Sun data: {"source":"int","civdawn":1599108215,"nautdawn":1599105592,"sunset":1599158927,"nautdusk":1599163689,"stamp":2020247,"latitude":52.6386,"astrodusk":1599166590,"longitude":-1.13169,"civdusk":1599161066,"astrodawn":1599102691,"sunrise":1599110354}
  Geofence: not running
        RS: 1599081446,1599081473,1599084441,1599142689,1599152814,1599152958,1599153091,1599156384,1599159832,1599160005
        NS: 0:X,1590927660:U,1591331580:D,1591331645:U
************************************************************************************************************************************
Lux hue (#603)
    Version 20045.64 09/03/20 20:12:21
    Message/status: Not tripped
    Variable/expressions
       0: getstate                 getstate( 589, "urn:micasaverde-com:serviceId:LightSensor1", "CurrentLevel" )/1000 [last 0.231(number)]
    Condition group "Reactor Sensor 18" (AND)  false as of 20:36:09 <root>
      &-F-var getstate change  [0 => 0.231 at 20:36:09; F/F as of 20:36:09/20:36:09] <cond0>
    Activity root.true
        Device Virtual LightSensor 1 (607) action urn:toggledbits-com:serviceId:VirtualSensor1/SetValue( newValue="{getstate}" )
    Events
        2020-09-03 20:16:09: Group Reactor Sensor 18 test state changed from false to true
        2020-09-03 20:16:09: Group Reactor Sensor 18 evaluation state changed from false to true
        2020-09-03 20:16:09: Preparing Reactor Sensor 18.true (root.true) activity
        2020-09-03 20:16:09: Launching scene/activity root.true
        2020-09-03 20:16:09: Starting "root.true" group 1
        2020-09-03 20:16:09: Activity "root.true" finished
        2020-09-03 20:16:09: Stopping activity "root.true"
        2020-09-03 20:16:09: Changing RS tripped state to true
        2020-09-03 20:16:09: Sensor update completed; 0.041s
        2020-09-03 20:16:09: Sensor update starting
        2020-09-03 20:16:09: Condition cond0 test state changed from true to false
        2020-09-03 20:16:09: Condition cond0 evaluation state changed from true to false
        2020-09-03 20:16:09: Group Reactor Sensor 18 test state changed from true to false
        2020-09-03 20:16:09: Group Reactor Sensor 18 evaluation state changed from true to false
        2020-09-03 20:16:09: Changing RS tripped state to false
        2020-09-03 20:16:09: Sensor update completed; 0.021s
        2020-09-03 20:21:09: Device Hue Hue outdoor light sensor 1 (#589) urn:micasaverde-com:serviceId:LightSensor1/CurrentLevel changed from "8013" to "5002"
        2020-09-03 20:21:09: Sensor update starting
        2020-09-03 20:21:09: Variable getstate value changed from "8.013" to "5.002"
        2020-09-03 20:21:09: Condition cond0 test state changed from false to true
        2020-09-03 20:21:09: Condition cond0 evaluation state changed from false to true
        2020-09-03 20:21:09: Group Reactor Sensor 18 test state changed from false to true
        2020-09-03 20:21:09: Group Reactor Sensor 18 evaluation state changed from false to true
        2020-09-03 20:21:09: Preparing Reactor Sensor 18.true (root.true) activity
        2020-09-03 20:21:09: Launching scene/activity root.true
        2020-09-03 20:21:09: Starting "root.true" group 1
        2020-09-03 20:21:09: Activity "root.true" finished
        2020-09-03 20:21:09: Stopping activity "root.true"
        2020-09-03 20:21:09: Changing RS tripped state to true
        2020-09-03 20:21:09: Sensor update completed; 0.035s
        2020-09-03 20:21:09: Sensor update starting
        2020-09-03 20:21:09: Condition cond0 test state changed from true to false
        2020-09-03 20:21:09: Condition cond0 evaluation state changed from true to false
        2020-09-03 20:21:09: Group Reactor Sensor 18 test state changed from true to false
        2020-09-03 20:21:09: Group Reactor Sensor 18 evaluation state changed from true to false
        2020-09-03 20:21:09: Changing RS tripped state to false
        2020-09-03 20:21:09: Sensor update completed; 0.022s
        2020-09-03 20:26:09: Device Hue Hue outdoor light sensor 1 (#589) urn:micasaverde-com:serviceId:LightSensor1/CurrentLevel changed from "5002" to "231"
        2020-09-03 20:26:09: Sensor update starting
        2020-09-03 20:26:09: Variable getstate value changed from "5.002" to "0.231"
        2020-09-03 20:26:09: Condition cond0 test state changed from false to true
        2020-09-03 20:26:09: Condition cond0 evaluation state changed from false to true
        2020-09-03 20:26:09: Group Reactor Sensor 18 test state changed from false to true
        2020-09-03 20:26:09: Group Reactor Sensor 18 evaluation state changed from false to true
        2020-09-03 20:26:09: Preparing Reactor Sensor 18.true (root.true) activity
        2020-09-03 20:26:09: Launching scene/activity root.true
        2020-09-03 20:26:09: Starting "root.true" group 1
        2020-09-03 20:26:09: Activity "root.true" finished
        2020-09-03 20:26:09: Stopping activity "root.true"
        2020-09-03 20:26:09: Changing RS tripped state to true
        2020-09-03 20:26:09: Sensor update completed; 0.034s
        2020-09-03 20:26:09: Sensor update starting
        2020-09-03 20:26:09: Condition cond0 test state changed from true to false
        2020-09-03 20:26:09: Condition cond0 evaluation state changed from true to false
        2020-09-03 20:26:09: Group Reactor Sensor 18 test state changed from true to false
        2020-09-03 20:26:09: Group Reactor Sensor 18 evaluation state changed from true to false
        2020-09-03 20:26:09: Changing RS tripped state to false
        2020-09-03 20:26:09: Sensor update completed; 0.023s
        2020-09-03 20:31:09: Device Hue Hue outdoor light sensor 1 (#589) urn:micasaverde-com:serviceId:LightSensor1/CurrentLevel changed from "231" to "0"
        2020-09-03 20:31:09: Sensor update starting
        2020-09-03 20:31:09: Variable getstate value changed from "0.231" to "0"
        2020-09-03 20:31:09: Condition cond0 test state changed from false to true
        2020-09-03 20:31:09: Condition cond0 evaluation state changed from false to true
        2020-09-03 20:31:09: Group Reactor Sensor 18 test state changed from false to true
        2020-09-03 20:31:09: Group Reactor Sensor 18 evaluation state changed from false to true
        2020-09-03 20:31:09: Preparing Reactor Sensor 18.true (root.true) activity
        2020-09-03 20:31:09: Launching scene/activity root.true
        2020-09-03 20:31:09: Starting "root.true" group 1
        2020-09-03 20:31:09: Activity "root.true" finished
        2020-09-03 20:31:09: Stopping activity "root.true"
        2020-09-03 20:31:09: Changing RS tripped state to true
        2020-09-03 20:31:09: Sensor update completed; 0.046s
        2020-09-03 20:31:09: Sensor update starting
        2020-09-03 20:31:09: Condition cond0 test state changed from true to false
        2020-09-03 20:31:09: Condition cond0 evaluation state changed from true to false
        2020-09-03 20:31:09: Group Reactor Sensor 18 test state changed from true to false
        2020-09-03 20:31:09: Group Reactor Sensor 18 evaluation state changed from true to false
        2020-09-03 20:31:09: Changing RS tripped state to false
        2020-09-03 20:31:09: Sensor update completed; 0.020s
        2020-09-03 20:36:09: Device Hue Hue outdoor light sensor 1 (#589) urn:micasaverde-com:serviceId:LightSensor1/CurrentLevel changed from "0" to "231"
        2020-09-03 20:36:09: Sensor update starting
        2020-09-03 20:36:09: Variable getstate value changed from "0" to "0.231"
        2020-09-03 20:36:09: Condition cond0 test state changed from false to true
        2020-09-03 20:36:09: Condition cond0 evaluation state changed from false to true
        2020-09-03 20:36:09: Group Reactor Sensor 18 test state changed from false to true
        2020-09-03 20:36:09: Group Reactor Sensor 18 evaluation state changed from false to true
        2020-09-03 20:36:09: Preparing Reactor Sensor 18.true (root.true) activity
        2020-09-03 20:36:09: Launching scene/activity root.true
        2020-09-03 20:36:09: Starting "root.true" group 1
        2020-09-03 20:36:09: Activity "root.true" finished
        2020-09-03 20:36:09: Stopping activity "root.true"
        2020-09-03 20:36:09: Changing RS tripped state to true
        2020-09-03 20:36:09: Sensor update completed; 0.034s
        2020-09-03 20:36:09: Sensor update starting
        2020-09-03 20:36:09: Condition cond0 test state changed from true to false
        2020-09-03 20:36:09: Condition cond0 evaluation state changed from true to false
        2020-09-03 20:36:09: Group Reactor Sensor 18 test state changed from true to false
        2020-09-03 20:36:09: Group Reactor Sensor 18 evaluation state changed from true to false
        2020-09-03 20:36:09: Changing RS tripped state to false
        2020-09-03 20:36:09: Sensor update completed; 0.025s
    Devices
        Virtual Sensor (571) urn:schemas-toggledbits-com:device:VirtualSensor:1 (4/1); parent 0; plugin 9031; mfg  model ; dev D_VirtualSensor1.xml impl I_VirtualSensor1.xml
        Virtual LightSensor 1 (607) urn:schemas-micasaverde-com:device:LightSensor:1 (18/0); parent 571; plugin -; mfg  model ; dev D_LightSensor1.xml impl 
    Watches
        Device #603 Lux hue service urn:toggledbits-com:serviceId:ReactorSensor variable cdata
        Device #607 Virtual LightSensor 1 service urn:micasaverde-com:serviceId:LightSensor1 variable round :CurrentLevel
        Device #603 Lux hue service urn:toggledbits-com:serviceId:ReactorSensor variable TestTime
        Device #589 Hue Hue outdoor light sensor 1 service urn:micasaverde-com:serviceId:LightSensor1 variable round :CurrentLevel
        Device #589 Hue Hue outdoor light sensor 1 service urn:micasaverde-com:serviceId:LightSensor1 variable CurrentLevel
        Device #603 Lux hue service urn:toggledbits-com:serviceId:ReactorSensor variable TestHouseMode

To round to two digits:

round( getstate( 589, "urn:micasaverde-com:serviceId:LightSensor1", "CurrentLevel" )/1000, 2 )
1 Like

OMG so simple, I was putting in the brackets, behind the brackets, never thought to put it in front of everything!!
Thank you sorry to have wasted so much of your time on such a simple thing
Thanks

1 Like

Ok so the formulas are all correct now thanks to rigpapa and the virtual sensor is showing the correct reading but every 5 mins it seems to revert back to the old reading ie 33333 instead of 333 , so I tried to put a interval in the condition of 1 minute into the condition but when I do that it doesnt update

*************************************************** REACTOR LOGIC SUMMARY REPORT ***************************************************
   Version: 3.7-20190 config 20190 cdata 20045 ui 20190 pluginDevice 526 LuaXP 1.0.2enh
    System: Vera version 1.7.4970 (7.31) on Sercomm G450 ID 36 (Vera Plus); loadtime 1599223792/1599223806; systemReady 1599223811
       Env: Lua 5.1; JSON dkjson 2.5+LPeg; UnsafeLua=nil/true
Local time: 2020-09-04T14:25:18+0100; DST=1; Leicester, England United Kingdom; formats %d/%m/%Y %H:%M:%S
House mode: plugin 1; system 1; tracking off
  Sun data: {"source":"int","civdawn":1599194722,"nautdawn":1599192113,"sunset":1599245187,"nautdusk":1599249927,"stamp":2020248,"latitude":52.6386,"astrodusk":1599252802,"longitude":-1.13169,"civdusk":1599247319,"astrodawn":1599189239,"sunrise":1599196854}
  Geofence: not running
        RS: 1599156384,1599159832,1599160005,1599201422,1599216696,1599216892,1599217244,1599220566,1599220595,1599223806
        NS: 0:X,1590927660:U,1591331580:D,1591331645:U
************************************************************************************************************************************
Lux hue (#603)
    Version 20045.80 09/04/20 13:49:01
    Message/status: Not tripped
    Variable/expressions
       0: getstate                 round(getstate( 589, "urn:micasaverde-com:serviceId:LightSensor1", "CurrentLevel" )/100) [last 334(number)]
    Condition group "Reactor Sensor 18" (AND)  false as of 13:46:46 <root>
      &-F-var getstate change  [316 => 334 at 14:21:45; F/F as of 14:21:45/14:21:45] <cond0>
      &-F-interval 00h:01m [1599225840 => 1599225900 at 14:25:00; F/F as of 14:25:00/14:25:00] <condw4fynxm>
    Activity root.true
        Device Virtual LightSensor 1 (607) action urn:toggledbits-com:serviceId:VirtualSensor1/SetValue( newValue="{getstate}" )
    Events
        2020-09-04 14:16:00: Sensor update starting
        2020-09-04 14:16:00: Condition condw4fynxm test state changed from false to true
        2020-09-04 14:16:00: Condition condw4fynxm evaluation state changed from false to true
        2020-09-04 14:16:00: Sensor update completed; 0.016s
        2020-09-04 14:16:02: Sensor update starting
        2020-09-04 14:16:02: Condition condw4fynxm test state changed from true to false
        2020-09-04 14:16:02: Condition condw4fynxm evaluation state changed from true to false
        2020-09-04 14:16:02: Sensor update completed; 0.016s
        2020-09-04 14:16:45: Device Hue Hue outdoor light sensor 1 (#589) urn:micasaverde-com:serviceId:LightSensor1/CurrentLevel changed from "31907" to "31573"
        2020-09-04 14:16:45: Sensor update starting
        2020-09-04 14:16:45: Variable getstate value changed from "319" to "316"
        2020-09-04 14:16:45: Condition cond0 test state changed from false to true
        2020-09-04 14:16:45: Condition cond0 evaluation state changed from false to true
        2020-09-04 14:16:45: Sensor update completed; 0.017s
        2020-09-04 14:16:45: Sensor update starting
        2020-09-04 14:16:45: Condition cond0 test state changed from true to false
        2020-09-04 14:16:45: Condition cond0 evaluation state changed from true to false
        2020-09-04 14:16:45: Sensor update completed; 0.018s
        2020-09-04 14:17:00: Sensor update starting
        2020-09-04 14:17:00: Condition condw4fynxm test state changed from false to true
        2020-09-04 14:17:00: Condition condw4fynxm evaluation state changed from false to true
        2020-09-04 14:17:00: Sensor update completed; 0.024s
        2020-09-04 14:17:00: Sensor update starting
        2020-09-04 14:17:00: Condition condw4fynxm test state changed from true to false
        2020-09-04 14:17:00: Condition condw4fynxm evaluation state changed from true to false
        2020-09-04 14:17:00: Sensor update completed; 0.021s
        2020-09-04 14:18:00: Sensor update starting
        2020-09-04 14:18:00: Condition condw4fynxm test state changed from false to true
        2020-09-04 14:18:00: Condition condw4fynxm evaluation state changed from false to true
        2020-09-04 14:18:00: Sensor update completed; 0.028s
        2020-09-04 14:18:00: Sensor update starting
        2020-09-04 14:18:00: Condition condw4fynxm test state changed from true to false
        2020-09-04 14:18:00: Condition condw4fynxm evaluation state changed from true to false
        2020-09-04 14:18:00: Sensor update completed; 0.030s
        2020-09-04 14:19:00: Sensor update starting
        2020-09-04 14:19:00: Condition condw4fynxm test state changed from false to true
        2020-09-04 14:19:00: Condition condw4fynxm evaluation state changed from false to true
        2020-09-04 14:19:00: Sensor update completed; 0.024s
        2020-09-04 14:19:00: Sensor update starting
        2020-09-04 14:19:00: Condition condw4fynxm test state changed from true to false
        2020-09-04 14:19:00: Condition condw4fynxm evaluation state changed from true to false
        2020-09-04 14:19:00: Sensor update completed; 0.015s
        2020-09-04 14:20:00: Sensor update starting
        2020-09-04 14:20:00: Condition condw4fynxm test state changed from false to true
        2020-09-04 14:20:00: Condition condw4fynxm evaluation state changed from false to true
        2020-09-04 14:20:00: Sensor update completed; 0.014s
        2020-09-04 14:20:00: Sensor update starting
        2020-09-04 14:20:00: Condition condw4fynxm test state changed from true to false
        2020-09-04 14:20:00: Condition condw4fynxm evaluation state changed from true to false
        2020-09-04 14:20:00: Sensor update completed; 0.013s
        2020-09-04 14:21:00: Sensor update starting
        2020-09-04 14:21:00: Condition condw4fynxm test state changed from false to true
        2020-09-04 14:21:00: Condition condw4fynxm evaluation state changed from false to true
        2020-09-04 14:21:00: Sensor update completed; 0.024s
        2020-09-04 14:21:02: Sensor update starting
        2020-09-04 14:21:02: Condition condw4fynxm test state changed from true to false
        2020-09-04 14:21:02: Condition condw4fynxm evaluation state changed from true to false
        2020-09-04 14:21:02: Sensor update completed; 0.016s
        2020-09-04 14:21:45: Device Hue Hue outdoor light sensor 1 (#589) urn:micasaverde-com:serviceId:LightSensor1/CurrentLevel changed from "31573" to "33435"
        2020-09-04 14:21:45: Sensor update starting
        2020-09-04 14:21:45: Variable getstate value changed from "316" to "334"
        2020-09-04 14:21:45: Condition cond0 test state changed from false to true
        2020-09-04 14:21:45: Condition cond0 evaluation state changed from false to true
        2020-09-04 14:21:45: Sensor update completed; 0.015s
        2020-09-04 14:21:45: Sensor update starting
        2020-09-04 14:21:45: Condition cond0 test state changed from true to false
        2020-09-04 14:21:45: Condition cond0 evaluation state changed from true to false
        2020-09-04 14:21:45: Sensor update completed; 0.018s
        2020-09-04 14:22:00: Sensor update starting
        2020-09-04 14:22:00: Condition condw4fynxm test state changed from false to true
        2020-09-04 14:22:00: Condition condw4fynxm evaluation state changed from false to true
        2020-09-04 14:22:00: Sensor update completed; 0.014s
        2020-09-04 14:22:00: Sensor update starting
        2020-09-04 14:22:00: Condition condw4fynxm test state changed from true to false
        2020-09-04 14:22:00: Condition condw4fynxm evaluation state changed from true to false
        2020-09-04 14:22:00: Sensor update completed; 0.013s
        2020-09-04 14:23:00: Sensor update starting
        2020-09-04 14:23:00: Condition condw4fynxm test state changed from false to true
        2020-09-04 14:23:00: Condition condw4fynxm evaluation state changed from false to true
        2020-09-04 14:23:00: Sensor update completed; 0.036s
        2020-09-04 14:23:00: Sensor update starting
        2020-09-04 14:23:00: Condition condw4fynxm test state changed from true to false
        2020-09-04 14:23:00: Condition condw4fynxm evaluation state changed from true to false
        2020-09-04 14:23:00: Sensor update completed; 0.014s
        2020-09-04 14:24:00: Sensor update starting
        2020-09-04 14:24:00: Condition condw4fynxm test state changed from false to true
        2020-09-04 14:24:00: Condition condw4fynxm evaluation state changed from false to true
        2020-09-04 14:24:00: Sensor update completed; 0.035s
        2020-09-04 14:24:00: Sensor update starting
        2020-09-04 14:24:00: Condition condw4fynxm test state changed from true to false
        2020-09-04 14:24:00: Condition condw4fynxm evaluation state changed from true to false
        2020-09-04 14:24:00: Sensor update completed; 0.013s
        2020-09-04 14:25:00: Sensor update starting
        2020-09-04 14:25:00: Condition condw4fynxm test state changed from false to true
        2020-09-04 14:25:00: Condition condw4fynxm evaluation state changed from false to true
        2020-09-04 14:25:00: Sensor update completed; 0.035s
        2020-09-04 14:25:00: Sensor update starting
        2020-09-04 14:25:00: Condition condw4fynxm test state changed from true to false
        2020-09-04 14:25:00: Condition condw4fynxm evaluation state changed from true to false
        2020-09-04 14:25:00: Sensor update completed; 0.013s
    Devices
        Virtual Sensor (571) urn:schemas-toggledbits-com:device:VirtualSensor:1 (4/1); parent 0; plugin 9031; mfg  model ; dev D_VirtualSensor1.xml impl I_VirtualSensor1.xml
        Virtual LightSensor 1 (607) urn:schemas-micasaverde-com:device:LightSensor:1 (18/0); parent 571; plugin -; mfg  model ; dev D_LightSensor1.xml impl 
    Watches
        Device #603 Lux hue service urn:toggledbits-com:serviceId:ReactorSensor variable cdata
        Device #603 Lux hue service urn:toggledbits-com:serviceId:ReactorSensor variable TestTime
        Device #589 Hue Hue outdoor light sensor 1 service urn:micasaverde-com:serviceId:LightSensor1 variable CurrentLevel
        Device #603 Lux hue service urn:toggledbits-com:serviceId:ReactorSensor variable TestHouseMode

Any help finally putting this to bed would be appreciated, thanks