Turn off a room and don't trigger an automation for a light in the room

I have an automation to turn off a specific light whenever the TV is turned on.

I have another automation that reverses this (light on when TV switched off).

This works great until I turn the whole room off with Google. The TV turns off as part of the “Hey Google, turn off the living room” comand and so, that turns on the light. Leaving me in a state where the whole room is off except this one light.

I could use a time condition but that seems pretty brittle. I could check for other lights being off but that’s also brittle (and there could be race-conditions if check in the same room).

What I’m trying to work out is how to say something like:

“Turn on the light when the TV is turned off UNLESS the room is being turned off”.

I found Turn on light for X minutes, but not off when manually turned on but that doesn’t help as much as I’d hoped.

Any ideas on how to accomplish this? I think I’m stuck at the conceptual level.

Is the “Hey Google, turn off the living room” command calling an automation?

No it’s not. I think I would have to say “activate turn off the living room” in that case. I could use a scene but, with both, I’d need to manually create a Google Home Routine (which stupidly can’t be shared) so would only work for me and not the rest of my household.

Perhaps if I can store the state of the light when the TV turns on, and restore that when the TV turns off.

So if it was already off it would restore the previous state and so keep it turned off.

Not sure if this is possible. Might have to look into Node-Red for that. And there still might be race conditions.

I’ve come up with a solution in Node Red that seems to work ok.

I’ve detached the light in question from all scenes. Instead, because it’s one of a pair, I used Node Red to essentially mirror the other light of the pair (A) to this light (B).

This took some doing but, now, whenever light A changes brightness or colour (as part of a scene) light B does too (maybe half a second slower but almost not noticeable) and so appears to be part of the scene.

Then I added conditions and triggers based on the state of the TV and, with a delay when the TV is turned off, light B checks the state of light A and if A is off then B stays off. Of light A is on, then light B inherits those values.

EDIT: Added a screenshot and flow export.

[{"id":"cb35bb6f.a82188","type":"tab","label":"TV Automated Lights","disabled":false,"info":""},{"id":"42acd639.14e948","type":"server-state-changed","z":"cb35bb6f.a82188","name":"Living Room TV","server":"63df8a1.7750374","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"media_player.living_room_tv","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,"x":200,"y":420,"wires":[["dc8b5866.317c78"]]},{"id":"fe5f603b.156a4","type":"api-call-service","z":"cb35bb6f.a82188","name":"Turn Off Near Uplighter","server":"63df8a1.7750374","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.near_uplighter","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1010,"y":360,"wires":[[]]},{"id":"dc8b5866.317c78","type":"switch","z":"cb35bb6f.a82188","name":"On / Off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":380,"y":360,"wires":[["fe5f603b.156a4"],["fdc8ad2a.ddf98"]],"outputLabels":["On","Off"]},{"id":"2584bc03.654764","type":"api-current-state","z":"cb35bb6f.a82188","name":"Far Uplighter State","server":"63df8a1.7750374","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.far_uplighter","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":490,"y":480,"wires":[["fe5f603b.156a4"],["58bfe17d.1232d"]],"outputLabels":["Light Off","Light On"]},{"id":"3183128a.4a35fe","type":"trigger-state","z":"cb35bb6f.a82188","name":"Far Uplighter Changes State","server":"63df8a1.7750374","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"light.far_uplighter","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"entity_id","targetValue":"media_player.living_room_tv","propertyType":"property","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off","propertyValue":"state"}],"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":240,"y":480,"wires":[["2584bc03.654764"],[]]},{"id":"58bfe17d.1232d","type":"switch","z":"cb35bb6f.a82188","name":"Detect Hue Color Descriptor","property":"data.attributes.color_temp","propertyType":"msg","rules":[{"t":"nnull"},{"t":"null"}],"checkall":"true","repair":false,"outputs":2,"x":740,"y":480,"wires":[["5059b83c.19ce78"],["94213d36.70661"]]},{"id":"5059b83c.19ce78","type":"api-call-service","z":"cb35bb6f.a82188","name":"Uplighter On (Temp)","server":"63df8a1.7750374","version":1,"debugenabled":true,"service_domain":"light","service":"turn_on","entityId":"light.near_uplighter","data":"{\t   \"brightness\": payload.brightness,\t   \"color_temp\": data.attributes.color_temp \t}","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1000,"y":420,"wires":[[]],"info":"color_temp"},{"id":"94213d36.70661","type":"api-call-service","z":"cb35bb6f.a82188","name":"Uplighter On (RGB)","server":"63df8a1.7750374","version":1,"debugenabled":true,"service_domain":"light","service":"turn_on","entityId":"light.near_uplighter","data":"{\t   \"brightness\": data.attributes.brightness,\t   \"rgb_color\": data.attributes.rgb_color\t}","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":990,"y":480,"wires":[[]],"info":"color_temp"},{"id":"fdc8ad2a.ddf98","type":"delay","z":"cb35bb6f.a82188","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":460,"y":420,"wires":[["2584bc03.654764"]]},{"id":"63df8a1.7750374","type":"server","name":"Home Assistant","addon":true}]
1 Like