Light with motion - Override with switch?

This ALMOST worked.

Problem:
When the MOTION trigger turns the SWITCH on and its turning the BOOLEAN MOTION on - which is fine.
However, the SWITCH turning on triggers the bottom sequence of that flow and in turn halting the OFF automation from the timer of the top sequence.

Right so we need to turn off the light boolean only when light is turned on by motion.

[{"id":"7818ef92.edfb6","type":"switch","z":"ce443d08.e992c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":410,"y":260,"wires":[["6d294209.f13e4c","bab761ef.aacf5"],[]]},{"id":"bab761ef.aacf5","type":"stoptimer","z":"ce443d08.e992c","duration":"2","units":"Minute","payloadtype":"num","payloadval":"0","name":"2min","x":590,"y":280,"wires":[["26754ff6.b8b39"],[]]},{"id":"281ca419.f9ca6c","type":"api-call-service","z":"ce443d08.e992c","name":"OFF","server":"e7c576e.5663a88","service_domain":"switch","service":"turn_off","data":"{\"entity_id\": \"switch.patio_light_switch\"}","mergecontext":"","x":1230,"y":320,"wires":[[]]},{"id":"7139e7ff.fbcc08","type":"api-call-service","z":"ce443d08.e992c","name":"ON","server":"e7c576e.5663a88","service_domain":"switch","service":"turn_on","data":"{\"entity_id\": \"switch.patio_light_switch\"}","mergecontext":"","x":1010,"y":220,"wires":[[]]},{"id":"1c710c1d.7b8c94","type":"api-current-state","z":"ce443d08.e992c","name":"Already On?","server":"e7c576e.5663a88","halt_if":"on","override_topic":true,"override_payload":true,"entity_id":"switch.patio_light_switch","x":810,"y":220,"wires":[["7139e7ff.fbcc08","7b0508ff.82bc08","1415b628.050caa"]]},{"id":"31ea000d.6ca9f","type":"server-state-changed","z":"ce443d08.e992c","name":"Motion","server":"e7c576e.5663a88","entityidfilter":"binary_sensor.motion_sensor_158d000200ea5b","entityidfiltertype":"substring","haltifstate":"","x":210,"y":260,"wires":[["7818ef92.edfb6"]]},{"id":"6d294209.f13e4c","type":"time-range-switch","z":"ce443d08.e992c","name":"After Sunset","lat":"","lon":"","startTime":"sunsetStart","endTime":"sunrise","startOffset":"","endOffset":"","x":610,"y":220,"wires":[["1c710c1d.7b8c94"],[]]},{"id":"ad3dc0de.fe19","type":"server-state-changed","z":"ce443d08.e992c","name":"Light Switch","server":"e7c576e.5663a88","entityidfilter":"switch.patio_light_switch","entityidfiltertype":"exact","haltifstate":"off","x":210,"y":460,"wires":[["29e63b67.282114"]]},{"id":"26754ff6.b8b39","type":"api-current-state","z":"ce443d08.e992c","name":"Still Motion?","server":"e7c576e.5663a88","halt_if":"on","override_topic":true,"override_payload":true,"entity_id":"binary_sensor.motion_sensor_158d000200ea5b","x":810,"y":280,"wires":[["86cc7407.8e5a38"]]},{"id":"29e63b67.282114","type":"switch","z":"ce443d08.e992c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":390,"y":460,"wires":[["4dcfaca2.62b284","edb1a007.d2e6","1a4ca8fa.a0ca87"],["db4bb719.3aff88","dd584938.a4c388"]]},{"id":"86cc7407.8e5a38","type":"api-current-state","z":"ce443d08.e992c","name":"Light Switch on Halt","server":"69a8824.8c4167c","halt_if":"","override_topic":true,"override_payload":true,"entity_id":"","x":1020,"y":280,"wires":[["281ca419.f9ca6c","54d6ad37.392454"]]},{"id":"7b0508ff.82bc08","type":"api-call-service","z":"ce443d08.e992c","name":"Boolean Motion On","server":"69a8824.8c4167c","service_domain":"input_boolean","service":"turn_on","data":"","mergecontext":"","x":1050,"y":180,"wires":[[]]},{"id":"54d6ad37.392454","type":"api-call-service","z":"ce443d08.e992c","name":"Boolean Motion Off","server":"69a8824.8c4167c","service_domain":"input_boolean","service":"turn_off","data":"","mergecontext":"","x":1270,"y":260,"wires":[[]]},{"id":"4dcfaca2.62b284","type":"api-call-service","z":"ce443d08.e992c","name":"Boolean Light On","server":"69a8824.8c4167c","service_domain":"input_boolean","service":"turn_on","data":"","mergecontext":"","x":610,"y":380,"wires":[[]]},{"id":"edb1a007.d2e6","type":"api-call-service","z":"ce443d08.e992c","name":"Light On","server":"69a8824.8c4167c","service_domain":"switch","service":"turn_on","data":"","mergecontext":"","x":580,"y":420,"wires":[[]]},{"id":"1a4ca8fa.a0ca87","type":"api-call-service","z":"ce443d08.e992c","name":"Boolean Motion Off","server":"69a8824.8c4167c","service_domain":"input_boolean","service":"turn_off","data":"","mergecontext":"","x":610,"y":460,"wires":[[]]},{"id":"db4bb719.3aff88","type":"api-call-service","z":"ce443d08.e992c","name":"Light Off","server":"69a8824.8c4167c","service_domain":"switch","service":"turn_off","data":"","mergecontext":"","x":580,"y":500,"wires":[[]]},{"id":"dd584938.a4c388","type":"api-call-service","z":"ce443d08.e992c","name":"Boolean Light Off","server":"69a8824.8c4167c","service_domain":"input_boolean","service":"turn_off","data":"","mergecontext":"","x":610,"y":540,"wires":[[]]},{"id":"1415b628.050caa","type":"api-call-service","z":"ce443d08.e992c","name":"Boolean Light Off","server":"69a8824.8c4167c","service_domain":"input_boolean","service":"turn_off","data":"","mergecontext":"","x":1050,"y":140,"wires":[[]]},{"id":"e7c576e.5663a88","type":"server","z":"","name":"HA - Automations","url":"http://localhost:8123","pass":"yourpassword"},{"id":"69a8824.8c4167c","type":"server","z":"","name":"HA - Main","url":"http://localhost:8123","pass":"yourpassword"}]

