For quite a while I have had the ability to tell Alexa “Turn off everything in [room name]” and she would turn a select number of lights/devices off. The way I was doing it was by creating a group within Alexa called “Everything in [room name]” but that got to be a pain when changes on the home automation side caused devices to drop off in Alexa. While the devices were easily added back into Alexa, they were not automatically added back to the groups. This issue was prevalent when I was using SmartThings given the number of times I had to exclude/include devices thus causing then to drop off the groups.
Now that I am using the far better Home Assistant platform and Node Red, I set out to find a way to have the same functionality without having to bother configuring stuff in Alexa (their app is so insanely poor!!). To do this I created a Help called “Everything in Office” and a few groups of lights/devices to limit the number of individual devices I need to work with in Node Red.
I am aware that many nodes, if not all, allow me to put multiple devices so they can all be turned on/off but that makes it harder for me to see what is being turned on/off so I use a node per device. If this creates inefficiencies or additional mesh traffic, please let me know.
My first attempt is below… it works but it is fairly complicated to replicate for all the rooms so I wonder whether there is an easier way to accomplish it.
The basics are that the 4 events: state
nodes are 3 groups and a ceiling fan feed into the BooleanLogic Ultimate node (Gate 4). If any of the 4 nodes are on, then I turn on the “Everything in Office” helper. On the contrary, if ALL of the groups/devices are off, I turn the helper off.
Although it would appear that Alexa sends the on/off command to HA to toggle the helper regardless of its state, I prefer to actually make it reflect the correct state of things as this may break in the future or could simply be confusing to troubleshoot.
When the helper is toggled off, Node Red will turn off all the desired devices. Here I already see an issue as I really only need to actually turn off all the devices if I am issuing the command to do so via Alexa. If it is the node turning the helper off, it is doing so because all the devices are already off.
Adding a check to confirm that a device being turned off is actually on is easy but this is getting messy. Since I have to replicate this at least 13 times, likely more, I would like it to be as simple as possible.
I do not want to use HA’s room/area to toggle stuff, assuming it is possible (I haven’t looked into it), as it would toggle a lot of other devices that I do NOT want to toggle. In other words, when I leave a room and want to turn everything off, I actually only want to turn off all lights and devices that are normally off (like a TV, amplifier, table lamps, etc) but not outlets, for example, that are always on by default.
I’d love to get feedback on how to make this more efficient, simpler, better… etc.
[{"id":"bbffc5cda9d68280","type":"server-state-changed","z":"10166deaea152eef","name":"Everything in Office","server":"6f1799ba.17e938","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.everything_in_office","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":190,"y":400,"wires":[[],["3ab480d337c9ab2e"]]},{"id":"d09b6890bf67f12b","type":"link in","z":"10166deaea152eef","name":"Office Devices","links":["3ab480d337c9ab2e"],"x":790,"y":400,"wires":[["0059890465bd4959","646dc692a9c20197","e64d0e6fa0447b3c","dbc43c2176b8a809"]],"l":true},{"id":"3ab480d337c9ab2e","type":"link out","z":"10166deaea152eef","name":"Office","mode":"link","links":["d09b6890bf67f12b","eff68d7bc73d5c11"],"x":390,"y":400,"wires":[],"l":true},{"id":"eff68d7bc73d5c11","type":"link in","z":"10166deaea152eef","name":"Office Lights","links":["3ab480d337c9ab2e"],"x":790,"y":320,"wires":[["a28cba1c514b8aa9"]],"l":true},{"id":"0059890465bd4959","type":"api-call-service","z":"10166deaea152eef","name":"Office Fan >> off","server":"6f1799ba.17e938","version":5,"debugenabled":false,"domain":"fan","service":"turn_off","areaId":[],"deviceId":["d0af55ea5c082ccdeb12a040568bd88a"],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1070,"y":400,"wires":[[]]},{"id":"8ba1bf4b04a2c47d","type":"api-call-service","z":"10166deaea152eef","name":"Everything in Office >> on","server":"6f1799ba.17e938","version":5,"debugenabled":false,"domain":"input_boolean","service":"turn_on","areaId":[],"deviceId":[],"entityId":["input_boolean.everything_in_office"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1090,"y":160,"wires":[[]]},{"id":"4514201f600dcce4","type":"api-call-service","z":"10166deaea152eef","name":"Everything in Office >> off","server":"6f1799ba.17e938","version":5,"debugenabled":false,"domain":"input_boolean","service":"turn_off","areaId":[],"deviceId":[],"entityId":["input_boolean.everything_in_office"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":830,"y":220,"wires":[[]]},{"id":"a2c7f6a82cf8a37b","type":"server-state-changed","z":"10166deaea152eef","name":"All Office Lights","server":"6f1799ba.17e938","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.all_office_lights","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"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":200,"y":100,"wires":[["dfc615faed066153"]]},{"id":"a28cba1c514b8aa9","type":"api-call-service","z":"10166deaea152eef","name":"All Office Lights >> off","server":"6f1799ba.17e938","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.all_office_lights"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1080,"y":320,"wires":[[]]},{"id":"646dc692a9c20197","type":"api-call-service","z":"10166deaea152eef","name":"Shedder >> off","server":"6f1799ba.17e938","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":["64d2b9e52a20dc821dd33d4775261001"],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1060,"y":460,"wires":[[]]},{"id":"e64d0e6fa0447b3c","type":"api-call-service","z":"10166deaea152eef","name":"Office Workbench Instruments >> off","server":"6f1799ba.17e938","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.office_workbench_instruments"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1130,"y":520,"wires":[[]]},{"id":"d74e84904e0e94ce","type":"server-state-changed","z":"10166deaea152eef","name":"Office Workbench Instruments","server":"6f1799ba.17e938","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.office_workbench_instruments","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"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":160,"y":160,"wires":[["dfc615faed066153"]]},{"id":"be62367e21db59aa","type":"server-state-changed","z":"10166deaea152eef","name":"Office Workbench Tools","server":"6f1799ba.17e938","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.office_workbench_tools","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"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":180,"y":220,"wires":[["dfc615faed066153"]]},{"id":"dbc43c2176b8a809","type":"api-call-service","z":"10166deaea152eef","name":"Office Workbench Tools >> off","server":"6f1799ba.17e938","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.office_workbench_tools"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1110,"y":580,"wires":[[]]},{"id":"dfc615faed066153","type":"BooleanLogicUltimate","z":"10166deaea152eef","name":"","filtertrue":"both","persist":true,"sInitializeWith":"WaitForPayload","triggertopic":"trigger","outputtriggeredby":"all","inputCount":"4","topic":"result","restrictinputevaluation":false,"delayEvaluation":0,"x":450,"y":180,"wires":[[],["cd31d796426aff4d"],[]]},{"id":"cd31d796426aff4d","type":"switch","z":"10166deaea152eef","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":630,"y":180,"wires":[["28157b391a5ca02f"],["4514201f600dcce4"]]},{"id":"28157b391a5ca02f","type":"api-current-state","z":"10166deaea152eef","name":"Everything in Office - off?","server":"6f1799ba.17e938","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.everything_in_office","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":830,"y":160,"wires":[["8ba1bf4b04a2c47d"],[]]},{"id":"f6cd1d66f4fc34de","type":"comment","z":"10166deaea152eef","name":"Everything in Office","info":"","x":150,"y":40,"wires":[]},{"id":"d8b527059a253b90","type":"server-state-changed","z":"10166deaea152eef","name":"Office Fan","server":"6f1799ba.17e938","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"fan.office_fan","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"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":220,"y":280,"wires":[["dfc615faed066153"]]},{"id":"0af74fc6eca18837","type":"comment","z":"10166deaea152eef","name":"Ignore shredder. Good to turn off but no need to track","info":"","x":300,"y":340,"wires":[]},{"id":"6f1799ba.17e938","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}]
Edit: Being able to turn ON the lights/devices in the “Everything in Office” group is of little to no use in my case… so if the solution doesn’t allow it, even better.
Edit2: Google appears to have a super annoying “feature” that interprets “Everything in [room name]” as all the devices it knows are in that room so it turns literally everything on/off which I certainly do NOT want. A work around was to remove rooms from Google and just let it see the devices but when I recently re-activated device sharing with Google, I noticed that Home Assistant provides the rooms too… any way to fix this??
Edit3: The link in/out nodes are unnecessary, I know. I used them initially as a way to make this a bit cleaner as I thought it was going to be quite messy otherwise. I’ll likely get rid of them.