How can I disable / enable flow when manually switching the light on?

If the switch responds fast enough you can use a double click on the switch to disable the motion trigger. Use a trigger node in lieu of the event state for motion.

[{"id":"375747db3e20c029","type":"counter","z":"f80b6c338afd5483","name":"","init":"0","step":"1","lower":"","upper":"","mode":"increment","outputs":1,"x":440,"y":4200,"wires":[["5f9be7287e3a5e05"]]},{"id":"5f9be7287e3a5e05","type":"switch","z":"f80b6c338afd5483","name":"press count","property":"count","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":600,"y":4200,"wires":[["12e1ea8897038b9c"],["6cc051f26fff941b","d81ec59aa5eab12b","e95938d186272a82"]]},{"id":"e95938d186272a82","type":"change","z":"f80b6c338afd5483","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":4460,"wires":[["375747db3e20c029"]]},{"id":"12e1ea8897038b9c","type":"delay","z":"f80b6c338afd5483","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":910,"y":4200,"wires":[["e95938d186272a82"]]},{"id":"d81ec59aa5eab12b","type":"delay","z":"f80b6c338afd5483","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":910,"y":4320,"wires":[["e95938d186272a82","a9a46f87256c5dee"]]},{"id":"6cc051f26fff941b","type":"change","z":"f80b6c338afd5483","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":4260,"wires":[["12e1ea8897038b9c"]]},{"id":"f5748a75a870468d","type":"inject","z":"f80b6c338afd5483","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":4200,"wires":[["375747db3e20c029"]]},{"id":"a9a46f87256c5dee","type":"change","z":"f80b6c338afd5483","name":"disable","rules":[{"t":"set","p":"payload","pt":"msg","to":"disable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1110,"y":4320,"wires":[["d368ccbe013d5d45"]]},{"id":"d368ccbe013d5d45","type":"trigger-state","z":"f80b6c338afd5483","name":"set motion here","server":"6b1110b5.183a4","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"device_tracker.unifi_b8_27_eb_cb_22_f5_default","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":""}],"inputs":1,"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","enableInput":true,"x":1320,"y":4320,"wires":[[],[]]},{"id":"02928162cb3db3bc","type":"inject","z":"f80b6c338afd5483","name":"time to restart motion trigger","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":870,"y":4460,"wires":[["864a14d9096c23a5"]]},{"id":"864a14d9096c23a5","type":"change","z":"f80b6c338afd5483","name":"enable","rules":[{"t":"set","p":"payload","pt":"msg","to":"enable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1110,"y":4460,"wires":[["d368ccbe013d5d45"]]},{"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"}]

Just create an input_boolean (toggle) in the helper menu in Home Assistant.
Use a timestamp node to call the service input_boolean.turn_on to turn the boolean on at the start of the time range - to reset things.
Call the service to turn the boolean off when the light is manually turned off. Call the service to turn the boolean on when the light is manually turned on.

Check the state of the boolean when the PIR is triggered - to see if it should turn the light on or not.

This is how I do it

They are trying to keep the light off not on. If you reverse the enable and disable commands, it would work.

It would also turn off the pir anytime the switch was turned off. If you don’t really use the switch, then it would work.

Thanks for all the help and suggestions, but unfortunately I’m still struggling :frowning: :pensive:

@Mikefila I have tried your suggestion but doesn’t seem to be working. The lights come on but doesn’t seem to go off nor when I manually switch the light of the flow doesn’t seem to do anything. (it could possibly me doing something wrong)

@mobile.andrew.jones your suggestion sounds very interesting but to be honest I have no idea how to implement it (I am relatively new to Node Red so still learning) But I will give it a go today and will let you know.

@mbonani This solution also sounds great, but when testing it the motion sensor node goes to disabled and just stays there, doesn’t change back to enabled. I see in your flow you use light (which I assume is a smart light? I use a smart wall switch so don’t know if that is what’s causing the problem.

Thanks again for your assistance!

What smart switch is that? how is it integrated? is there a way you can tell whether the light was turned on due to someone clicking the smart switch instead of your PIR?

If you can tell the difference then it’s easy. When that switch is manually clicked then stop that flow somehow: with an input boolean, exposing and disabling the event: state node, etc…

For this particular scenarios I like to create a sensor in NR. Paste your code and I’ll be able to provide a more visual example,

The smart switch is a Sonoff device. It’s integrated via Tuya into Home Assistant. If the PIR senses movement it the switches on that switch, but can also control it via the app or UI.

This is the code for the basic setup (as per original post) This works great, but need to have a function to override / disable this flow if the light has been switched off manually

[{"id":"76db671eca5bfcfd","type":"server-state-changed","z":"0919a69f33566eb7","name":"Sliding Door PIR","server":"2879a640.7a9e7a","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.zone_sliding_door_open","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","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":[],"x":100,"y":80,"wires":[[],["26fab5174aa55088"]]},{"id":"7a9d045f8bf7d262","type":"api-call-service","z":"0919a69f33566eb7","name":"Light Switch","server":"2879a640.7a9e7a","version":5,"debugenabled":false,"domain":"switch","service":"turn_on","areaId":["patio"],"deviceId":["f4abb1ab408791bc8b5253d128d3b1fe"],"entityId":["switch.patio_lights_socket_1"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":610,"y":80,"wires":[["08dddb64a1da2931"]]},{"id":"9a62d44a23b89e86","type":"api-call-service","z":"0919a69f33566eb7","name":"Turn Off Patio Lights","server":"2879a640.7a9e7a","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":["f4abb1ab408791bc8b5253d128d3b1fe"],"entityId":["switch.patio_lights_socket_1"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1040,"y":80,"wires":[[]]},{"id":"08dddb64a1da2931","type":"trigger","z":"0919a69f33566eb7","name":"Timer","op1":"1","op2":"1","op1type":"str","op2type":"str","duration":"5","extend":true,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":810,"y":80,"wires":[[],["9a62d44a23b89e86"]]},{"id":"26fab5174aa55088","type":"time-range-switch","z":"0919a69f33566eb7","name":"Time Range","lat":"","lon":"","startTime":"18:00","endTime":"22:30","startOffset":0,"endOffset":0,"x":350,"y":80,"wires":[["7a9d045f8bf7d262"],[]]},{"id":"2879a640.7a9e7a","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"}]

This is the code I am currently testing with (suggested by @mbonani Mbonani)
Just made a few changes to the entities.

[{"id":"e433ab36.c6b358","type":"api-call-service","z":"a6f32365d996ff1c","name":"Patio Lights ON","server":"2879a640.7a9e7a","version":5,"debugenabled":false,"domain":"switch","service":"turn_on","areaId":[],"deviceId":["f4abb1ab408791bc8b5253d128d3b1fe"],"entityId":["switch.patio_lights_socket_1"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","output_location":"","output_location_type":"none","x":1100,"y":280,"wires":[[]]},{"id":"cd7df0e2.ea938","type":"trigger","z":"a6f32365d996ff1c","name":"10min","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"1","extend":true,"units":"min","reset":"","bytopic":"all","outputs":1,"x":930,"y":360,"wires":[["16bf9a80.ccead6"]]},{"id":"16bf9a80.ccead6","type":"api-call-service","z":"a6f32365d996ff1c","name":"Patio Lights OFF","server":"2879a640.7a9e7a","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":["f4abb1ab408791bc8b5253d128d3b1fe"],"entityId":["switch.patio_lights_socket_1"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","output_location":"","output_location_type":"none","x":1110,"y":360,"wires":[[]]},{"id":"14739080.90dc9","type":"change","z":"a6f32365d996ff1c","name":"RESET","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":815,"y":200,"wires":[["cd7df0e2.ea938"]],"icon":"node-red/timer.svg","l":false},{"id":"ce4419ce.841178","type":"trigger-state","z":"a6f32365d996ff1c","name":"Dining Room Motion Sensor","server":"2879a640.7a9e7a","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"binary_sensor.zone_dining_room_open","entityidfiltertype":"exact","debugenabled":false,"constraints":[],"inputs":1,"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","enableInput":true,"x":200,"y":220,"wires":[["a2d4c1a6.bb35a"],["279d7f80.57b5d"]]},{"id":"56668319.4c687c","type":"trigger-state","z":"a6f32365d996ff1c","name":"Motion Sensor","server":"2879a640.7a9e7a","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"binary_sensor.dining_room_motion_sensor","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"inputs":1,"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","enableInput":true,"x":650,"y":360,"wires":[["e433ab36.c6b358","14739080.90dc9"],["cd7df0e2.ea938"]]},{"id":"279d7f80.57b5d","type":"change","z":"a6f32365d996ff1c","name":"ENABLE","rules":[{"t":"set","p":"payload","pt":"msg","to":"enable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":475,"y":260,"wires":[["14739080.90dc9","56668319.4c687c"]],"icon":"font-awesome/fa-toggle-on","l":false},{"id":"a2d4c1a6.bb35a","type":"change","z":"a6f32365d996ff1c","name":"DISABLE","rules":[{"t":"set","p":"payload","pt":"msg","to":"disable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":475,"y":190,"wires":[["14739080.90dc9"]],"icon":"font-awesome/fa-toggle-off","l":false},{"id":"3d1eb7ce.7c42a8","type":"server-state-changed","z":"a6f32365d996ff1c","name":"Patio Lights","server":"2879a640.7a9e7a","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.patio_lights_socket_1","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":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":300,"wires":[[],["279d7f80.57b5d"]]},{"id":"2879a640.7a9e7a","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"}]

So basically all I need to do is the ability to switch of the light off manually and not for the PIR to switch it back on again within the time range.

Thanks

How does your PIR work? as far as I understand, according to your first flow, when PIR’s state is not
true, then turn on the lights ?

Doesn’t your PIR report on and off states? if it does, what is the blind time of your PIR? how long does it take to go off again after detecting movement?

It should be that when the PIR detects motion it must turn on the lights. So it needs to be true.
Yes the PIR reports on on and off states. I would say it takes about 2 seconds to go off after it detects movement.

This is one way I think you can achieve what you want.

[{"id":"70559aa8.374e54","type":"server-state-changed","z":"878e74c2.7f39c8","name":"Light to off?","server":"9405c3fe.d0a6c","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.patio_lights_socket_1","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":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":230,"y":3700,"wires":[["2a90c62b.52498a"],[]]},{"id":"2a90c62b.52498a","type":"api-current-state","z":"878e74c2.7f39c8","name":"PIR off for 5 min?","server":"9405c3fe.d0a6c","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.zone_sliding_door_open","state_type":"str","blockInputOverrides":true,"outputProperties":[],"for":"5","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":430,"y":3700,"wires":[[],["19530122.16b04f"]]},{"id":"63c6562.0d210a8","type":"trigger-state","z":"878e74c2.7f39c8","name":"PIR","server":"9405c3fe.d0a6c","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"binary_sensor.zone_sliding_door_open","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","comparatorType":"is_not","comparatorValueDatatype":"prevEntity","comparatorValue":"state","propertyValue":"new_state.state"}],"inputs":1,"outputs":4,"customoutputs":[{"messageType":"default","messageValue":"","messageValueType":"json","comparatorPropertyType":"current_state","comparatorType":"is","comparatorValue":"on","comparatorValueDataType":"str","comparatorPropertyValue":"new_state.state"},{"messageType":"default","messageValue":"","messageValueType":"json","comparatorPropertyType":"current_state","comparatorType":"is","comparatorValue":"off","comparatorValueDataType":"str","comparatorPropertyValue":"new_state.state"}],"outputinitially":false,"state_type":"str","enableInput":true,"x":810,"y":3780,"wires":[[],[],["8f8c54ec.63f5e8","44dca1b5.c7a5a"],["44dca1b5.c7a5a"]]},{"id":"44dca1b5.c7a5a","type":"trigger","z":"878e74c2.7f39c8","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"5","extend":false,"overrideDelay":false,"units":"min","reset":"on","bytopic":"all","topic":"topic","outputs":1,"x":970,"y":3820,"wires":[["6e75ed51.1d73e4"]]},{"id":"8f8c54ec.63f5e8","type":"time-range-switch","z":"878e74c2.7f39c8","name":"Time Range","lat":"","lon":"","startTime":"18:00","endTime":"22:30","startOffset":0,"endOffset":0,"x":970,"y":3780,"wires":[["6e75ed51.1d73e4"],[]]},{"id":"6e75ed51.1d73e4","type":"api-call-service","z":"878e74c2.7f39c8","name":"Light Switch","server":"2879a640.7a9e7a","version":5,"debugenabled":false,"service_domain":"switch","service":"turn_{{payload}}","entityId":["switch.patio_lights_socket_1"],"data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1190,"y":3820,"wires":[[]]},{"id":"19530122.16b04f","type":"change","z":"878e74c2.7f39c8","name":"dis","rules":[{"t":"set","p":"payload","pt":"msg","to":"disable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":3760,"wires":[["63c6562.0d210a8"]]},{"id":"66a1caf2.f54014","type":"change","z":"878e74c2.7f39c8","name":"enable","rules":[{"t":"set","p":"payload","pt":"msg","to":"enable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":3800,"wires":[["63c6562.0d210a8"]]},{"id":"6977a25.de3865c","type":"inject","z":"878e74c2.7f39c8","name":"Every day at 22:31","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"31 22 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":360,"y":3860,"wires":[["66a1caf2.f54014"]]},{"id":"f7c6f0e5.547db","type":"comment","z":"878e74c2.7f39c8","name":"Main flow","info":"","x":820,"y":3620,"wires":[]},{"id":"80bf0e00.b7e2e","type":"comment","z":"878e74c2.7f39c8","name":"Manual operation","info":"","x":240,"y":3620,"wires":[]},{"id":"b42fd897.958d58","type":"comment","z":"878e74c2.7f39c8","name":"Restore automatic operation","info":"","x":340,"y":3800,"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":"2879a640.7a9e7a","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}]

The logic is as follows.

Main flow is basically your flow but with a trigger: state node instead of an event: state node since it’s easier to enable/disable it without needing to create any extra entity.

Manual operation logic: If light goes off and the PIR is either on or has been off for less than 5 minutes, you can assume it was manipulated manually, given that the PIR turns it off only after 5 minutes, not before. If everything cheks, disable the Main flow.

Restore automatic operation is there just in case you forget to enable it back again, it does the work for you.

I’d personally go this way, it might be more difficult to understand though

[{"id":"d9631ff.d5dd0e","type":"comment","z":"878e74c2.7f39c8","name":"Patio Lights auto/manual mode sensor","info":"","x":250,"y":4240,"wires":[]},{"id":"429dc2b.660353c","type":"ha-entity","z":"878e74c2.7f39c8","name":"sensor.patio_lights_socket_1_manual_auto","server":"9405c3fe.d0a6c","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"patio_lights_socket_1_manual_auto"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1150,"y":4520,"wires":[[]]},{"id":"fb95b448.0cc0c8","type":"comment","z":"878e74c2.7f39c8","name":"To manual","info":"","x":200,"y":4340,"wires":[]},{"id":"2bb4ea0.fa65916","type":"server-state-changed","z":"878e74c2.7f39c8","name":"Light to off?","server":"9405c3fe.d0a6c","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.patio_lights_socket_1","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":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[],"x":210,"y":4420,"wires":[["32addbd6.f68e24"],[]]},{"id":"32addbd6.f68e24","type":"api-current-state","z":"878e74c2.7f39c8","name":"PIR off for 5 min?","server":"9405c3fe.d0a6c","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.zone_sliding_door_open","state_type":"str","blockInputOverrides":true,"outputProperties":[],"for":"5","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":410,"y":4420,"wires":[[],["28a8e34a.caa25c"]]},{"id":"d5d46bcb.aff898","type":"change","z":"878e74c2.7f39c8","name":"manual","rules":[{"t":"set","p":"payload","pt":"msg","to":"manual","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":4480,"wires":[["429dc2b.660353c"]]},{"id":"95fa9843.8de008","type":"change","z":"878e74c2.7f39c8","name":"auto","rules":[{"t":"set","p":"payload","pt":"msg","to":"auto","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":4560,"wires":[["429dc2b.660353c"]]},{"id":"8be88cb9.8d8e8","type":"link in","z":"878e74c2.7f39c8","name":"","links":["28a8e34a.caa25c"],"x":735,"y":4480,"wires":[["d5d46bcb.aff898"]]},{"id":"7b98c79.34f1e38","type":"link in","z":"878e74c2.7f39c8","name":"","links":["8d0e44be.c548c8"],"x":735,"y":4560,"wires":[["95fa9843.8de008"]]},{"id":"28a8e34a.caa25c","type":"link out","z":"878e74c2.7f39c8","name":"","links":["8be88cb9.8d8e8"],"x":535,"y":4420,"wires":[]},{"id":"c0b42d91.e43eb","type":"comment","z":"878e74c2.7f39c8","name":"To auto","info":"","x":190,"y":4540,"wires":[]},{"id":"caf62019.b6cee","type":"inject","z":"878e74c2.7f39c8","name":"Every day at 22:31","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"31 22 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":240,"y":4620,"wires":[["8d0e44be.c548c8"]]},{"id":"8d0e44be.c548c8","type":"link out","z":"878e74c2.7f39c8","name":"","links":["7b98c79.34f1e38"],"x":375,"y":4620,"wires":[]},{"id":"225098cc.2f6ec8","type":"comment","z":"878e74c2.7f39c8","name":"Main flow","info":"","x":160,"y":3980,"wires":[]},{"id":"29923e7d.8dbbe2","type":"server-state-changed","z":"878e74c2.7f39c8","name":"PIR off for 5 min?","server":"9405c3fe.d0a6c","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.zone_sliding_door_open","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":"5","forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[],"x":220,"y":4080,"wires":[["d11ad810.c0f348"],["d11ad810.c0f348"]]},{"id":"1459e9ff.8bdda6","type":"server-state-changed","z":"878e74c2.7f39c8","name":"sensor auto/manual","server":"9405c3fe.d0a6c","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.patio_lights_socket_1_manual_auto","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":210,"y":4120,"wires":[["d11ad810.c0f348"]]},{"id":"d11ad810.c0f348","type":"api-current-state","z":"878e74c2.7f39c8","name":"auto?","server":"9405c3fe.d0a6c","version":3,"outputs":2,"halt_if":"auto","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.patio_lights_socket_1_manual_auto","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":450,"y":4100,"wires":[["e67a7a26.16eac8"],["2c629738.7e2518"]]},{"id":"2c629738.7e2518","type":"api-call-service","z":"878e74c2.7f39c8","name":"Light off","server":"2879a640.7a9e7a","version":5,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":["switch.patio_lights_socket_1"],"data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":600,"y":4140,"wires":[[]]},{"id":"e67a7a26.16eac8","type":"api-current-state","z":"878e74c2.7f39c8","name":"PIR off for 5 min?","server":"9405c3fe.d0a6c","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.zone_sliding_door_open","state_type":"str","blockInputOverrides":true,"outputProperties":[],"for":"5","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":630,"y":4080,"wires":[["64700779.8df778"],["47956d8b.f70e24"]]},{"id":"64700779.8df778","type":"api-call-service","z":"878e74c2.7f39c8","name":"Light off","server":"2879a640.7a9e7a","version":5,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":["switch.patio_lights_socket_1"],"data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":820,"y":4040,"wires":[[]]},{"id":"47956d8b.f70e24","type":"time-range-switch","z":"878e74c2.7f39c8","name":"Time Range","lat":"","lon":"","startTime":"18:00","endTime":"22:30","startOffset":0,"endOffset":0,"x":830,"y":4100,"wires":[["6762f089.a7b44"],[]]},{"id":"6762f089.a7b44","type":"api-call-service","z":"878e74c2.7f39c8","name":"Light on","server":"2879a640.7a9e7a","version":5,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":["switch.patio_lights_socket_1"],"data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1000,"y":4100,"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":"2879a640.7a9e7a","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}]

Creating a sensor.patio_lights_socket_1_manual_auto allows you to have better control over the main flow. You’ll always know whether the main flow is in automatic mode or in manual mode. Aside from that, you can more easily add different triggers to change the state of your sensor, different ways to set the flow to auto or to manual.

Main flow contains this sensor as a trigger, so you only really need to care about configuring your sensor right. Main flow will do the rest and you’ll very rarely need to change it. This way, if for example, you set the sensor to manual, light will go off. On the other hand, if you set the sensor back to auto and someone is in the room (motion’s been detected during the last 5 minutes whithin your time range), light will turn on too.

Is more complete and better finished.

You can try it this way, If you turn the switch off, then on, then off again in under 4 seconds, it will disable the pir.

[{"id":"d542f98f13ac28ce","type":"counter","z":"24e54e48.fd06f2","name":"count","init":"3","step":"1","lower":"0","upper":"3","mode":"decrement","outputs":2,"x":1650,"y":380,"wires":[["fdcffaab87d5a294"],[]]},{"id":"fdcffaab87d5a294","type":"switch","z":"24e54e48.fd06f2","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1830,"y":380,"wires":[["39d679148f3e1367","7a6e4874bf631f61"]]},{"id":"fa5685097f2499a2","type":"delay","z":"24e54e48.fd06f2","name":"","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1500,"y":300,"wires":[["39d679148f3e1367"]]},{"id":"39d679148f3e1367","type":"change","z":"24e54e48.fd06f2","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1740,"y":300,"wires":[["d542f98f13ac28ce"]]},{"id":"c6bc3b3d0f50d2ae","type":"server-state-changed","z":"24e54e48.fd06f2","name":"light switch","server":"6b1110b5.183a4","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"device_tracker.unifi_b8_27_eb_cb_22_f5_default","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":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":1240,"y":380,"wires":[["fa5685097f2499a2","d542f98f13ac28ce"]]},{"id":"7a6e4874bf631f61","type":"change","z":"24e54e48.fd06f2","name":"disable","rules":[{"t":"set","p":"payload","pt":"msg","to":"disable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1990,"y":380,"wires":[["93a0281a1c707717"]]},{"id":"93a0281a1c707717","type":"trigger-state","z":"24e54e48.fd06f2","name":"pir trigger","server":"6b1110b5.183a4","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"device_tracker.unifi_b8_27_eb_cb_22_f5_default","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":""}],"inputs":1,"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","enableInput":true,"x":2200,"y":380,"wires":[[],[]]},{"id":"3411c6b6fb995b98","type":"change","z":"24e54e48.fd06f2","name":"enable","rules":[{"t":"set","p":"payload","pt":"msg","to":"enable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1990,"y":460,"wires":[["93a0281a1c707717"]]},{"id":"3e7846828231ed2d","type":"inject","z":"24e54e48.fd06f2","name":"turn on pir trigger everyday @ 18:00","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 18 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1730,"y":460,"wires":[["3411c6b6fb995b98"]]},{"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"}]

@obaldius Thank you, I will definitely implement this and when I get back home and will revert back.
I am looking at now and will make sense of it when I see it in action :slight_smile:
I will let you know once I have implemented it.

Thanks

One last note.

If you use a sensor created through NR as a trigger in any of your flows don’t forget to check the first five ignore state when boxes to avoid problems upon restarts. In fact it would be wise to do that almost everywhere… Not sure why those boxes aren’t checked by default. But more specifically with these NR sensors, if you don’t do that, your flows will trigger at every restart.

@obaldius Thanks for the info and explanations :slight_smile: I have tried the following flow

[{"id":"70559aa8.374e54","type":"server-state-changed","z":"878e74c2.7f39c8","name":"Light to off?","server":"9405c3fe.d0a6c","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.patio_lights_socket_1","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":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":230,"y":3700,"wires":[["2a90c62b.52498a"],[]]},{"id":"2a90c62b.52498a","type":"api-current-state","z":"878e74c2.7f39c8","name":"PIR off for 5 min?","server":"9405c3fe.d0a6c","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.zone_sliding_door_open","state_type":"str","blockInputOverrides":true,"outputProperties":[],"for":"5","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":430,"y":3700,"wires":[[],["19530122.16b04f"]]},{"id":"63c6562.0d210a8","type":"trigger-state","z":"878e74c2.7f39c8","name":"PIR","server":"9405c3fe.d0a6c","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"binary_sensor.zone_sliding_door_open","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","comparatorType":"is_not","comparatorValueDatatype":"prevEntity","comparatorValue":"state","propertyValue":"new_state.state"}],"inputs":1,"outputs":4,"customoutputs":[{"messageType":"default","messageValue":"","messageValueType":"json","comparatorPropertyType":"current_state","comparatorType":"is","comparatorValue":"on","comparatorValueDataType":"str","comparatorPropertyValue":"new_state.state"},{"messageType":"default","messageValue":"","messageValueType":"json","comparatorPropertyType":"current_state","comparatorType":"is","comparatorValue":"off","comparatorValueDataType":"str","comparatorPropertyValue":"new_state.state"}],"outputinitially":false,"state_type":"str","enableInput":true,"x":810,"y":3780,"wires":[[],[],["8f8c54ec.63f5e8","44dca1b5.c7a5a"],["44dca1b5.c7a5a"]]},{"id":"44dca1b5.c7a5a","type":"trigger","z":"878e74c2.7f39c8","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"5","extend":false,"overrideDelay":false,"units":"min","reset":"on","bytopic":"all","topic":"topic","outputs":1,"x":970,"y":3820,"wires":[["6e75ed51.1d73e4"]]},{"id":"8f8c54ec.63f5e8","type":"time-range-switch","z":"878e74c2.7f39c8","name":"Time Range","lat":"","lon":"","startTime":"18:00","endTime":"22:30","startOffset":0,"endOffset":0,"x":970,"y":3780,"wires":[["6e75ed51.1d73e4"],[]]},{"id":"6e75ed51.1d73e4","type":"api-call-service","z":"878e74c2.7f39c8","name":"Light Switch","server":"2879a640.7a9e7a","version":5,"debugenabled":false,"service_domain":"switch","service":"turn_{{payload}}","entityId":["switch.patio_lights_socket_1"],"data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1190,"y":3820,"wires":[[]]},{"id":"19530122.16b04f","type":"change","z":"878e74c2.7f39c8","name":"dis","rules":[{"t":"set","p":"payload","pt":"msg","to":"disable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":3760,"wires":[["63c6562.0d210a8"]]},{"id":"66a1caf2.f54014","type":"change","z":"878e74c2.7f39c8","name":"enable","rules":[{"t":"set","p":"payload","pt":"msg","to":"enable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":3800,"wires":[["63c6562.0d210a8"]]},{"id":"6977a25.de3865c","type":"inject","z":"878e74c2.7f39c8","name":"Every day at 22:31","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"31 22 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":360,"y":3860,"wires":[["66a1caf2.f54014"]]},{"id":"f7c6f0e5.547db","type":"comment","z":"878e74c2.7f39c8","name":"Main flow","info":"","x":820,"y":3620,"wires":[]},{"id":"80bf0e00.b7e2e","type":"comment","z":"878e74c2.7f39c8","name":"Manual operation","info":"","x":240,"y":3620,"wires":[]},{"id":"b42fd897.958d58","type":"comment","z":"878e74c2.7f39c8","name":"Restore automatic operation","info":"","x":340,"y":3800,"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":"2879a640.7a9e7a","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}]

I can see that the flow is triggered but getting the this error:

I have changed it from patio to Spare Bedroom, makes it easier to test and play with. I don’t know if that messed things up now?

This is the Flow after updating:

[{"id":"6e75ed51.1d73e4","type":"api-call-service","z":"864945b7d8432708","name":"Light Switch","server":"2879a640.7a9e7a","version":5,"debugenabled":false,"service":"turn_{{payload}}","areaId":[],"deviceId":[],"entityId":["switch.spare_bedroom_switch_1"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","service_domain":"switch","mergecontext":"","x":1050,"y":240,"wires":[[]]},{"id":"2879a640.7a9e7a","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"}]

I checked the debug and its complaining about no domain in the node. I tried changing the domain but the can’t select turn_{{payload}} or add it.

Thanks

Do this to simplify things for now, I have a way older version of NR and that dropdown menu doesn’t show up in my instance. Split the service call node into two nodes: switch.turn_on and switch.turn_off

domain: switch
service: turn_on & turn_off respectively

Awesome thanks. I will test once I get back home this afternoon. hopefully it will work perfectly now.

Thanks

To use a command that does not show in the drop down add a pound sign at the end.

turn_{{payload}}#

Then select it. The most recent HA nodes you don’t need the pound sign, you should be able to just enter it.

Thanks from me too. Not having used state nodes before ,I would normally have used a flow variable to store the state of the light, but this is a neat solution.

1 Like

@obaldius Awesome, thanks it is working perfectly now!! Thanks for you assistance. I made it so that when the light is turned on manually the flow starts again, tested and working great

[{"id":"e043b635ab019e4c","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"a071ec60fdc42f68","type":"server-state-changed","z":"e043b635ab019e4c","name":"Light to off?","server":"2879a640.7a9e7a","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.patio_lights_socket_1","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":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":130,"y":140,"wires":[["d44f57ac59f053c8"],["33bd6ca7eb1c6534"]]},{"id":"d44f57ac59f053c8","type":"api-current-state","z":"e043b635ab019e4c","name":"PIR off for 5 min?","server":"2879a640.7a9e7a","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.zone_dining_room_open","state_type":"str","blockInputOverrides":true,"outputProperties":[],"for":"10","forType":"num","forUnits":"seconds","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":370,"y":140,"wires":[[],["0fecb96854c68d93"]]},{"id":"fbad6e45c195bfcf","type":"trigger-state","z":"e043b635ab019e4c","name":"PIR","server":"2879a640.7a9e7a","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"binary_sensor.zone_dining_room_open","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is_not","comparatorValueDatatype":"prevEntity","comparatorValue":"state"}],"inputs":1,"outputs":4,"customoutputs":[{"messageType":"default","messageValue":"","messageValueType":"json","comparatorPropertyType":"current_state","comparatorPropertyValue":"new_state.state","comparatorType":"is","comparatorValue":"on","comparatorValueDataType":"str"},{"messageType":"default","messageValue":"","messageValueType":"json","comparatorPropertyType":"current_state","comparatorPropertyValue":"new_state.state","comparatorType":"is","comparatorValue":"off","comparatorValueDataType":"str"}],"outputinitially":false,"state_type":"str","enableInput":true,"x":550,"y":240,"wires":[[],[],["edc49ffb40c52069","cb1cb8838671199a"],["cb1cb8838671199a"]]},{"id":"cb1cb8838671199a","type":"trigger","z":"e043b635ab019e4c","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"10","extend":false,"overrideDelay":false,"units":"s","reset":"on","bytopic":"all","topic":"topic","outputs":1,"x":770,"y":280,"wires":[["4991534be6b8c200"]]},{"id":"edc49ffb40c52069","type":"time-range-switch","z":"e043b635ab019e4c","name":"Time Range","lat":"","lon":"","startTime":"17:00","endTime":"22:30","startOffset":0,"endOffset":0,"x":770,"y":200,"wires":[["778bd10f480103e2"],[]]},{"id":"0fecb96854c68d93","type":"change","z":"e043b635ab019e4c","name":"dis","rules":[{"t":"set","p":"payload","pt":"msg","to":"disable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":220,"wires":[["fbad6e45c195bfcf"]]},{"id":"33bd6ca7eb1c6534","type":"change","z":"e043b635ab019e4c","name":"enable","rules":[{"t":"set","p":"payload","pt":"msg","to":"enable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":260,"wires":[["fbad6e45c195bfcf"]]},{"id":"1d5dcc85a06c0f85","type":"inject","z":"e043b635ab019e4c","name":"Every day at 22:31","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"31 22 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":340,"wires":[["33bd6ca7eb1c6534"]]},{"id":"97f4b5f2e9d97256","type":"comment","z":"e043b635ab019e4c","name":"Patio Lights","info":"","x":130,"y":60,"wires":[]},{"id":"22ecf2b2610483e5","type":"comment","z":"e043b635ab019e4c","name":"Manual operation","info":"","x":140,"y":100,"wires":[]},{"id":"42db5ab1b3653eb5","type":"comment","z":"e043b635ab019e4c","name":"Restore automatic operation","info":"","x":180,"y":300,"wires":[]},{"id":"778bd10f480103e2","type":"api-call-service","z":"e043b635ab019e4c","name":"Light Switch On","server":"2879a640.7a9e7a","version":5,"debugenabled":false,"domain":"switch","service":"turn_on","areaId":[],"deviceId":[],"entityId":["switch.patio_lights_socket_1"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1040,"y":200,"wires":[[]]},{"id":"4991534be6b8c200","type":"api-call-service","z":"e043b635ab019e4c","name":"Light Switch Off","server":"2879a640.7a9e7a","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.patio_lights_socket_1"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1040,"y":280,"wires":[[]]},{"id":"2879a640.7a9e7a","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"}]

Thanks again for your help! :slight_smile:

1 Like