i have the following working rules..
Is that ok from a performance point of view, or can I simplify it too?
Rule 1:
Code: Select all
on System#Boot do
timerSet,1,1 // Init Display after 1 Seconds
lcdcmd,off
pwm,5,20
Let 1,20
endon
on Rules#Timer=1 do // Wait until MQTT is connected
lcdcmd,on
lcd,1,1,Waiting...
lcd,2,1,Waiting...
endon
on MQTT#Connected do // Start Display wrap around
timerSet,2,3
notify 1
endon
on MQTT#Disconnected do // Reset Display when ESP are disconnected ..
timerSet,2,0
timerSet,3,0
timerSet,4,0
timerSet,5,0
timerSet,6,0
notify 1
lcd,1,1,'MQTT disconnect!'
lcd,2,1,'be cool .. '
endon
on Rules#Timer=2 do
lcd,1,1,'Wind [MQTT_IMPORT1#ws] km/h x'
lcd,2,1,'%sysweekday_s% %sysday%-%sysmonth%-%sysyear% x'
timerSet,3,3
endon
on Rules#Timer=3 do
lcd,1,1,'Out T:[MQTT_IMPORT1#out_temp] H:[MQTT_IMPORT1#out_hum] x'
lcd,2,1,'In T:[T&H#in_temp] H:[T&H#in_hum#D2.0] x'
timerSet,4,3
endon
on Rules#Timer=4 do
lcd,1,1,'Rain [MQTT_IMPORT1#Raintoday] l/qm x '
lcd,2,1,'CO2 [CO2#CO2] ppm x'
timerSet,5,3
endon
on Rules#Timer=5 do
lcd,1,1,'APS-A [MQTT_IMPORT2#Pressure] hPA x'
lcd,2,1,'Time %systime% x'
timerSet,6,3
endon
on Rules#Timer=6 do
if [MQTT_IMPORT2#Tendency] > 0
lcd,1,1,'APS-T +[MQTT_IMPORT2#Tendency] (3h) x'
else
lcd,1,1,'APS-T [MQTT_IMPORT2#Tendency] (3h) x'
endif
lcd,2,1,'SR %sunrise% SS %sunset% '
timerSet,2,3
endon
Rule2: (gpio 5 controls the brightness of the lcd display via a light dependent resisitor)
Code: Select all
on LDR#Light do
If [LDR#Light] >0 and [LDR#Light] <20 and [VAR#1] != 1
pwm,5,1,3000
Let 1,1
endif
If [LDR#Light] >20 and [LDR#Light] <100 and [VAR#1] != 5
pwm,5,5,3000
Let 1,5
endif
If [LDR#Light] >100 and [LDR#Light] <550 and [VAR#1] != 10
pwm,5,10,3000
Let 1,10
endif
If [LDR#Light] >550 and [LDR#Light] <650 and [VAR#1] != 20
pwm,5,20,3000
Let 1,20
endif
If [LDR#Light] >650 and [LDR#Light] <750 and [VAR#1] != 40
pwm,5,40,3000
Let 1,40
endif
If [LDR#Light] >750 and [LDR#Light] <900 and [VAR#1] != 50
pwm,5,50,3000
Let 1,50
endif
If [LDR#Light] >900 and [LDR#Light] <1010 and [VAR#1] != 100
pwm,5,100,3000
Let 1,100
endif
If [LDR#Light] >=1010 and [VAR#1] != 800
pwm,5,800,3000
Let 1,800
endif
endon
on Clock#Time=All,**:00 do //**:** ==> jede Minute **:00 ==> jede Stunde
If %systime% > 05:00:00 and %systime% < 23:00:00
rtttl,4:d=1000,o=8,b=6,c,,,,,,,,c
Endif
endon