Light not turning on after motion is detected a second time

Thanks mate. You have understood what i am trying to do.

When i look in the logbook i see this. I walked in the room at 18:02:40 and i moved about for 2 mins in the room. Then i left at 18:04:35 and a few mins later then light went out.

See below for the logbook entry. Not sure if that shows how quickly its resetting its state. I am using a Phillips Hue Motion sensor.

could you please share your code? not just a picture, the code.

Philips Hue motion sensors do have a 10 seconds blind time, so it can work the way you want.

Thanks mate. I have pissed around with this so much. Right now this is what i have.

Basically on the top item “Turn on Dining Room Light - Dimmed” i am trying to get the light to turn off after 10 or 20 seconds but stay on if motion. The 07:00 to 23:00 branch the light can turn off after 5 mins as normal.

[{"id":"a34e4d89c741b6ed","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"69048e8815e2c5c7","type":"group","z":"a34e4d89c741b6ed","name":"Turn Dining Room Light - On - Off - If Alseep or away from home only turn on for 10 seconds","style":{"label":true},"nodes":["6641b60b7138c0ea","f59746a87f41122e","a2d3c205d739d7c9","53cdcdcabf0e2ecd","53397df6629e2775","d85d84582684037d","c1be55628be9d86c","9bae71e31798d8d4","5f198dde4a514c73"],"x":34,"y":119,"w":1232,"h":202},{"id":"6641b60b7138c0ea","type":"server-state-changed","z":"a34e4d89c741b6ed","g":"69048e8815e2c5c7","name":"Dining Room - ON","server":"da3b2d1e.ad751","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.mqtt_sensor_samsung_dining_room_occupancy","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":"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":150,"y":180,"wires":[["53cdcdcabf0e2ecd"],[]]},{"id":"f59746a87f41122e","type":"api-call-service","z":"a34e4d89c741b6ed","g":"69048e8815e2c5c7","name":"Turn off Dining Room Light","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.mqtt_bulb_phillips_dining_room_main"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":400,"y":260,"wires":[[]]},{"id":"a2d3c205d739d7c9","type":"api-call-service","z":"a34e4d89c741b6ed","g":"69048e8815e2c5c7","name":"Turn on Dining Room Light - Full","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.mqtt_bulb_phillips_dining_room_main"],"data":"{\"brightness\":255,\"rgb_color\":[255,255,255]}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1110,"y":220,"wires":[[]]},{"id":"53cdcdcabf0e2ecd","type":"api-current-state","z":"a34e4d89c741b6ed","g":"69048e8815e2c5c7","name":"Light Level","server":"7e20b797.b28178","version":3,"outputs":2,"halt_if":"2000","halt_if_type":"num","halt_if_compare":"lt","entity_id":"sensor.mqtt_sensor_samsung_dining_room_illuminance_lux","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":350,"y":180,"wires":[["53397df6629e2775"],[]]},{"id":"53397df6629e2775","type":"api-current-state","z":"a34e4d89c741b6ed","g":"69048e8815e2c5c7","name":"Good-Bye-Good-Night","server":"7e20b797.b28178","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.good_night_good_bye","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":590,"y":180,"wires":[["9bae71e31798d8d4"],["d85d84582684037d"]]},{"id":"d85d84582684037d","type":"within-time-switch","z":"a34e4d89c741b6ed","g":"69048e8815e2c5c7","name":"","nameInt":"","positionConfig":"b954ab15.fd5738","startTime":"07:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"23:00","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeRestrictions":0,"timeRestrictionsType":"none","timeDays":"*","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeOnlyOddWeeks":false,"timeOnlyEvenWeeks":false,"timeMonths":"*","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"withinTimeValue":"true","withinTimeValueType":"msgInput","outOfTimeValue":"false","outOfTimeValueType":"msgInput","tsCompare":"0","x":810,"y":220,"wires":[["a2d3c205d739d7c9"],["c1be55628be9d86c"]]},{"id":"c1be55628be9d86c","type":"api-call-service","z":"a34e4d89c741b6ed","g":"69048e8815e2c5c7","name":"Turn on Dining Room Light - Dimmed","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.mqtt_bulb_phillips_dining_room_main"],"data":"{\"brightness\":5,\"rgb_color\":[255,255,255]}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1090,"y":280,"wires":[[]]},{"id":"9bae71e31798d8d4","type":"api-call-service","z":"a34e4d89c741b6ed","g":"69048e8815e2c5c7","name":"Turn on Dining Room Light - Dimmed","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.mqtt_bulb_phillips_dining_room_main"],"data":"{\"brightness\":2,\"rgb_color\":[255,255,255]}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":910,"y":160,"wires":[[]]},{"id":"5f198dde4a514c73","type":"server-state-changed","z":"a34e4d89c741b6ed","g":"69048e8815e2c5c7","name":"Dining Room - OFF","server":"da3b2d1e.ad751","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.mqtt_sensor_samsung_dining_room_occupancy","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":"0","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":150,"y":260,"wires":[["f59746a87f41122e"],[]]},{"id":"da3b2d1e.ad751","type":"server","name":"Home Assistant","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"},{"id":"7e20b797.b28178","type":"server","name":"Home Assistant","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"},{"id":"b954ab15.fd5738","type":"position-config","name":"","isValide":"true","longitude":"0","latitude":"0","angleType":"deg","timeZoneOffset":"99","timeZoneDST":"0","stateTimeFormat":"3","stateDateFormat":"12","contextStore":""}]

So from 23:00 to 07:00 live should turn off after 10-20 seconds, otherwise after 5 minutes, is that it?

This

[{"id":"22d6d6ed.349f7a","type":"server-state-changed","z":"a34e4d89c741b6ed","name":"Dining Room PIR","server":"da3b2d1e.ad751","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.mqtt_sensor_samsung_dining_room_occupancy","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":"seconds","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[],"x":180,"y":560,"wires":[["b5d91453.c37948"]]},{"id":"b5d91453.c37948","type":"time-range-switch","z":"a34e4d89c741b6ed","name":"","lat":"","lon":"","startTime":"07:00","endTime":"23:00","startOffset":0,"endOffset":0,"x":370,"y":560,"wires":[["6f0ea451.8e682c"],["a8ad27ab.aca5e8"]]},{"id":"6f0ea451.8e682c","type":"trigger","z":"a34e4d89c741b6ed","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"5","extend":false,"overrideDelay":false,"units":"min","reset":"on","bytopic":"all","topic":"topic","outputs":1,"x":560,"y":540,"wires":[["a8ad27ab.aca5e8"]]},{"id":"a8ad27ab.aca5e8","type":"api-call-service","z":"a34e4d89c741b6ed","name":"Turn off Dining Room Light","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"service":"turn_off","entityId":["light.mqtt_bulb_phillips_dining_room_main"],"data":"","dataType":"jsonata","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":780,"y":580,"wires":[[]]},{"id":"da3b2d1e.ad751","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

should replace this

I suspect the rest you have it right?

Thanks mate. So the light is turning on but is still turning off with motion in the room and its not waiting 5 mins

I only need the light to go off after 20 seconds say if the Good-Bye-Good-Night toggle is on. Out side of that the light can stay on for 5 minutes before going off with no motion.

Below is my updated flow based on your changes.

[{"id":"755794255d420f60","type":"group","z":"f8c6eedc9d47547b","name":"Turn Dining Room Light - On - Off - If Alseep or away from home only turn on for 10 seconds","style":{"label":true},"nodes":["50db2ff5b9ceefb5","e67d52df87772633","0c0294a0fc27efc3","b8739c73e00df36a","5319acc36a3a3156","f21381b0771e5f53","a640af87ab430a68"],"x":14,"y":1499,"w":1232,"h":222},{"id":"50db2ff5b9ceefb5","type":"server-state-changed","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"Dining Room - ON","server":"da3b2d1e.ad751","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.mqtt_sensor_samsung_dining_room_occupancy","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":"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":130,"y":1560,"wires":[["0c0294a0fc27efc3"],[]]},{"id":"e67d52df87772633","type":"api-call-service","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"Turn on Dining Room Light - Full","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.mqtt_bulb_phillips_dining_room_main"],"data":"{\"brightness\":255,\"rgb_color\":[255,255,255]}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1070,"y":1600,"wires":[[]]},{"id":"0c0294a0fc27efc3","type":"api-current-state","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"Light Level","server":"7e20b797.b28178","version":3,"outputs":2,"halt_if":"2000","halt_if_type":"num","halt_if_compare":"lt","entity_id":"sensor.mqtt_sensor_samsung_dining_room_illuminance_lux","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":330,"y":1560,"wires":[["b8739c73e00df36a"],[]]},{"id":"b8739c73e00df36a","type":"api-current-state","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"Good-Bye-Good-Night","server":"7e20b797.b28178","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.good_night_good_bye","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":570,"y":1560,"wires":[["a640af87ab430a68"],["5319acc36a3a3156"]]},{"id":"5319acc36a3a3156","type":"within-time-switch","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"","nameInt":"","positionConfig":"b954ab15.fd5738","startTime":"07:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"23:00","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeRestrictions":0,"timeRestrictionsType":"none","timeDays":"*","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeOnlyOddWeeks":false,"timeOnlyEvenWeeks":false,"timeMonths":"*","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"withinTimeValue":"true","withinTimeValueType":"msgInput","outOfTimeValue":"false","outOfTimeValueType":"msgInput","tsCompare":"0","x":810,"y":1620,"wires":[["e67d52df87772633"],["f21381b0771e5f53"]]},{"id":"f21381b0771e5f53","type":"api-call-service","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"Turn on Dining Room Light - Dimmed","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.mqtt_bulb_phillips_dining_room_main"],"data":"{\"brightness\":5,\"rgb_color\":[255,255,255]}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1070,"y":1680,"wires":[[]]},{"id":"a640af87ab430a68","type":"api-call-service","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"Turn on Dining Room Light - Dimmed","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.mqtt_bulb_phillips_dining_room_main"],"data":"{\"brightness\":2,\"rgb_color\":[255,255,255]}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":890,"y":1540,"wires":[[]]},{"id":"da3b2d1e.ad751","type":"server","name":"Home Assistant","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"},{"id":"7e20b797.b28178","type":"server","name":"Home Assistant","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"},{"id":"b954ab15.fd5738","type":"position-config","name":"","isValide":"true","longitude":"0","latitude":"0","angleType":"deg","timeZoneOffset":"99","timeZoneDST":"0","stateTimeFormat":"3","stateDateFormat":"12","contextStore":""}]

Have you watched the Hookup on Youtube - he did a video recently on HA and NR and covered exactly this scenario - including remembering dimmed states etc

Have a look

Craig

I made a mistake before, I believe this should do it

replace this:

with this:

[{"id":"fc8f7a3f.45c778","type":"server-state-changed","z":"878e74c2.7f39c8","name":"Dining Room PIR","server":"da3b2d1e.ad751","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.mqtt_sensor_samsung_dining_room_occupancy","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":"seconds","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":200,"y":3700,"wires":[["3f4149df.34d7c6"]]},{"id":"80439b28.6409b8","type":"trigger","z":"878e74c2.7f39c8","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"5","extend":false,"overrideDelay":true,"units":"min","reset":"on","bytopic":"all","topic":"topic","outputs":1,"x":730,"y":3700,"wires":[["5038b65a.989948"]]},{"id":"5038b65a.989948","type":"api-call-service","z":"878e74c2.7f39c8","name":"Turn off Dining Room Light","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":["light.mqtt_bulb_phillips_dining_room_main"],"data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":940,"y":3700,"wires":[[]]},{"id":"3f4149df.34d7c6","type":"api-current-state","z":"878e74c2.7f39c8","name":"Good-Bye-Good-Night","server":"7e20b797.b28178","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.good_night_good_bye","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":400,"y":3700,"wires":[["38596d7c.280632"],["baa849ab.e85ae8"]]},{"id":"baa849ab.e85ae8","type":"change","z":"878e74c2.7f39c8","name":"5 min","rules":[{"t":"set","p":"delay","pt":"msg","to":"300000","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":3720,"wires":[["80439b28.6409b8"]]},{"id":"38596d7c.280632","type":"change","z":"878e74c2.7f39c8","name":"20 sec","rules":[{"t":"set","p":"delay","pt":"msg","to":"10000","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":3680,"wires":[["80439b28.6409b8"]]},{"id":"da3b2d1e.ad751","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30},{"id":"7e20b797.b28178","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

Delay is overridden by msg.delay in milliseconds. I set the 20 sec delay to 10000 mls because it’s 10 seconds from the PIR blind time plus 10 more seconds.

Ok so we are getting close i think. So when Good-Bye-Good-Night is off the light is coming on and staying on for 5 minutes.

When Good-Bye-Good-Night is on the light is coming on and going off after 20 seconds even though there is motion in the room. I have / will be using the same flows for other rooms. The bathroom is the one my Mrs is giving me a head ache over. :slight_smile:

Any other suggestions? Not far off it

[{"id":"755794255d420f60","type":"group","z":"f8c6eedc9d47547b","name":"Turn Dining Room Light - On - Off - If Alseep or away from home only turn on for 10 seconds","style":{"label":true},"nodes":["50db2ff5b9ceefb5","e67d52df87772633","0c0294a0fc27efc3","b8739c73e00df36a","5319acc36a3a3156","f21381b0771e5f53","a640af87ab430a68","c82db8f3e510d512","ccacd9e96f0322ca","4f2d4c55caa106b6","48ce0428cf5f1867"],"x":14,"y":1499,"w":1372,"h":242},{"id":"50db2ff5b9ceefb5","type":"server-state-changed","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"Dining Room PIR On","server":"da3b2d1e.ad751","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.mqtt_sensor_samsung_dining_room_occupancy","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":"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":130,"y":1560,"wires":[["0c0294a0fc27efc3"],[]]},{"id":"e67d52df87772633","type":"api-call-service","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"Turn on Dining Room Light - Full","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.mqtt_bulb_phillips_dining_room_main"],"data":"{\"brightness\":255,\"rgb_color\":[255,255,255]}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1190,"y":1560,"wires":[[]]},{"id":"0c0294a0fc27efc3","type":"api-current-state","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"Light Level","server":"7e20b797.b28178","version":3,"outputs":2,"halt_if":"2000","halt_if_type":"num","halt_if_compare":"lt","entity_id":"sensor.mqtt_sensor_samsung_dining_room_illuminance_lux","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":330,"y":1560,"wires":[["b8739c73e00df36a"],[]]},{"id":"b8739c73e00df36a","type":"api-current-state","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"Good-Bye-Good-Night","server":"7e20b797.b28178","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.good_night_good_bye","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":570,"y":1560,"wires":[["a640af87ab430a68"],["5319acc36a3a3156"]]},{"id":"5319acc36a3a3156","type":"within-time-switch","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"","nameInt":"","positionConfig":"b954ab15.fd5738","startTime":"07:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"23:00","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeRestrictions":0,"timeRestrictionsType":"none","timeDays":"*","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeOnlyOddWeeks":false,"timeOnlyEvenWeeks":false,"timeMonths":"*","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"withinTimeValue":"true","withinTimeValueType":"msgInput","outOfTimeValue":"false","outOfTimeValueType":"msgInput","tsCompare":"0","x":810,"y":1620,"wires":[["e67d52df87772633"],["f21381b0771e5f53"]]},{"id":"f21381b0771e5f53","type":"api-call-service","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"Turn on Dining Room Light - Dimmed","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.mqtt_bulb_phillips_dining_room_main"],"data":"{\"brightness\":5,\"rgb_color\":[255,255,255]}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1210,"y":1620,"wires":[[]]},{"id":"a640af87ab430a68","type":"api-call-service","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"Turn on Dining Room Light - Dimmed","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.mqtt_bulb_phillips_dining_room_main"],"data":"{\"brightness\":2,\"rgb_color\":[255,255,255]}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":890,"y":1540,"wires":[[]]},{"id":"c82db8f3e510d512","type":"server-state-changed","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"Dining Room PIR","server":"da3b2d1e.ad751","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.mqtt_sensor_samsung_dining_room_occupancy","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":"seconds","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[],"x":120,"y":1660,"wires":[["ccacd9e96f0322ca"]]},{"id":"ccacd9e96f0322ca","type":"api-current-state","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"Good-Bye-Good-Night","server":"7e20b797.b28178","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.good_night_good_bye","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":330,"y":1660,"wires":[["4f2d4c55caa106b6"],["48ce0428cf5f1867"]]},{"id":"4f2d4c55caa106b6","type":"change","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"20 sec","rules":[{"t":"set","p":"delay","pt":"msg","to":"10000","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":1640,"wires":[["b159050633ae74d3"]]},{"id":"48ce0428cf5f1867","type":"change","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"5 min","rules":[{"t":"set","p":"delay","pt":"msg","to":"300000","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":1700,"wires":[["b159050633ae74d3"]]},{"id":"da3b2d1e.ad751","type":"server","name":"Home Assistant","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"},{"id":"7e20b797.b28178","type":"server","name":"Home Assistant","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"},{"id":"b954ab15.fd5738","type":"position-config","name":"","isValide":"true","longitude":"0","latitude":"0","angleType":"deg","timeZoneOffset":"99","timeZoneDST":"0","stateTimeFormat":"3","stateDateFormat":"12","contextStore":""}]

sorry mate, I’m lost. Trigger node is behaving as expected according to my tests… I dunno where the problem is.

Just looking at the picture of the flow you have posted - what is different between the top and the bottom stream ? They both look like they are going to be operating on the PIR in the dining room - are you sure these are not running in parallel and clobbering each other ?

Maybe put some debug nodes on each one and set it to the full debug message (and give them both names like top and bottom) and post up the debug screen when you force motion

When i import that last flow you posted it does not have the trigger now and the turn off node either

Try this for the off signal, the input boolean/off time is accounted for in the jsonata

image

[{"id":"c82db8f3e510d512","type":"server-state-changed","z":"f80b6c338afd5483","name":"Dining Room PIR","server":"6b1110b5.183a4","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.mqtt_sensor_samsung_dining_room_occupancy","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":"$entities('input_boolean.good_night_good_bye').state ? 20 : 300\t","forType":"jsonata","forUnits":"seconds","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[],"x":800,"y":4280,"wires":[["ec755e89b660f56f"],[]]},{"id":"ec755e89b660f56f","type":"api-call-service","z":"f80b6c338afd5483","name":"Turn off Dining Room Light","server":"6b1110b5.183a4","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.mqtt_bulb_phillips_dining_room_main"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1090,"y":4280,"wires":[[]]},{"id":"6b1110b5.183a4","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m"}]
1 Like

Ah sorry not sure why the code did not come through in the flow. Hopefully this one has it all.

I think this seems to be working. I recreated manually what you did rather than import as i think something odd happened when it imported the flow. I also changed the off section to the off connection on the PIR @craigcurtin it might just have been that and thank you for the nudge in the right direction.

I need to do some testing. When the Good-Bye-Good-Night is on the light is switching off after 30 seconds. which i think you said was the 20 seconds delay and 10 seconds from the PIR blind time. 30 Seconds is more than fine.

I will do more testing today and will report back but from the test i just did its working as i wanted it. Thank you everyone who has commented and @obaldius for really taking the time , i really appreciate it.

Apart from getting it fixed (pending more testing) the main thing is i have learnt something along the way and thats the best bit.

[{"id":"755794255d420f60","type":"group","z":"f8c6eedc9d47547b","name":"Turn Dining Room Light - On - Off - If Alseep or away from home only turn on for 10 seconds","style":{"label":true},"nodes":["50db2ff5b9ceefb5","e67d52df87772633","0c0294a0fc27efc3","b8739c73e00df36a","5319acc36a3a3156","f21381b0771e5f53","a640af87ab430a68","ccacd9e96f0322ca","4f2d4c55caa106b6","48ce0428cf5f1867","6b33770ff8e373d0","fcdb85dd19314c17"],"x":14,"y":1499,"w":1372,"h":242},{"id":"50db2ff5b9ceefb5","type":"server-state-changed","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"Dining Room PIR","server":"da3b2d1e.ad751","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.mqtt_sensor_samsung_dining_room_occupancy","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":"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":1560,"wires":[["0c0294a0fc27efc3"],["ccacd9e96f0322ca"]]},{"id":"e67d52df87772633","type":"api-call-service","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"Turn on Dining Room Light - Full","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.mqtt_bulb_phillips_dining_room_main"],"data":"{\"brightness\":255,\"rgb_color\":[255,255,255]}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1190,"y":1560,"wires":[[]]},{"id":"0c0294a0fc27efc3","type":"api-current-state","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"Light Level","server":"7e20b797.b28178","version":3,"outputs":2,"halt_if":"2000","halt_if_type":"num","halt_if_compare":"lt","entity_id":"sensor.mqtt_sensor_samsung_dining_room_illuminance_lux","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":330,"y":1560,"wires":[["b8739c73e00df36a"],[]]},{"id":"b8739c73e00df36a","type":"api-current-state","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"Good-Bye-Good-Night","server":"7e20b797.b28178","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.good_night_good_bye","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":570,"y":1560,"wires":[["a640af87ab430a68"],["5319acc36a3a3156"]]},{"id":"5319acc36a3a3156","type":"within-time-switch","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"","nameInt":"","positionConfig":"b954ab15.fd5738","startTime":"07:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"23:00","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeRestrictions":0,"timeRestrictionsType":"none","timeDays":"*","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeOnlyOddWeeks":false,"timeOnlyEvenWeeks":false,"timeMonths":"*","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"withinTimeValue":"true","withinTimeValueType":"msgInput","outOfTimeValue":"false","outOfTimeValueType":"msgInput","tsCompare":"0","x":810,"y":1620,"wires":[["e67d52df87772633"],["f21381b0771e5f53"]]},{"id":"f21381b0771e5f53","type":"api-call-service","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"Turn on Dining Room Light - Dimmed","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.mqtt_bulb_phillips_dining_room_main"],"data":"{\"brightness\":5,\"rgb_color\":[255,255,255]}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1210,"y":1620,"wires":[[]]},{"id":"a640af87ab430a68","type":"api-call-service","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"Turn on Dining Room Light - Dimmed","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.mqtt_bulb_phillips_dining_room_main"],"data":"{\"brightness\":2,\"rgb_color\":[255,255,255]}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":890,"y":1540,"wires":[[]]},{"id":"ccacd9e96f0322ca","type":"api-current-state","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"Good-Bye-Good-Night","server":"7e20b797.b28178","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.good_night_good_bye","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":330,"y":1660,"wires":[["4f2d4c55caa106b6"],["48ce0428cf5f1867"]]},{"id":"4f2d4c55caa106b6","type":"change","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"20 sec","rules":[{"t":"set","p":"delay","pt":"msg","to":"20000","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":1640,"wires":[["6b33770ff8e373d0"]]},{"id":"48ce0428cf5f1867","type":"change","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"5 min","rules":[{"t":"set","p":"delay","pt":"msg","to":"300000","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":1700,"wires":[["6b33770ff8e373d0"]]},{"id":"6b33770ff8e373d0","type":"trigger","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"5","extend":false,"overrideDelay":true,"units":"min","reset":"on","bytopic":"all","topic":"topic","outputs":1,"x":670,"y":1680,"wires":[["fcdb85dd19314c17"]]},{"id":"fcdb85dd19314c17","type":"api-call-service","z":"f8c6eedc9d47547b","g":"755794255d420f60","name":"Turn off Dining Room Light","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.mqtt_bulb_phillips_dining_room_main"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":900,"y":1680,"wires":[[]]},{"id":"da3b2d1e.ad751","type":"server","name":"Home Assistant","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"},{"id":"7e20b797.b28178","type":"server","name":"Home Assistant","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"},{"id":"b954ab15.fd5738","type":"position-config","name":"","isValide":"true","longitude":"0","latitude":"0","angleType":"deg","timeZoneOffset":"99","timeZoneDST":"0","stateTimeFormat":"3","stateDateFormat":"12","contextStore":""}]

I don’t think this last picture you posted will work since the trigger node relies both on the on and off state to start / stop the countdown.

I don’t think top and bottom flows are clobbering, I would try to merge them though… not sure it would be worth it.

Mikefila’s suggestion is the best / most compact / prettiest solution you’ll find. If that doesn’t work, problem is somewhere else.

He made a little mistake in the Jsonata delay, he forgot to add the " = ‘on’ " comparison. Put this instead, but as I said, it’s the best approach we’ve come up with in this thread:

$entities('input_boolean.good_night_good_bye').state = 'on' ? 20 : 300	

If you want to merge both triggers into one node, this should work

[{"id":"aab9b1a7.28933","type":"server-state-changed","z":"878e74c2.7f39c8","name":"Dining Room PIR","server":"6b1110b5.183a4","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.mqtt_sensor_samsung_dining_room_occupancy","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":"$entities('input_boolean.good_night_good_bye').state = 'on' ? 20 : 300","forType":"jsonata","forUnits":"seconds","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[],"x":360,"y":4700,"wires":[["c0109bc2.8700e8"],["a02176b5.e16708"]]},{"id":"c0109bc2.8700e8","type":"api-call-service","z":"878e74c2.7f39c8","name":"Turn off Dining Room Light","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"service":"turn_off","entityId":["light.mqtt_bulb_phillips_dining_room_main"],"data":"","dataType":"jsonata","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":640,"y":4660,"wires":[[]]},{"id":"a02176b5.e16708","type":"api-current-state","z":"878e74c2.7f39c8","name":"Light Level","server":"7e20b797.b28178","version":3,"outputs":2,"halt_if":"2000","halt_if_type":"num","halt_if_compare":"lt","entity_id":"sensor.mqtt_sensor_samsung_dining_room_illuminance_lux","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":590,"y":4760,"wires":[["d87dc359.8c98d"],[]]},{"id":"d87dc359.8c98d","type":"api-current-state","z":"878e74c2.7f39c8","name":"Good-Bye-Good-Night","server":"7e20b797.b28178","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.good_night_good_bye","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":830,"y":4760,"wires":[["a5c1c3bb.94d2d"],["bb9d797f.e9e2d8"]]},{"id":"a5c1c3bb.94d2d","type":"api-call-service","z":"878e74c2.7f39c8","name":"Turn on Dining Room Light - Dimmed","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"service_domain":"","service":"turn_on","entityId":["light.mqtt_bulb_phillips_dining_room_main"],"data":"{\"brightness\":2,\"rgb_color\":[255,255,255]}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1150,"y":4720,"wires":[[]]},{"id":"6b94022c.e4e46c","type":"api-call-service","z":"878e74c2.7f39c8","name":"Turn on Dining Room Light - Full","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"service":"turn_on","entityId":["light.mqtt_bulb_phillips_dining_room_main"],"data":"{\"brightness\":255,\"rgb_color\":[255,255,255]}","dataType":"json","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1410,"y":4780,"wires":[[]]},{"id":"6fdbb943.ac6408","type":"api-call-service","z":"878e74c2.7f39c8","name":"Turn on Dining Room Light - Dimmed","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"service_domain":"","service":"turn_on","entityId":["light.mqtt_bulb_phillips_dining_room_main"],"data":"{\"brightness\":5,\"rgb_color\":[255,255,255]}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1430,"y":4840,"wires":[[]]},{"id":"bb9d797f.e9e2d8","type":"time-range-switch","z":"878e74c2.7f39c8","name":"","lat":"","lon":"","startTime":"07:00","endTime":"23:00","startOffset":0,"endOffset":0,"x":1070,"y":4800,"wires":[["6b94022c.e4e46c"],["6fdbb943.ac6408"]]},{"id":"6b1110b5.183a4","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"30"},{"id":"da3b2d1e.ad751","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30},{"id":"7e20b797.b28178","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]
1 Like

@obaldius. I have set all my rooms where i need this turn off after 20 secs and it seems to be working.

As long as there is movement the light stays on. No movement its off after the 30 seconds. It will be tonight that we will really knows and i need to wait for the seal of approval from the Mrs on the bathroom staying on more than 20 seconds when she goes down to the toilet in the night. But from what i can see so far it is working as it should.

I still think it won’t work… ¬¬’

I mean, it will work, but it doesn’t work as it was intended.

The way you set it it’s exactly the same as if you extended the delay from 10s to 30s in your original flow, nothing more…

If you go into the dining room, go away for 15 seconds and go back in, the trigger node won’t reset and you’ll find yourself in the dark 15 seconds later regardless of the last detected movement.

It apparently works, but when you find out it doesn’t come back to this thread.

After an evening of real world use i think you are right. It was not really noticeable apart from in the kitchen where even though we were in it the light was still going off way quicker than it should.

So i have changed the flow for the kitchen to include what you said a few posts back

$entities('input_boolean.good_night_good_bye').state = 'on' ? 20 : 300	

I have included the flow for the Kitchen below just so we know where i am right now. I know we was looking at dining room but to be fair i am using the same logic for all the rooms that need it. I will give it some real world testing today / this evening and see if its any better.

[{"id":"4702f2af3c981df9","type":"group","z":"f4d699e3f5593b7b","name":"Turn Kitchen Lights - On - Off - If Alseep or away from home only turn on for 20 seconds","style":{"label":true},"nodes":["b813d119661b7826","d7ae93874e9e42d5","836a9ec058e0f16f","3a22270b2b637ea5","58300163b07271ca","df5f749a45e913a9","3981fbf8d53e9c39","7899c3bad1c6d5ce"],"x":34,"y":299,"w":972,"h":262},{"id":"b813d119661b7826","type":"server-state-changed","z":"f4d699e3f5593b7b","g":"4702f2af3c981df9","name":"Kitchen PIR","server":"da3b2d1e.ad751","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.sensor_group_kitchen_motion_sensor","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":"$entities('input_boolean.good_night_good_bye').state = 'on' ? 20 : 300","forType":"jsonata","forUnits":"seconds","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[],"x":130,"y":360,"wires":[["7899c3bad1c6d5ce"],["836a9ec058e0f16f"]]},{"id":"d7ae93874e9e42d5","type":"api-call-service","z":"f4d699e3f5593b7b","g":"4702f2af3c981df9","name":"Turn on Kitchen Lights - Full","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.light_group_kitchen_spots"],"data":"{\"brightness\":255,\"rgb_color\":[255,255,255]}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":820,"y":460,"wires":[[]]},{"id":"836a9ec058e0f16f","type":"api-current-state","z":"f4d699e3f5593b7b","g":"4702f2af3c981df9","name":"Light Level","server":"7e20b797.b28178","version":3,"outputs":2,"halt_if":"200","halt_if_type":"num","halt_if_compare":"lt","entity_id":"sensor.mqtt_sensor_samsung_kitchen_boiler_illuminance_lux","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":150,"y":440,"wires":[["3a22270b2b637ea5"],[]]},{"id":"3a22270b2b637ea5","type":"api-current-state","z":"f4d699e3f5593b7b","g":"4702f2af3c981df9","name":"Good-Bye-Good-Night","server":"7e20b797.b28178","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.good_night_good_bye","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":370,"y":440,"wires":[["3981fbf8d53e9c39"],["58300163b07271ca"]]},{"id":"58300163b07271ca","type":"within-time-switch","z":"f4d699e3f5593b7b","g":"4702f2af3c981df9","name":"","nameInt":"","positionConfig":"b954ab15.fd5738","startTime":"07:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"23:00","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeRestrictions":0,"timeRestrictionsType":"none","timeDays":"*","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeOnlyOddWeeks":false,"timeOnlyEvenWeeks":false,"timeMonths":"*","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"withinTimeValue":"true","withinTimeValueType":"msgInput","outOfTimeValue":"false","outOfTimeValueType":"msgInput","tsCompare":"0","x":590,"y":480,"wires":[["d7ae93874e9e42d5"],["df5f749a45e913a9"]]},{"id":"df5f749a45e913a9","type":"api-call-service","z":"f4d699e3f5593b7b","g":"4702f2af3c981df9","name":"Turn on Kitchen Lights - Dimmed","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.light_group_kitchen_spots"],"data":"{\"brightness\":5,\"rgb_color\":[255,255,255]}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":840,"y":520,"wires":[[]]},{"id":"3981fbf8d53e9c39","type":"api-call-service","z":"f4d699e3f5593b7b","g":"4702f2af3c981df9","name":"Turn on Kitchen Lights - Dimmed","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.light_group_kitchen_spots"],"data":"{\"brightness\":2,\"rgb_color\":[255,255,255]}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":660,"y":400,"wires":[[]]},{"id":"7899c3bad1c6d5ce","type":"api-call-service","z":"f4d699e3f5593b7b","g":"4702f2af3c981df9","name":"Turn off Kitchen Lights","server":"da3b2d1e.ad751","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.light_group_kitchen_spots"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":360,"y":340,"wires":[[]]},{"id":"da3b2d1e.ad751","type":"server","name":"Home Assistant","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"},{"id":"7e20b797.b28178","type":"server","name":"Home Assistant","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"},{"id":"b954ab15.fd5738","type":"position-config","name":"","isValide":"true","longitude":"0","latitude":"0","angleType":"deg","timeZoneOffset":"99","timeZoneDST":"0","stateTimeFormat":"3","stateDateFormat":"12","contextStore":""}]
1 Like

Just to update. I think the above flow hit the nail on the head and is working as it should.

We was so busy last night in and out of rooms, in rooms for long period of times and we didnt even notice any issues that made us stop and notice the lights.

So unless we notice anything wrong i think this issue is fixed. Thank you to everyone who replied and helped. Your help is so appreciated in helping me get to grips with Node Red.