[SOLVED]Some help please

Hi Guys hoping someone can help with something really basic that i can’t get my head round lol
So I’m doing the Hookups motion lights.
I’m just wanting the light to come on with motion then dim then go off afterwards, and that does work great however i want to set a time limit so it only runs 30 minutes after sunset.
I’ve tried some Eztimer nodes i normally use in various flows but can’t get it working.
Any help appreciated as I’m wanting to use this flow for my bedroom light as well but with extra conditions.
Thanks
flow
[{"id":"1e6b2fb618da75c5","type":"server-state-changed","z":"a6a11ae5.8e47f8","name":"Kitchen Motion","server":"8a3231e1.3f0e1","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.kitchen","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"off","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"15","forType":"num","forUnits":"seconds","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":120,"y":1180,"wires":[["84f14951547f5cd5"],["8a30f97dcc7b24f8","84f14951547f5cd5"]]},{"id":"7bd265f4ed42615c","type":"api-call-service","z":"a6a11ae5.8e47f8","name":"Kitchen Lamp off","server":"8a3231e1.3f0e1","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.kitchen_lamp"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":650,"y":1200,"wires":[[]]},{"id":"8a30f97dcc7b24f8","type":"api-call-service","z":"a6a11ae5.8e47f8","name":"Kitchen Lamp on 80%","server":"8a3231e1.3f0e1","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.kitchen_lamp"],"data":"{\"brightness_pct\":\"100\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":380,"y":1220,"wires":[[]]},{"id":"84f14951547f5cd5","type":"trigger","z":"a6a11ae5.8e47f8","name":"30 secs","op1":"Dim","op2":"off","op1type":"str","op2type":"str","duration":"30","extend":true,"overrideDelay":false,"units":"s","reset":"on","bytopic":"all","topic":"topic","outputs":2,"x":340,"y":1160,"wires":[["dbf5a64dc7a98d57"],["7bd265f4ed42615c"]]},{"id":"dbf5a64dc7a98d57","type":"api-call-service","z":"a6a11ae5.8e47f8","name":"Kitchen Lamp dimmed 50 %","server":"8a3231e1.3f0e1","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.kitchen_lamp"],"data":"{\"brightness_pct\":\"50\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":680,"y":1140,"wires":[[]]},{"id":"8a3231e1.3f0e1","type":"server","name":"Hassio","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m"}]

As I understand it, you want the light turn on with motion, dim to 50% after 15 seconds and turn back off after 45 seconds total. On top of that, you only want this flow to work from sunset to sunset + 30mins. If so, this should do it. The brightness_pct variable is set whithin every event state node.

