I need an automation to close my covers everyday when my lux sensor outside gives a value of <= 5 lux or at the maximum time of 22:30.
I have this automation created in Node-RED:
[{"id":"424560624253eb90","type":"tab","label":"Cover close","disabled":false,"info":"","env":[]},{"id":"7f5beb7ea980fbd6","type":"inject","z":"424560624253eb90","name":"Every day at 22:30","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"30 22 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":360,"wires":[["f12d5513ead28e53"]]},{"id":"87730bdc16333d21","type":"poll-state","z":"424560624253eb90","name":"'Zijraam' lux <= 5","server":"63f26c18.71f4f4","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"1","updateIntervalType":"num","updateIntervalUnits":"seconds","outputinitially":false,"outputonchanged":false,"entity_id":"sensor.zijraam_woonkamer_lux","state_type":"num","halt_if":"5","halt_if_type":"num","halt_if_compare":"lte","outputs":2,"x":120,"y":140,"wires":[[],[]]},{"id":"1d5adca0d40aa403","type":"server-state-changed","z":"424560624253eb90","name":"'Zijraam' lux <= 5","server":"63f26c18.71f4f4","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.zijraam_woonkamer_lux","entityidfiltertype":"exact","outputinitially":false,"state_type":"habool","haltifstate":"5","halt_if_type":"num","halt_if_compare":"lte","outputs":2,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":140,"y":300,"wires":[["f12d5513ead28e53"],[]]},{"id":"f12d5513ead28e53","type":"switch","z":"424560624253eb90","name":"Are the covers already closed by this automation?","property":"covers_are_closed","propertyType":"global","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":510,"y":320,"wires":[["af86c1158c42df32"],["d3e80ca09ba18180"]]},{"id":"1164530c3b420d1e","type":"inject","z":"424560624253eb90","name":"Every day at 15:00","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 15 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":540,"wires":[["db3b231efe5e61a6"]]},{"id":"db3b231efe5e61a6","type":"change","z":"424560624253eb90","name":"Reset global variable covers are closed","rules":[{"t":"set","p":"covers_are_closed","pt":"global","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":540,"wires":[[]]},{"id":"7b6f15afe3b93fe8","type":"debug","z":"424560624253eb90","name":"Close covers","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1170,"y":380,"wires":[]},{"id":"af86c1158c42df32","type":"debug","z":"424560624253eb90","name":"Covers are already closed","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":890,"y":280,"wires":[]},{"id":"d3e80ca09ba18180","type":"change","z":"424560624253eb90","name":"Set global variable covers are closed","rules":[{"t":"set","p":"covers_are_closed","pt":"global","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":380,"wires":[["7b6f15afe3b93fe8"]]},{"id":"c4d23ee7b48fc029","type":"comment","z":"424560624253eb90","name":"Poll every second","info":"","x":130,"y":100,"wires":[]},{"id":"63f26c18.71f4f4","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]
So I use a global variable which is set when the lux value is <=5 or at 22:30. This global variable is reset on 15:00.
Is this best way to do this? (I don’t fetch the positions of the 10 covers because it is not always up-to-date, because the Somfy cloud integration is not always working perfect and also in combination with controlling the covers with wall remote control units).