Help with Date Comparison

17 views
Skip to first unread message

Shanmukha B

unread,
Nov 15, 2022, 4:54:13 AM11/15/22
to TasmotaUsers
Hi Guys ,
                I have sonoff pow r2 devices and im currently using the below rules to get back my energy consumption value before power supply is gone . 

rule1 ON Power1#Boot DO rule3 0 ENDON ON Time#Initialized DO backlog EnergyToday %mem1% ;RuleTimer1 900 ENDON ON Rules#Timer=1 DO Rule3 1 ENDON

rule3 ON ENERGY#Today DO Backlog var3 %value%; MULT3 1000; Event save ENDON ON Event#save DO Backlog Rule3 0;mem1 %var3%;RuleTimer1 900 ENDON

Above rules will save the energytoday value for every 15 min  in mem1 and if the device gets restarted then energytoday will get replaced by previously stored value in mem1

But the above rule will give wrong results in some situations . For Example .if power supply goes at 2pm and if the energytoday value is 10 kWh . power supply came back again at next day 6am then energytoday will get the value of 10kWh but thats wrong right?

so if we can able to compare the date then it would be great 

we have timestamp command but to compare that timestamp in rules we don't have any options for that 

Philip Knowles

unread,
Nov 15, 2022, 6:43:08 AM11/15/22
to Shanmukha B, TasmotaUsers

You could do it with scripts but, really, this is better done in a control system – apart from anything else writing to mem1 nearly 100 times a day will shorten the life of the flash memory...

 

 

Sent from Mail for Windows

--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/754f85fa-9485-4ee2-bab6-395a68c46363n%40googlegroups.com.

 

Shanmukha B

unread,
Nov 15, 2022, 7:04:37 AM11/15/22
to TasmotaUsers
Regarding mem1 writing i will reduce it eventually .

Is there any way to extract Date from Timestamp, or String comparison commands

Regards 
Shanmukha

Philip Knowles

unread,
Nov 15, 2022, 7:36:10 AM11/15/22
to Shanmukha B, TasmotaUsers

In scripts, yes, but not otherwise.

Shanmukha B

unread,
Nov 15, 2022, 10:58:05 PM11/15/22
to TasmotaUsers
Thanks , I will check that out 


Regards 
Shanmukha
Reply all
Reply to author
Forward
0 new messages