Light with motion - Override with switch?

Thanks.
This is all well and good, but it still does not explain how to get input from (ie. turn on the light) my Homeassistant companion on my Android, or via the Lovelace UI on the web page from a computer.

The same goes when I set up a helper that gets set to ON when the light is turned on via a switch.
The helper does not get set to ON when doing the same operation via Lovelace

By “Helper”, do you mean an input boolean?

In my nodered flow, I’m not using any “helpers”. I’m using the traffic light node to control the flow from the motion/door sensor. The traffic light node is directly controlled by whether or not the light is on.

Are your light entities controlled by a separate switch entity? ie. binary_sensor/ physical switch entity

Yes, I mean an input boolean.
My point is, I have tried both methods, including yours with the traffic light.
Sure, they work when using the light switch, but NOT when I do the same via the Lovelace UI, either on my phone or on the web page.

When the light is turned on/off, can you see the traffic light node switching between “allow” and “stop”?

EDIT:
Also, want entity do you have for the “light switch” in the first node?

I’m sorry for the late reply.
Here is a picture of the flow:

Here is an export of the flow:

[{"id":"c8d04565.caeae8","type":"tab","label":"Loft","disabled":false,"info":""},{"id":"a25b6a5b.801cb8","type":"switch","z":"c8d04565.caeae8","name":"Valg","property":"payload.action","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"brightness_move_up","vt":"str"},{"t":"eq","v":"brightness_move_down","vt":"str"},{"t":"eq","v":"brightness_stop","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":470,"y":760,"wires":[["b47d1fd9.59c24","df0be10c.e8961"],["448d443d.96e96c","57fe9b4e.d01744"],["2e1e7788.81b648"],["dbac15f3.d2e908"],["13dea8ec.9dfcd7"]]},{"id":"b47d1fd9.59c24","type":"api-current-state","z":"c8d04565.caeae8","name":"Already on?","server":"22f5da40.d3e236","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"group.light_loft_gang_taklys","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":690,"y":540,"wires":[["e74d91e2.f0912"],["bdad43dd.7e1b4"]]},{"id":"e74d91e2.f0912","type":"api-call-service","z":"c8d04565.caeae8","name":"Turn on - Max","server":"22f5da40.d3e236","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"group.light_loft_gang_taklys","data":"{\"brightness\": 254}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1280,"y":480,"wires":[[]]},{"id":"bdad43dd.7e1b4","type":"api-call-service","z":"c8d04565.caeae8","name":"Turn on","server":"22f5da40.d3e236","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"group.light_loft_gang_taklys","data":"{\"brightness\": 180}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1260,"y":540,"wires":[[]]},{"id":"448d443d.96e96c","type":"api-current-state","z":"c8d04565.caeae8","name":"Already off?","server":"22f5da40.d3e236","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"group.light_loft_gang_taklys","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":690,"y":600,"wires":[[],["98f994c4.1ae5a8"]]},{"id":"98f994c4.1ae5a8","type":"api-call-service","z":"c8d04565.caeae8","name":"Turn off","server":"22f5da40.d3e236","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"group.light_loft_gang_taklys","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1260,"y":600,"wires":[[]]},{"id":"3d4a7472.29aa1c","type":"api-current-state","z":"c8d04565.caeae8","name":"Status","server":"22f5da40.d3e236","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"group.light_loft_gang_taklys","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1010,"y":840,"wires":[["3ff617a1.c7dbc8"],[]]},{"id":"d23ffca9.d431","type":"api-call-service","z":"c8d04565.caeae8","name":"Light On","server":"22f5da40.d3e236","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"","data":"{    \"entity_id\": \"group.light_loft_gang_taklys\",    \"brightness\": {{payload}}}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1380,"y":840,"wires":[[]]},{"id":"3ff617a1.c7dbc8","type":"function","z":"c8d04565.caeae8","name":"Brightness +30","func":"\nvar brightness = msg.data.attributes.brightness;\n\nbrightness = parseInt(brightness);\n\nif (brightness < 224) {\n    brightness = brightness + 30;\n} else {\n    brightness = 254;\n}\n\nmsg.payload = brightness;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1200,"y":840,"wires":[["d23ffca9.d431"]]},{"id":"2e1e7788.81b648","type":"trigger","z":"c8d04565.caeae8","name":"Resend","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"-500","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":860,"y":840,"wires":[["3d4a7472.29aa1c"]]},{"id":"6fa4d2fd.29cf6c","type":"api-current-state","z":"c8d04565.caeae8","name":"Status","server":"22f5da40.d3e236","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"group.light_loft_gang_taklys","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1010,"y":900,"wires":[["1b06e9c.bdc4c16"],[]]},{"id":"23cb20c5.bf7fd","type":"api-call-service","z":"c8d04565.caeae8","name":"Light Off","server":"22f5da40.d3e236","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"group.light_loft_gang_taklys","data":"{\"brightness\": {{payload}}}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1380,"y":900,"wires":[[]]},{"id":"1b06e9c.bdc4c16","type":"function","z":"c8d04565.caeae8","name":"Brightness -30","func":"\nvar brightness = msg.data.attributes.brightness;\n\nbrightness = parseInt(brightness);\n\nif (brightness >= 30) {\n    brightness = brightness - 30;\n} else {\n    brightness = 0;\n}\n\nmsg.payload = brightness;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1200,"y":900,"wires":[["23cb20c5.bf7fd"]]},{"id":"dbac15f3.d2e908","type":"trigger","z":"c8d04565.caeae8","name":"Resend","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"-500","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":860,"y":900,"wires":[["6fa4d2fd.29cf6c"]]},{"id":"b591f0df.663b2","type":"mqtt in","z":"c8d04565.caeae8","name":"Loft - Gang - Lysbryter","topic":"zigbee2mqtt/Loft - Gang - Lysbryter","qos":"0","datatype":"json","broker":"3d06dee0.f98b0a","x":160,"y":760,"wires":[["a25b6a5b.801cb8"]]},{"id":"13dea8ec.9dfcd7","type":"change","z":"c8d04565.caeae8","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":860,"wires":[["2e1e7788.81b648","dbac15f3.d2e908"]]},{"id":"328d9492.69a7fc","type":"api-call-service","z":"c8d04565.caeae8","name":"Turn on","server":"c20c4f32.3a7de","version":1,"debugenabled":true,"service_domain":"light","service":"turn_on","entityId":"group.light_loft_gang_taklys","data":"{\"brightness\":{{{payload}}}}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1260,"y":200,"wires":[[]]},{"id":"66c00d69.935014","type":"api-current-state","z":"c8d04565.caeae8","name":"Already on?","server":"c20c4f32.3a7de","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"group.light_loft_gang_taklys","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":670,"y":200,"wires":[[],["d33e8b50.1cf5d8","b0a3631f.fbad"]]},{"id":"cc281130.ff1dd","type":"api-call-service","z":"c8d04565.caeae8","name":"Turn off","server":"c20c4f32.3a7de","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"group.light_loft_gang_taklys","data":"{\"transition\": 10}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1260,"y":400,"wires":[[]]},{"id":"a6456619.b41898","type":"inject","z":"c8d04565.caeae8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":130,"y":200,"wires":[["66c00d69.935014"]]},{"id":"3cc3eeae.209542","type":"inject","z":"c8d04565.caeae8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":130,"y":400,"wires":[["14e51033.64d2c"]]},{"id":"480545a5.befb6c","type":"trigger","z":"c8d04565.caeae8","name":"60 sec delay","op1":"","op2":"on","op1type":"nul","op2type":"str","duration":"60","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1090,"y":400,"wires":[["cc281130.ff1dd"]]},{"id":"d33e8b50.1cf5d8","type":"change","z":"c8d04565.caeae8","name":"Light Brightness Adjustment","rules":[{"t":"set","p":"payload","pt":"msg","to":"Light_Brightness","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":200,"wires":[["328d9492.69a7fc"]]},{"id":"c4c618c0.3671d8","type":"switch","z":"c8d04565.caeae8","name":"True or False","property":"payload.occupancy","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":460,"y":300,"wires":[["66c00d69.935014"],["14e51033.64d2c"]]},{"id":"c91fd5be.057b28","type":"mqtt in","z":"c8d04565.caeae8","name":"Loft - Motion sensor","topic":"zigbee2mqtt/Loft - Gang - Motion Sensor","qos":"2","datatype":"json","broker":"3d06dee0.f98b0a","x":150,"y":300,"wires":[["c4c618c0.3671d8"]]},{"id":"14e51033.64d2c","type":"api-current-state","z":"c8d04565.caeae8","name":"Already off?","server":"c20c4f32.3a7de","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"group.light_loft_gang_taklys","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":690,"y":400,"wires":[["3900f36c.7175ac"],[]]},{"id":"df0be10c.e8961","type":"api-call-service","z":"c8d04565.caeae8","name":"Boolean Light On","server":"c20c4f32.3a7de","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.helper_loft_lysbryter","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":710,"y":680,"wires":[[]]},{"id":"3900f36c.7175ac","type":"api-current-state","z":"c8d04565.caeae8","name":"Lys fra bryter?","server":"c20c4f32.3a7de","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.helper_loft_lysbryter","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":880,"y":400,"wires":[[],["480545a5.befb6c"]]},{"id":"57fe9b4e.d01744","type":"api-call-service","z":"c8d04565.caeae8","name":"Boolean Light Off","server":"c20c4f32.3a7de","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.helper_loft_lysbryter","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":710,"y":740,"wires":[[]]},{"id":"6ab49071.0ee37","type":"inject","z":"c8d04565.caeae8","name":"Reduce Brightness at 21:00","props":[{"p":"payload"},{"p":"topic","v":"Light_Brightness","vt":"num"}],"repeat":"","crontab":"00 21 * * *","once":false,"onceDelay":"","topic":"","payload":"20","payloadType":"num","x":200,"y":140,"wires":[["9a5ba6c.9b25758"]]},{"id":"56c351ae.2f3b3","type":"inject","z":"c8d04565.caeae8","name":"Normal Brightness at 6:00","props":[{"p":"payload"},{"p":"topic","v":"Light_Brightness","vt":"num"}],"repeat":"","crontab":"00 06 * * *","once":false,"onceDelay":"","topic":"","payload":"150","payloadType":"num","x":200,"y":80,"wires":[["9a5ba6c.9b25758"]]},{"id":"9a5ba6c.9b25758","type":"change","z":"c8d04565.caeae8","name":"Light Brightness Adjustment","rules":[{"t":"set","p":"Light_Brightness","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":100,"wires":[[]]},{"id":"b0a3631f.fbad","type":"api-call-service","z":"c8d04565.caeae8","name":"Boolean Light Off","server":"c20c4f32.3a7de","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.helper_loft_lysbryter","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1290,"y":260,"wires":[[]]},{"id":"22f5da40.d3e236","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true},{"id":"3d06dee0.f98b0a","type":"mqtt-broker","name":"localhost - Min","broker":"mqtt://core-mosquitto","port":"1883","tls":"","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"c20c4f32.3a7de","type":"server","name":"Home Assistant - Min","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

The switch is a Philips Hue light switch connected by Zigbee2MQTT. The light is connected via the Philips Hue bridge.

Thanks.

This is how I do it. I have my motion node exposed to HA as a switch called “[room name] Motion Trigger”. If the light gets toggled (using a Philips Hue Dimmer as well connected to Z2M), it toggles the state of the exposed switch. So, if the light switch is turned on, it disables the motion node. When the light is turned off, it waits 10 seconds and then turns the motion trigger back on.

It would be pretty easy to adapt this to detect when a light is turned on via Lovelace and apply the same logic.

This is the whole point of this thread. It’s creating an automation for when you do NOT have a seperate switch entity to the light entity.

I don’t have a separate physical switch entity. The light entity is all I have. And this is what controls the traffic light node.

Hi.
All this is understood.
But I still need to find a way to trigger the input boolean helper (or the traffic light node) if the light is turned on via the Lovelace UI

I’m sorry, but it doesn’t seem that you understand what I’m saying. Maybe I’m not explaining it clear enough.

If you turn the light on via Lovelace, the light entity is now “on”. I use this entity directly to control the traffic light node in my flow. So it shouldn’t matter how the light is turned on.

Have you tried importing my flow and testing it?

Thanks for answering, and sorry for the late reply.
So I’ve probably done some overthinking here.

Your traffic light works fine, and is a beautiful clever way to stop the sensor :slight_smile:

But I’ve always imagined that this will create at catch-22 situation, since the sensor will also change the light state to on.
How will the light know when to be turned off again if turned on by the sensor?

There must be something we haven’t thought of here, this is too easy :slight_smile:

Thank you.

You’re exactly right - The sensor turning on the light will change the traffic light node too.

However, by that stage, the flow has already been triggered, and the rest of the automation can continue AFTER the traffic light node.

How are you setting the state of the On/Off “input_boolean.porch_light_auto” node?

Since using node red, I no longer require using input booleans.

I’m confused then. The Node Red flow you posted in early April (that I replied to) uses the input boolean porch_light_auto:

Ohh, that’s a very good point.

That node is probably redundant now. I could probably remove it. Lol

Ah, that makes sense. This is my new working edit for my bathroom lights:

If it’s dark outside, and there are other lights on in the house, bathroom lights are set to 100% on motion trigger, and turn off after 30s of no motion
If it’s dark outside, and all the other lights are off, bathroom lights are set to 14% on motion trigger (ie someone gets up in the middle of the night to use the restroom), and turn off after 30s of no motion
If someone turns on the light manually, it will stay on until turned off again.

1 Like

like this?

likethis
this
that

no matter how the light is turned on or off this will set the state of the input boolean…