You may need to add a delay to turning off the light boolean after motion detection in case it is turned back on by the flow of light switch.

Thanks for all your help @jimpower ! You’re a legend!

I tweaked your last one a bit to get it working 100%.

  • I added a 5 second delay to the light boolean, because it was indeed turning on with the bottom sequence (like you said).
  • I removed the motion boolean off from the lower sequence as it was turning this off, even when the trigger was the motion.
  • Light switch halt entity is the Light boolean, not the switch directly.
  • Removed “halt if state: off” from the Switch in the bottom sequence, as the off trigger wasn’t coming through.
  • Removed the Switch turning itself On/off, as they are not needed.

Here is the final flow:

And for anyone wanting the code:

[{"id":"8cc2a8db.59dbd8","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"4e5e6da3.8a75b4","type":"switch","z":"8cc2a8db.59dbd8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":390,"y":310,"wires":[["4879bbf5.16eee4","f7475019.95049"],[]]},{"id":"f7475019.95049","type":"stoptimer","z":"8cc2a8db.59dbd8","duration":"10","units":"Second","payloadtype":"num","payloadval":"0","name":"","x":610,"y":330,"wires":[["a62f7504.7f4858"],[]]},{"id":"66b47b7a.927ec4","type":"api-call-service","z":"8cc2a8db.59dbd8","name":"OFF","server":"9582d396.920b1","service_domain":"switch","service":"turn_off","data":"{\"entity_id\": \"switch.plug_158d0001a68b97\"}","mergecontext":"","x":1260,"y":330,"wires":[[]]},{"id":"99136a52.8e2d48","type":"api-call-service","z":"8cc2a8db.59dbd8","name":"ON","server":"9582d396.920b1","service_domain":"switch","service":"turn_on","data":"{\"entity_id\": \"switch.plug_158d0001a68b97\"}","mergecontext":"","x":1260,"y":250,"wires":[[]]},{"id":"a23777e1.4ac7f8","type":"api-current-state","z":"8cc2a8db.59dbd8","name":"Already On?","server":"9582d396.920b1","halt_if":"on","override_topic":true,"override_payload":true,"entity_id":"switch.plug_158d0001a68b97","x":790,"y":270,"wires":[["99136a52.8e2d48","baf43cfa.8bb2e","b2321988.bc8fd8"]]},{"id":"eaa82eb5.ab02","type":"server-state-changed","z":"8cc2a8db.59dbd8","name":"Motion","server":"9582d396.920b1","entityidfilter":"binary_sensor.motion_sensor_158d00012cbb78","entityidfiltertype":"substring","haltifstate":"","x":190,"y":310,"wires":[["4e5e6da3.8a75b4"]]},{"id":"4879bbf5.16eee4","type":"time-range-switch","z":"8cc2a8db.59dbd8","name":"After Sunset?","lat":"-27.465328","lon":"153.024548","startTime":"sunsetStart","endTime":"sunrise","startOffset":"","endOffset":"","x":600,"y":270,"wires":[["a23777e1.4ac7f8"],[]]},{"id":"6e855221.f8275c","type":"server-state-changed","z":"8cc2a8db.59dbd8","name":"Light Switch","server":"9582d396.920b1","entityidfilter":"switch.plug_158d0001a68b97","entityidfiltertype":"exact","haltifstate":"","x":210,"y":440,"wires":[["4ca49a29.1b1c64"]]},{"id":"a62f7504.7f4858","type":"api-current-state","z":"8cc2a8db.59dbd8","name":"Still Motion?","server":"9582d396.920b1","halt_if":"on","override_topic":true,"override_payload":true,"entity_id":"binary_sensor.motion_sensor_158d00012cbb78","x":790,"y":330,"wires":[["871057b4.0715d8"]]},{"id":"4ca49a29.1b1c64","type":"switch","z":"8cc2a8db.59dbd8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":390,"y":440,"wires":[["a328cea1.dca05"],["64c9a1fc.198f6"]]},{"id":"871057b4.0715d8","type":"api-current-state","z":"8cc2a8db.59dbd8","name":"Light on from Switch?","server":"9582d396.920b1","halt_if":"on","override_topic":true,"override_payload":true,"entity_id":"input_boolean.light_manual","x":980,"y":330,"wires":[["66b47b7a.927ec4","496b28b6.375aa8"]]},{"id":"baf43cfa.8bb2e","type":"api-call-service","z":"8cc2a8db.59dbd8","name":"Boolean Motion On","server":"9582d396.920b1","service_domain":"input_boolean","service":"turn_on","data":"{\"entity_id\": \"input_boolean.light_auto\"}","mergecontext":"","x":1220,"y":210,"wires":[[]]},{"id":"496b28b6.375aa8","type":"api-call-service","z":"8cc2a8db.59dbd8","name":"Boolean Motion Off","server":"9582d396.920b1","service_domain":"input_boolean","service":"turn_off","data":"{\"entity_id\": \"input_boolean.light_auto\"}","mergecontext":"","x":1220,"y":290,"wires":[[]]},{"id":"a328cea1.dca05","type":"api-call-service","z":"8cc2a8db.59dbd8","name":"Boolean Light On","server":"9582d396.920b1","service_domain":"input_boolean","service":"turn_on","data":"{\"entity_id\": \"input_boolean.light_manual\"}","mergecontext":"","x":610,"y":420,"wires":[[]]},{"id":"64c9a1fc.198f6","type":"api-call-service","z":"8cc2a8db.59dbd8","name":"Boolean Light Off","server":"9582d396.920b1","service_domain":"input_boolean","service":"turn_off","data":"{\"entity_id\":\"input_boolean.light_manual\"}","mergecontext":"","x":610,"y":460,"wires":[[]]},{"id":"de84c6e8.e8dc08","type":"api-call-service","z":"8cc2a8db.59dbd8","name":"Boolean Light Off","server":"9582d396.920b1","service_domain":"input_boolean","service":"turn_off","data":"{\"entity_id\": \"input_boolean.light_manual\"}","mergecontext":"","x":1220,"y":170,"wires":[[]]},{"id":"b2321988.bc8fd8","type":"delay","z":"8cc2a8db.59dbd8","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1040,"y":170,"wires":[["de84c6e8.e8dc08"]]}]
3 Likes

Yeah I didn’t add your conditions as I figured you would be able to do that, glad you got it working I was in between family duties (if only I could automate that :wink:)

Does your motion change state quickly?, your timer is only 10secs but following this condition is to check if the motion is still on I’m guessing this is what is triggering the off part of the flow you could remove the timer if that is the case.

To test this just place a debug node after both these points to see if which is passing the msg first to the off command I suspect it waits 10 secs then has to wait another x amount of time for your pir to change its state anyway.

Thanks again.

I had the timer set to 10 seconds to test the flow. I forgot to change it before posting.
Plus I’m potentially using it with Xiaomi sensors that have a 2 minute time anyway.

I’ve gone from having to use a switch template, scripts, input booleans, and automation to only having to use 2 input booleans and one automation! Plus I can use the original switch which is a huge bonus.

Loving this nodered business!!

1 Like

Yeah since moving to node-RED I only did my more complex automatons but recently my normal automation’s had become really sluggish. I deployed node-RED on its own Rasp Pi 3b+ running HassOS and left all my ping and polling sensors on the original and now things like motion happens instantly instead of having a lag sometimes longer then I was in that room. I use the Xiaomi motion sensor to and I find it doesn’t change state back for at least 2mins so I needed to have my wait timer set longer than 2 mins.

Plus how good is being to debug your automation flows without needing to reboot which for me can take nearly 20 mins.

**Edit just saw that you mentioned 2 mins for motion :wink:

1 Like

Debug and deploy are the greatest!
I’ve brought over all my automations which I did myself after spending only 48 hours learning and understanding how nodered works.

Obviously this last one was slightly over my head. Lol.

1 Like

I have also moved all my automation to Node-red (just need to move the node-red on its own RPI3).

I have all my lights motion triggered by Xiaomy sensors (motion, door, button) than the lights stay on for a period of time (3-5min depending on room an day of time) before they switch off… this makes the live very easy :slight_smile:

Below is just the light section … looks more complex than it is :wink:

1 Like

Hi, can you explain me the logic (what is house light timer, are you able to change iut from the frontend?)

Yes, “House Light Timer” in fact all the timer are Input_select where I have configure default times to be selected from.

See below my sleep timer, in case you want to remember your last selection after reboot, you have to comment-out the “initial” parameter and activate “Recorder” in configuration.yaml

sleep_timer:
name: Sleep Timer
options:
  - 30
  - 60
  - 120
  - 180
  - 240
  - 300
  - 360
  - 600
  - 960
  - 1200
  - 1800
  - 2400
  - 3000
  - 3600 
#initial: 120
icon: mdi:timer

Check out my post about AppDaemon. I wrote an implementation for motion lights with usage examples.
Might give you some ideas or other things to try. Good luck.

my take on the whole thing…
An extra input boolean per room that i switch on whenever light is turned on by an automation.
Then when there is no movement anymore, the lights will first dim down, and then go out. Of course a motion will reset everything and also turning off a light manually works fine without it turning on again. Turning on a lamp manually will keep it on even if motion is happening. On top it checks for illuminance level and day or night mode.

[{“id”:“9589ba0f.dc4288”,“type”:“tab”,“label”:“Lights Kitchen”,“disabled”:false,“info”:“Turn Light on / off based on Illuminance, Motion, HouseMode”},{“id”:“7005d4b3.44676c”,“type”:“switch”,“z”:“9589ba0f.dc4288”,“name”:“”,“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“on”,“vt”:“str”},{“t”:“eq”,“v”:“off”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:350,“y”:240,“wires”:[[“154bc203.2e31be”],[“b6d21259.6101b”]]},{“id”:“40d9556.fa932ac”,“type”:“api-call-service”,“z”:“9589ba0f.dc4288”,“name”:“ON”,“server”:“2fba4297.e4145e”,“service_domain”:“light”,“service”:“turn_on”,“data”:“{"entity_id":"light.kuche","kelvin":"2700","brightness_pct":"100"}”,“render_data”:false,“mergecontext”:“”,“output_location”:“payload”,“output_location_type”:“msg”,“x”:1150,“y”:100,“wires”:[]},{“id”:“ecc5df4f.b28a3”,“type”:“api-current-state”,“z”:“9589ba0f.dc4288”,“name”:“Already On?”,“server”:“2fba4297.e4145e”,“halt_if”:“on”,“halt_if_type”:“str”,“halt_if_compare”:“is”,“override_topic”:true,“override_payload”:true,“override_data”:true,“entity_id”:“light.kuche”,“state_type”:“str”,“outputs”:1,“x”:750,“y”:140,“wires”:[[“4280096b.77b3c8”,“1a50be40.8d74a2”,“95672975.207a78”]]},{“id”:“50f142e.a3b2dbc”,“type”:“server-state-changed”,“z”:“9589ba0f.dc4288”,“name”:“Kitchen Motion”,“server”:“2fba4297.e4145e”,“entityidfilter”:“binary_sensor.kuche_motion”,“entityidfiltertype”:“substring”,“outputinitially”:false,“state_type”:“str”,“haltifstate”:“”,“halt_if_type”:“str”,“halt_if_compare”:“is”,“outputs”:1,“x”:200,“y”:240,“wires”:[[“7005d4b3.44676c”]]},{“id”:“154bc203.2e31be”,“type”:“api-current-state”,“z”:“9589ba0f.dc4288”,“name”:“Illuminance”,“server”:“2fba4297.e4145e”,“halt_if”:“120”,“halt_if_type”:“num”,“halt_if_compare”:“gt”,“override_topic”:true,“override_payload”:true,“override_data”:true,“entity_id”:“sensor.kuche_helligkeit”,“state_type”:“str”,“outputs”:1,“x”:570,“y”:200,“wires”:[[“ecc5df4f.b28a3”,“ad78ce1d.bcd6e”]]},{“id”:“ad7f7ccb.155b9”,“type”:“inject”,“z”:“9589ba0f.dc4288”,“name”:“”,“topic”:“”,“payload”:“on”,“payloadType”:“str”,“repeat”:“”,“crontab”:“”,“once”:false,“onceDelay”:0.1,“x”:350,“y”:120,“wires”:[[“154bc203.2e31be”]]},{“id”:“3122492d.3fc036”,“type”:“inject”,“z”:“9589ba0f.dc4288”,“name”:“”,“topic”:“”,“payload”:“off”,“payloadType”:“str”,“repeat”:“”,“crontab”:“”,“once”:false,“onceDelay”:0.1,“x”:350,“y”:180,“wires”:[[“b6d21259.6101b”]]},{“id”:“b6d21259.6101b”,“type”:“api-current-state”,“z”:“9589ba0f.dc4288”,“name”:“Manually switched?”,“server”:“2fba4297.e4145e”,“halt_if”:“off”,“halt_if_type”:“str”,“halt_if_compare”:“is”,“override_topic”:true,“override_payload”:true,“override_data”:true,“entity_id”:“input_boolean.kitchen”,“state_type”:“str”,“outputs”:1,“x”:590,“y”:260,“wires”:[[“df2fe012.81341”]]},{“id”:“4280096b.77b3c8”,“type”:“api-call-service”,“z”:“9589ba0f.dc4288”,“name”:“on automation toggle”,“server”:“2fba4297.e4145e”,“service_domain”:“input_boolean”,“service”:“turn_on”,“data”:“{"entity_id":"input_boolean.kitchen"}”,“render_data”:false,“mergecontext”:“”,“x”:1020,“y”:40,“wires”:[]},{“id”:“893c97f8.36fa18”,“type”:“api-current-state”,“z”:“9589ba0f.dc4288”,“name”:“Still Motion?”,“server”:“2fba4297.e4145e”,“halt_if”:“on”,“halt_if_type”:“str”,“halt_if_compare”:“is”,“override_topic”:true,“override_payload”:false,“override_data”:true,“entity_id”:“binary_sensor.kuche_motion”,“state_type”:“str”,“outputs”:1,“x”:1130,“y”:260,“wires”:[[“499259bd.013698”,“5f20a655.f5e7e8”]],“outputLabels”:[“on”]},{“id”:“1a6386a6.b60259”,“type”:“api-call-service”,“z”:“9589ba0f.dc4288”,“name”:“OFF”,“server”:“2fba4297.e4145e”,“service_domain”:“light”,“service”:“turn_off”,“data”:“{"entity_id":"light.kuche"}”,“render_data”:false,“mergecontext”:“”,“x”:1830,“y”:320,“wires”:[]},{“id”:“e22c0fe0.e894e”,“type”:“api-call-service”,“z”:“9589ba0f.dc4288”,“name”:“off automation toggle”,“server”:“2fba4297.e4145e”,“service_domain”:“input_boolean”,“service”:“turn_off”,“data”:“{"entity_id":"input_boolean.kitchen"}”,“render_data”:false,“mergecontext”:“”,“x”:1880,“y”:260,“wires”:[]},{“id”:“ad78ce1d.bcd6e”,“type”:“api-current-state”,“z”:“9589ba0f.dc4288”,“name”:“Automation running”,“server”:“2fba4297.e4145e”,“halt_if”:“off”,“halt_if_type”:“str”,“halt_if_compare”:“is”,“override_topic”:true,“override_payload”:true,“override_data”:true,“entity_id”:“input_boolean.kitchen”,“state_type”:“str”,“outputs”:1,“x”:770,“y”:200,“wires”:[[“df2fe012.81341”,“1a50be40.8d74a2”,“95672975.207a78”,“43192541.27efcc”]]},{“id”:“df2fe012.81341”,“type”:“stoptimer”,“z”:“9589ba0f.dc4288”,“duration”:“90”,“units”:“Second”,“payloadtype”:“num”,“payloadval”:“0”,“name”:“90sec”,“x”:970,“y”:260,“wires”:[[“893c97f8.36fa18”],]},{“id”:“bb95ec1.114df1”,“type”:“api-current-state”,“z”:“9589ba0f.dc4288”,“name”:“Still Motion?”,“server”:“2fba4297.e4145e”,“halt_if”:“on”,“halt_if_type”:“str”,“halt_if_compare”:“is”,“override_topic”:true,“override_payload”:true,“override_data”:true,“entity_id”:“binary_sensor.kuche_motion”,“state_type”:“str”,“outputs”:1,“x”:1650,“y”:260,“wires”:[[“e22c0fe0.e894e”,“1a6386a6.b60259”]]},{“id”:“499259bd.013698”,“type”:“api-current-state”,“z”:“9589ba0f.dc4288”,“name”:“still On?”,“server”:“2fba4297.e4145e”,“halt_if”:“off”,“halt_if_type”:“str”,“halt_if_compare”:“is”,“override_topic”:true,“override_payload”:true,“override_data”:true,“entity_id”:“light.kuche”,“state_type”:“str”,“outputs”:1,“x”:1340,“y”:200,“wires”:[[“1dc28306.1b8ead”,“6c56b8fd.f9ccb8”]]},{“id”:“1a50be40.8d74a2”,“type”:“api-current-state”,“z”:“9589ba0f.dc4288”,“name”:“Day Mode”,“server”:“2fba4297.e4145e”,“halt_if”:“Tag”,“halt_if_type”:“str”,“halt_if_compare”:“is_not”,“override_topic”:true,“override_payload”:true,“override_data”:true,“entity_id”:“input_select.mode”,“state_type”:“str”,“outputs”:1,“x”:990,“y”:100,“wires”:[[“40d9556.fa932ac”]]},{“id”:“95672975.207a78”,“type”:“api-current-state”,“z”:“9589ba0f.dc4288”,“name”:“Night Mode”,“server”:“2fba4297.e4145e”,“halt_if”:“Nacht”,“halt_if_type”:“str”,“halt_if_compare”:“is_not”,“override_topic”:true,“override_payload”:true,“override_data”:true,“entity_id”:“input_select.mode”,“state_type”:“str”,“outputs”:1,“x”:990,“y”:160,“wires”:[[“3591db7f.915d34”]]},{“id”:“3591db7f.915d34”,“type”:“api-call-service”,“z”:“9589ba0f.dc4288”,“name”:“ON”,“server”:“2fba4297.e4145e”,“service_domain”:“light”,“service”:“turn_on”,“data”:“{"entity_id":"light.kitchen_top","color_name":"red","brightness_pct":"25"}”,“render_data”:false,“mergecontext”:“”,“x”:1150,“y”:160,“wires”:[]},{“id”:“1dc28306.1b8ead”,“type”:“api-current-state”,“z”:“9589ba0f.dc4288”,“name”:“Tag Mode”,“server”:“2fba4297.e4145e”,“halt_if”:“Tag”,“halt_if_type”:“str”,“halt_if_compare”:“is_not”,“override_topic”:true,“override_payload”:true,“override_data”:true,“entity_id”:“input_select.mode”,“state_type”:“str”,“outputs”:1,“x”:1520,“y”:140,“wires”:[[“76b87490.acd23c”]]},{“id”:“6c56b8fd.f9ccb8”,“type”:“api-current-state”,“z”:“9589ba0f.dc4288”,“name”:“Nacht Mode”,“server”:“2fba4297.e4145e”,“halt_if”:“Nacht”,“halt_if_type”:“str”,“halt_if_compare”:“is_not”,“override_topic”:true,“override_payload”:true,“override_data”:true,“entity_id”:“input_select.mode”,“state_type”:“str”,“outputs”:1,“x”:1530,“y”:200,“wires”:[[“19cfca2f.0d2ec6”]]},{“id”:“76b87490.acd23c”,“type”:“api-call-service”,“z”:“9589ba0f.dc4288”,“name”:“ON”,“server”:“2fba4297.e4145e”,“service_domain”:“light”,“service”:“turn_on”,“data”:“{"entity_id":"light.kuche","kelvin":"2700","brightness_pct":"50"}”,“render_data”:false,“mergecontext”:“”,“x”:1690,“y”:140,“wires”:[]},{“id”:“19cfca2f.0d2ec6”,“type”:“api-call-service”,“z”:“9589ba0f.dc4288”,“name”:“ON”,“server”:“2fba4297.e4145e”,“service_domain”:“light”,“service”:“turn_on”,“data”:“{"entity_id":"light.kitchen_top","color_name":"red","brightness_pct":"10"}”,“render_data”:false,“mergecontext”:“”,“x”:1690,“y”:200,“wires”:[]},{“id”:“43192541.27efcc”,“type”:“template”,“z”:“9589ba0f.dc4288”,“name”:“cancel”,“field”:“payload”,“fieldType”:“msg”,“format”:“handlebars”,“syntax”:“plain”,“template”:“cancel”,“output”:“str”,“x”:1110,“y”:220,“wires”:[[“5f20a655.f5e7e8”]],“inputLabels”:[“on”],“outputLabels”:[“stop”]},{“id”:“5f20a655.f5e7e8”,“type”:“mytimeout”,“z”:“9589ba0f.dc4288”,“name”:“30sec”,“outtopic”:“”,“outsafe”:" “,“outwarning”:”“,“outunsafe”:“off”,“warning”:”“,“timer”:“30”,“debug”:false,“ndebug”:true,“ignoreCase”:false,“repeat”:false,“again”:false,“x”:1330,“y”:260,“wires”:[[“7239e6d1.887788”],]},{“id”:“7239e6d1.887788”,“type”:“switch”,“z”:“9589ba0f.dc4288”,“name”:”“,“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“off”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:1,“x”:1470,“y”:260,“wires”:[[“bb95ec1.114df1”]]},{“id”:“2fba4297.e4145e”,“type”:“server”,“z”:”",“name”:“Home Assistant”,“legacy”:false,“hassio”:true,“rejectUnauthorizedCerts”:true,“ha_boolean”:“y|yes|true|on|home|open”}]![lights|690x134]

Check out my appdaemon app for this. I’m porting it to a native HA component.
It does what you are asking for.

This looks awesome! Does it work with time of day or can it be integrated based on the sunset / sunrise?

the HA component does not support sunset/sunrise yet. I am working on it. :slight_smile:
I recommend you adopt v2 which is made for HA (no AppDaemon required) as that will be the way forward.

I am trying something similar. But instead of stopping the motion I want to just override the brightness value. Right now I have the motion trigger the bathroom light to turn on at 20% brightness and turn off after 20 minutes of no activity. But say my wife is doing her make up and she turns the light full brightness when the motion triggers it turns it back down to 20%. Is there a way to:
Trigger motion to set light to 20% and keep motion timer but if light is manually set brighter when motion is triggered again keep light at that brightness until next time the automation runs? This way it would still shut off when no motion runs and turn on too 20% on motion but it wont dim the light on us we need it brighter.

This is untested but might give you an idea on how to accomplish what you’re trying to do.

[{"id":"dd22ce89.ab8f2","type":"server-state-changed","z":"ffbd7f06.4a014","name":"Motion","server":"2dad33ee.42bf5c","entityidfilter":"sensor.motion","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":130,"y":416,"wires":[["4e9a21f6.a6ba2","5c2354d1.c1ee3c"]]},{"id":"4e9a21f6.a6ba2","type":"trigger","z":"ffbd7f06.4a014","op1":"","op2":"0","op1type":"nul","op2type":"str","duration":"20","extend":false,"units":"min","reset":"","bytopic":"all","name":"","x":294,"y":464,"wires":[["35842f55.0dd4e"]]},{"id":"5c2354d1.c1ee3c","type":"change","z":"ffbd7f06.4a014","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"brightness_pct","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":304,"y":416,"wires":[["5818c9cb.df0098"]]},{"id":"5818c9cb.df0098","type":"api-call-service","z":"ffbd7f06.4a014","name":"","server":"2dad33ee.42bf5c","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"lilght.bathroom_light\",\"brightness_pct\":\"{{payload}}\"}","render_data":true,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":506,"y":416,"wires":[[]]},{"id":"35842f55.0dd4e","type":"api-call-service","z":"ffbd7f06.4a014","name":"","server":"2dad33ee.42bf5c","service_domain":"light","service":"turn_off","data":"{\"entity_id\":\"lilght.bathroom_light\"}","render_data":false,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":506,"y":464,"wires":[["5e19b1a5.43596"]]},{"id":"d9f27b0c.b02738","type":"server-state-changed","z":"ffbd7f06.4a014","name":"","server":"2dad33ee.42bf5c","entityidfilter":"light.bathrrom_light","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"off","halt_if_type":"str","halt_if_compare":"is","outputs":2,"x":220,"y":528,"wires":[["f191d5b8.3e2e88"],[]]},{"id":"f191d5b8.3e2e88","type":"change","z":"ffbd7f06.4a014","name":"","rules":[{"t":"set","p":"bathroom_brightness","pt":"flow","to":"data.attributes.brightness_pct","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":504,"y":528,"wires":[[]]},{"id":"5e19b1a5.43596","type":"change","z":"ffbd7f06.4a014","name":"","rules":[{"t":"set","p":"bathroom_brightness","pt":"flow","to":"20","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":744,"y":464,"wires":[[]]},{"id":"6ef8c58d.a0b89c","type":"inject","z":"ffbd7f06.4a014","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":166,"y":368,"wires":[["698c21df.fcca4"]]},{"id":"698c21df.fcca4","type":"change","z":"ffbd7f06.4a014","name":"","rules":[{"t":"set","p":"brightness_pct","pt":"flow","to":"20","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":356,"y":368,"wires":[[]]}]

Thank you for the help! It looks close! I get an API error on the light turn on svc.

I’m far from expert, but it seems sometimes the service homeassistant.turn_on works when light.turn_on doesn’t.

For me they tend to work interchangeably, but I’ve seen others comment on it.