@novitibo It works with a very basic trigger:
ON POWER1#state=0 DO Var1 %timestamp% ENDON
and in the console I then see
14:43:34 RUL: POWER1#STATE=0 performs "Var1 2019-10-21T14:43:34"
14:43:34 MQT: stat/sonoff33/RESULT = {"Var1":"2019-10-21T14:43:34"}
So I moved on and have now developed this:
`
ON POWER1#state=1 DO Var2 %timestamp% ENDON
ON POWER1#state=0 DO Var1 %timestamp% ENDON
ON Rules#Timer=1 DO Var1 ENDON
ON Rules#Timer=1 DO Var2 ENDON
`
NOTE1 Above is all ‘appended’ to become one rule
NOTE2: This is just testing on a movement sensor I have which is good because its outside and the wind is turning it on and off atm…very handy!
NOTE3: I use the ruletimer as a trigger so I can manually trigger it by inputting:
ruletime 3 at the console…then that just quickly counts down to ‘1’
Sonoff Web Console output:
PS: Dont be confused by the other output sending EVENT’s to sonnoff13…just look for the Var1 and Var2 output
17:18:22 MQT: stat/sonoff33/POWER1 = ON
17:18:22 RUL: POWER1#STATE=1 performs "backlog publish cmnd/sonoff13/Event Movement_Patio"
17:18:22 RUL: POWER1#STATE=1 performs "Var2 2019-10-21T17:18:22"
17:18:22 MQT: stat/sonoff33/RESULT = {"Var2":"2019-10-21T17:18:22"}
17:18:22 MQT: cmnd/sonoff13/Event = Movement_Patio
17:18:24 MQT: stat/sonoff33/RESULT = {"POWER1":"OFF"}
17:18:24 MQT: stat/sonoff33/POWER1 = OFF
17:18:25 RUL: POWER1#STATE=0 performs "Var1 2019-10-21T17:18:25"
17:18:25 MQT: stat/sonoff33/RESULT = {"Var1":"2019-10-21T17:18:25"}
17:18:46 MQT: stat/sonoff33/RESULT = {"POWER1":"ON"}
17:18:46 MQT: stat/sonoff33/POWER1 = ON
17:18:46 RUL: POWER1#STATE=1 performs "backlog publish cmnd/sonoff13/Event Movement_Patio"
17:18:46 RUL: POWER1#STATE=1 performs "Var2 2019-10-21T17:18:46"
17:18:46 MQT: stat/sonoff33/RESULT = {"Var2":"2019-10-21T17:18:46"}
17:18:46 MQT: cmnd/sonoff13/Event = Movement_Patio
17:18:48 MQT: stat/sonoff33/RESULT = {"POWER1":"OFF"}
17:18:48 MQT: stat/sonoff33/POWER1 = OFF
17:18:48 RUL: POWER1#STATE=0 performs "Var1 2019-10-21T17:18:48"
17:18:48 MQT: stat/sonoff33/RESULT = {"Var1":"2019-10-21T17:18:48"}
17:19:19 RSL: tele/sonoff33/STATE = {"Time":"2019-10-21T17:19:19","Uptime":"7T02:20:30","Vcc":3.462,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"POWER1":"OFF","POWER2":"OFF","POWER3":"OFF","POWER4":"OFF","POWER5":"OFF","Wifi":{"AP":1,"SSId":"Bugwire","BSSId":"E0:3F:49:72:B8:E0","Channel":6,"RSSI":92,"LinkCount":10,"Downtime":"0T00:00:35"}}
17:19:19 MQT: tele/sonoff33/SENSOR = {"Time":"2019-10-21T17:19:19","Switch1":"OFF","Switch5":"OFF"}17:34:00 MQT: stat/sonoff33/RESULT = {"Var2":"2019-10-21T17:34:00"}
17:34:00 MQT: cmnd/sonoff13/Event = Movement_Patio
17:34:02 MQT: stat/sonoff33/RESULT = {"POWER1":"OFF"}
17:34:02 MQT: stat/sonoff33/POWER1 = OFF
17:34:02 RUL: POWER1#STATE=0 performs "Var1 2019-10-21T17:34:02"
17:34:02 MQT: stat/sonoff33/RESULT = {"Var1":"2019-10-21T17:34:02"}
17:34:19 RSL: tele/sonoff33/STATE = {"Time":"2019-10-21T17:34:19","Uptime":"7T02:35:30","Vcc":3.462,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"POWER1":"OFF","POWER2":"OFF","POWER3":"OFF","POWER4":"OFF","POWER5":"OFF","Wifi":{"AP":1,"SSId":"Bugwire","BSSId":"E0:3F:49:72:B8:E0","Channel":6,"RSSI":100,"LinkCount":10,"Downtime":"0T00:00:35"}}
17:34:19 MQT: tele/sonoff33/SENSOR = {"Time":"2019-10-21T17:34:19","Switch1":"OFF","Switch5":"OFF"}
17:35:30 MQT: stat/sonoff33/RESULT = {"POWER1":"ON"}
17:35:30 MQT: stat/sonoff33/POWER1 = ON
17:35:30 RUL: POWER1#STATE=1 performs "backlog publish cmnd/sonoff13/Event Movement_Patio"
17:35:30 RUL: POWER1#STATE=1 performs "Var2 2019-10-21T17:35:30"
17:35:30 MQT: stat/sonoff33/RESULT = {"Var2":"2019-10-21T17:35:30"}
17:35:30 MQT: cmnd/sonoff13/Event = Movement_Patio
17:35:32 MQT: stat/sonoff33/RESULT = {"POWER1":"OFF"}
17:35:32 MQT: stat/sonoff33/POWER1 = OFF
17:35:32 RUL: POWER1#STATE=0 performs "Var1 2019-10-21T17:35:32"
17:35:32 MQT: stat/sonoff33/RESULT = {"Var1":"2019-10-21T17:35:32"}
17:39:19 RSL: tele/sonoff33/STATE = {"Time":"2019-10-21T17:39:19","Uptime":"7T02:40:30","Vcc":3.462,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"POWER1":"OFF","POWER2":"OFF","POWER3":"OFF","POWER4":"OFF","POWER5":"OFF","Wifi":{"AP":1,"SSId":"Bugwire","BSSId":"E0:3F:49:72:B8:E0","Channel":6,"RSSI":90,"LinkCount":10,"Downtime":"0T00:00:35"}}
17:39:19 MQT: tele/sonoff33/SENSOR = {"Time":"2019-10-21T17:39:19","Switch1":"OFF","Switch5":"OFF"}
17:39:22 MQT: stat/sonoff33/RESULT = {"POWER1":"ON"}
17:39:22 MQT: stat/sonoff33/POWER1 = ON
17:39:22 RUL: POWER1#STATE=1 performs "backlog publish cmnd/sonoff13/Event Movement_Patio"
17:39:22 RUL: POWER1#STATE=1 performs "Var2 2019-10-21T17:39:22"
17:39:22 MQT: stat/sonoff33/RESULT = {"Var2":"2019-10-21T17:39:22"}
17:39:23 MQT: cmnd/sonoff13/Event = Movement_Patio
17:39:25 MQT: stat/sonoff33/RESULT = {"POWER1":"OFF"}
17:39:25 MQT: stat/sonoff33/POWER1 = OFF
17:39:25 RUL: POWER1#STATE=0 performs "Var1 2019-10-21T17:39:25"
17:39:25 MQT: stat/sonoff33/RESULT = {"Var1":"2019-10-21T17:39:25"}
17:40:24 MQT: stat/sonoff33/RESULT = {"POWER1":"ON"}
17:40:24 MQT: stat/sonoff33/POWER1 = ON
17:40:24 RUL: POWER1#STATE=1 performs "backlog publish cmnd/sonoff13/Event Movement_Patio"
17:40:24 RUL: POWER1#STATE=1 performs "Var2 2019-10-21T17:40:24"
17:40:24 MQT: stat/sonoff33/RESULT = {"Var2":"2019-10-21T17:40:24"}
17:40:25 MQT: cmnd/sonoff13/Event = Movement_Patio
17:40:27 MQT: stat/sonoff33/RESULT = {"POWER1":"OFF"}
17:40:27 MQT: stat/sonoff33/POWER1 = OFF
17:40:27 RUL: POWER1#STATE=0 performs "Var1 2019-10-21T17:40:27"
17:40:27 MQT: stat/sonoff33/RESULT = {"Var1":"2019-10-21T17:40:27"}
17:40:38 MQT: stat/sonoff33/RESULT = {"POWER1":"ON"}
17:40:38 MQT: stat/sonoff33/POWER1 = ON
17:40:38 RUL: POWER1#STATE=1 performs "backlog publish cmnd/sonoff13/Event Movement_Patio"
17:40:38 RUL: POWER1#STATE=1 performs "Var2 2019-10-21T17:40:38"
17:40:38 MQT: stat/sonoff33/RESULT = {"Var2":"2019-10-21T17:40:38"}
17:40:38 MQT: cmnd/sonoff13/Event = Movement_Patio
17:40:40 MQT: stat/sonoff33/RESULT = {"POWER1":"OFF"}
17:40:40 MQT: stat/sonoff33/POWER1 = OFF
17:40:40 RUL: POWER1#STATE=0 performs "Var1 2019-10-21T17:40:40"
17:40:40 MQT: stat/sonoff33/RESULT = {"Var1":"2019-10-21T17:40:40"}
Triggering with ruletimer 3
08:32:28 CMD: ruletimer 3
08:32:28 MQT: stat/sonoff33/RESULT = {"T1":3,"T2":0,"T3":0,"T4":0,"T5":0,"T6":0,"T7":0,"T8":0}
08:32:31 RUL: RULES#TIMER=1 performs "Var1"
08:32:31 MQT: stat/sonoff33/RESULT = {"Var1":"2019-10-22T08:31:18"}
08:32:31 RUL: RULES#TIMER=1 performs "Var2"
08:32:31 MQT: stat/sonoff33/RESULT = {"Var2":"2019-10-22T08:31:15"}
Example misleading
I believe the example is misleading in how this must be written up as a rule.
I have worked on this since last night and just finally figured out how to do it a short while ago. Yeah…I’m a bit slow!
Have a go yourself and see if you can use this as I can see Var and Mem values being useful (Mem retains over a reboot) which is very handy I think.
Maths?
Also…it appears that maths is not possible BUT I HOPE I’M WRONG ABOUT THAT?