Hello, newbie here so, please bear with me.
Days ago I created a simple automation involving a light (lux) sensor and a couple of external smart lights:
- Is the light sensor below 10 lux?
- If so, turn on the exterior lights
- Every day, at 10 pm, turn them off.
The automation works perfectly. Now, here comes the catch: I wanted to convert this automation to Node-Red, piece of cake right?, well, no. Here is my converted ‘version’:
And here is the code:
[{"id":"c7598497bd67830e","type":"server-state-changed","z":"22f1f34ef85f0be6","name":"Is light sensor below 10 lux?","server":"31a7d703.5ff578","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.tsl2591_light_sensor_lux","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"10","halt_if_type":"num","halt_if_compare":"lt","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"},{"property":"service","propertyType":"msg","value":"turn_on","valueType":"str"}],"x":140,"y":2680,"wires":[["6a26aa2efe910768"],[]]},{"id":"6a26aa2efe910768","type":"api-call-service","z":"22f1f34ef85f0be6","name":"External Lights ON/OFF","server":"31a7d703.5ff578","version":5,"debugenabled":false,"domain":"light","service":"{{service}}","areaId":[],"deviceId":[],"entityId":["light.entrada_luz_inferior","light.garaje_luz_superior_on_off"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":470,"y":2700,"wires":[[]]},{"id":"038fb745c2b90810","type":"inject","z":"22f1f34ef85f0be6","name":"Turn lights off (daily at 10:00 PM)","props":[{"p":"service","v":"turn_off","vt":"str"}],"repeat":"","crontab":"00 22 * * *","once":false,"onceDelay":0.1,"topic":"","x":180,"y":2740,"wires":[["6a26aa2efe910768"]]},{"id":"31a7d703.5ff578","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}]
The flow does work as expected but for one thing, lights are being turned on early in the morning when the lux sensor catches the first luminosity at sunrise, a reading below 10 that triggers the flow and turns the lights back to ‘on’.
How do you prevent this?
Any help will be appreciated.
Cheers from rainy Costa Rica.