[{"id":"351b1c20.b04634","type":"time-range-switch","z":"878e74c2.7f39c8","name":"from sunset to sunset + 30'","lat":"","lon":"","startTime":"sunset","endTime":"sunset","startOffset":0,"endOffset":"30","x":400,"y":2140,"wires":[["dfa254bb.bd3218"],[]]},{"id":"63306723.736dd8","type":"server-state-changed","z":"878e74c2.7f39c8","name":"PIR on","server":"9405c3fe.d0a6c","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.kitchen","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"brightness_pct","propertyType":"msg","value":"80","valueType":"num"}],"x":170,"y":2100,"wires":[["351b1c20.b04634"],[]]},{"id":"b97f8f40.3eb4a","type":"server-state-changed","z":"878e74c2.7f39c8","name":"PIR off for 15''","server":"9405c3fe.d0a6c","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.kitchen","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"off","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"15","forType":"num","forUnits":"seconds","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"brightness_pct","propertyType":"msg","value":"50","valueType":"num"}],"x":150,"y":2140,"wires":[["351b1c20.b04634"],[]]},{"id":"ad628892.6a55b8","type":"server-state-changed","z":"878e74c2.7f39c8","name":"PIR off for 45''","server":"9405c3fe.d0a6c","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.kitchen","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"off","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"45","forType":"num","forUnits":"seconds","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"brightness_pct","propertyType":"msg","value":"0","valueType":"num"}],"x":150,"y":2180,"wires":[["351b1c20.b04634"],[]]},{"id":"dfa254bb.bd3218","type":"api-call-service","z":"878e74c2.7f39c8","name":"Light to X brightness","server":"8a3231e1.3f0e1","version":5,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":["light.kitchen_lamp"],"data":"{\"brightness_pct\":brightness_pct}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":660,"y":2140,"wires":[[]]},{"id":"9405c3fe.d0a6c","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},{"id":"8a3231e1.3f0e1","type":"server","name":"Hassio","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

Thanks that looks great I’ve just added it I can’t test until I get home.
The one I did last night wasn’t great as we moved in the night the light came on then instantly of again :laughing:
Had to load up node red at 3am to disable it lol

That worked great thanks.
I copied it to use in my bedroom also but with 1 extra condition.
So I want the motion lights in a evening like your flow.
But if my wife goes upstairs to watch TV she prefers the light to stay on as the time.
So I added this extra node to check if the TV is on or off , if on turn the light of off carry on with the motion lighting.
It does seem to work but looking at the debug it’s still sending the brightness data to the light but obviously it’s not actually changing it.
Is this the way you would do it ? I just thought there must be a more efficient way of doing it.
Thanks.

if I were really picky and I wanted to have a 100% bulletproof flow, I’d do it this way.

With this flow, fox example, if your wife is watching the tv at 19:00. regardless of motion, light will turn to 80%.

Or if you are watching TV and light is set to 80%, as soon as you turn off the TV the light will dim or turn off if need be.

I was also bothered by that and, after trying a few things to fix it, I ended up letting it be. Any attempt always brought more problems than it solved.

Final flow. Make sure to fill the blanks and the information whithin every node.

[{"id":"1b2eeeb6.5119f1","type":"time-range-switch","z":"878e74c2.7f39c8","name":"7 - 11","lat":"","lon":"","startTime":"18:59","endTime":"23:00","startOffset":0,"endOffset":"0","x":510,"y":2140,"wires":[["aa47fc43.867f8"],[]]},{"id":"f2f1f8d2.1ad088","type":"server-state-changed","z":"878e74c2.7f39c8","name":"PIR on","server":"9405c3fe.d0a6c","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.kitchen","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[],"x":290,"y":2140,"wires":[["1b2eeeb6.5119f1"],[]]},{"id":"2be77585.4446ea","type":"server-state-changed","z":"878e74c2.7f39c8","name":"PIR off for 15''","server":"9405c3fe.d0a6c","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.kitchen","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"off","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"15","forType":"num","forUnits":"seconds","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[],"x":270,"y":2180,"wires":[["1b2eeeb6.5119f1"],[]]},{"id":"acb70ceb.97236","type":"server-state-changed","z":"878e74c2.7f39c8","name":"PIR off for 45''","server":"9405c3fe.d0a6c","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.kitchen","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"off","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"45","forType":"num","forUnits":"seconds","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[],"x":270,"y":2220,"wires":[["1b2eeeb6.5119f1"],[]]},{"id":"b9d85a7d.56e8c8","type":"api-call-service","z":"878e74c2.7f39c8","name":"Light to 80","server":"8a3231e1.3f0e1","version":5,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":["light.kitchen_lamp"],"data":"{\"brightness_pct\":80}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1030,"y":2080,"wires":[[]]},{"id":"56c734b6.0bb53c","type":"inject","z":"878e74c2.7f39c8","name":"at 7","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 19 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":290,"y":2100,"wires":[["1b2eeeb6.5119f1"]]},{"id":"786aebbb.a39504","type":"server-state-changed","z":"878e74c2.7f39c8","name":"TV","server":"9405c3fe.d0a6c","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[],"x":290,"y":2060,"wires":[["1b2eeeb6.5119f1"]]},{"id":"aa47fc43.867f8","type":"api-current-state","z":"878e74c2.7f39c8","name":"TV on ?","server":"9405c3fe.d0a6c","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"","state_type":"str","blockInputOverrides":true,"outputProperties":[],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":660,"y":2140,"wires":[["b9d85a7d.56e8c8"],["1b67e156.8e023f"]]},{"id":"1b67e156.8e023f","type":"api-current-state","z":"878e74c2.7f39c8","name":"PIR on?","server":"9405c3fe.d0a6c","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.kitchen","state_type":"str","blockInputOverrides":true,"outputProperties":[],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":820,"y":2180,"wires":[["b9d85a7d.56e8c8"],["51c5e583.89268c"]]},{"id":"51c5e583.89268c","type":"api-current-state","z":"878e74c2.7f39c8","name":"PIR off for 45''?","server":"9405c3fe.d0a6c","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.kitchen","state_type":"str","blockInputOverrides":true,"outputProperties":[],"for":"45","forType":"num","forUnits":"seconds","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1000,"y":2220,"wires":[["9e18c5db.addec8"],["82b5461f.04d0a8"]]},{"id":"9e18c5db.addec8","type":"api-call-service","z":"878e74c2.7f39c8","name":"Light off","server":"8a3231e1.3f0e1","version":5,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":["light.kitchen_lamp"],"data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1240,"y":2160,"wires":[[]]},{"id":"82b5461f.04d0a8","type":"api-current-state","z":"878e74c2.7f39c8","name":"PIR off for 15''?","server":"9405c3fe.d0a6c","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.kitchen","state_type":"str","blockInputOverrides":true,"outputProperties":[],"for":"15","forType":"num","forUnits":"seconds","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1260,"y":2280,"wires":[["24afcc02.5707e4"],[]]},{"id":"24afcc02.5707e4","type":"api-call-service","z":"878e74c2.7f39c8","name":"Light to 50","server":"8a3231e1.3f0e1","version":5,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":["light.kitchen_lamp"],"data":"{\"brightness_pct\":50}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1470,"y":2240,"wires":[[]]},{"id":"9405c3fe.d0a6c","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},{"id":"8a3231e1.3f0e1","type":"server","name":"Hassio","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]
1 Like

Thanks so much for that’s working perfect.
I love seeing flows all set up like this so i can work out how things are all going together, i can never visualise it in my head.
Cheers.
On a side note how are you getting the code for the flow to display in one long box ?
When i did mine above i tried the preformatted text and Blockquote but it wouldn’t display like that.

1 Like

Three commas like these ones before and after your code ``

1 Like