hardware is a wemos D1 mini with a relay shield where the relay switches a babyphone behind. release used is ESP_Easy_mega_20201102_normal_ESP8266_4M1M
I am using the webgui.esp and calculate there the last switch, and out of it the sleeping time.
now there seems to be an issue with the #F formatting (see line Let,5,[INT#4#F] ): it does not round down, it rounds above .5 up. this leads to negative minutes.
rules:
Code: Select all
on System#Boot do
GPIO,5,0
Monitor,GPIO,5
endon
on Clock#Time=All,**:** do
TaskValueSet,2,1,%syshour_0%
TaskValueSet,2,2,%sysmin_0%
event,calcsleeptime
endon
on GPIO#5 do
TaskValueSet,2,3,%syshour_0%
TaskValueSet,2,4,%sysmin_0%
event,calcsleeptime
endon
on calcsleeptime do
if [Babyphone#State] = 1
Let,1,(([Time#Hour]*60)+[Time#Min])
Let,2,(([Time#HourSw]*60)+[Time#MinSw])
Let,3,([INT#1]-[INT#2])
Let,4,([INT#3]/60)
Let,5,[INT#4#F]
Let,6,(([VAR#4]-[INT#5])*60)
else
Let,5,0
Let,6,0
endif
endon
Code: Select all
129687402: EVENT: calcsleeptime
129687428: ACT : Let,1,((8*60)+31)
129687434: ACT : Let,2,((7*60)+59)
129687438: ACT : Let,3,(511-479)
129687442: ACT : Let,4,(32/60)
129687446: ACT : Let,5,1
129687449: ACT : Let,6,((0.53-1)*60)
webgui.esp:
Code: Select all
<!DOCTYPE html>
<html><head>
<meta http-equiv="refresh" content="30; URL=http://192.168.10.127/webgui.esp">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.circle {width:100px; height:60px;border-radius:50%;display: inline-flex;cursor:pointer;color:white;font-size:90%;font-weight:bold;align-items:center;justify-content:center;}
a {text-decoration: none;color:white;}
table {vertical-align:middle;font-size:220%;font-weight:bold;}
.c0 {background-color:red;}
.c1 {background-color:green;}
p { cursor:text; }
.no-link {color:black;text-decoration:underline;}
</style><title>Babyphone</title></head><body>
<br><br><table align="center">
<tr><td>Babyphone Status:</td><td> </td>
<td align="center"><div class="circle c[Babyphone#State]"><a class="circle link" href="webgui.esp?cmd=GPIOtoggle,5">[Babyphone#State]</a></div></td></tr>
<tr><td>zuletzt geschaltet:</td><td> </td><td align="center">[Time#HourSw#D2]:[Time#MinSw#D2]</td></tr>
<tr><td align="center">zuletzt aktualisiert:</td><td> </td><td align="center">[Time#Hour#D2]:[Time#Min#D2]</td></tr>
<tr><td align="center">schläft seit:</td><td> </td><td align="center">[INT#5]:[INT#6#D2]</td></tr>
<tr><td colspan="3" align="center"><a class="no-link" href="webgui.esp">Aktualisieren</a></td></tr>
</table>
* Dummdevice not filled any more - found out that it does not like the "Time" as Name for the Dummydevice
* %syshour_0% not working any more (leads always to 0)
* requesting the webgui.esp leads to reboots (Software-watchdog as reason - in log I can see it tries to do bitwise stuff most probably caused by the brackets in the webgui.esp ? )
Any ideas how to get rid of the failing #F formatting to calculate the time correctly?
Thanks!
BR
Alois