Window open climate off - using wildcards (SOLVED)

Hey there.

I need your help.

What I’m trying to archive is to have a simple node-red „window open, climate off automation“, but with one simple automation, using wildcards.

Everywhere I look around, people doing it all one by one - specifying every room, every window and every thermostat in single automations.
Having an office, a brothers-home, a parents-home and an own Home makes things really annoying (even with Blueprints).

So basically taking the Area of a window-magnet to choose in which Area to turn off the climate.
Ideally restoring it’s old value after closing the window.
And also ideally choosing the name from that window-magnet for the cover to open (if named the same), so let some fresh air in.

So I thought maybe you guys have done something like this already or maybe it’s interesting enough for you to build? :slight_smile:

Long story short
something like

If: window.{Bedroom_Front} in area.{Bedroom} gets opened
do: turn_off climate in area.{Bedroom} and (if closed) open cover.{Bedroom_Front} to 30%

thanks

This is assuming you have an area set for each device/entity and the all the windows sensors have their device_class set to window.

image

[{"id":"744b9f1935875b62","type":"server-events","z":"892eaca92f0b4509","name":"","server":"","version":2,"eventType":"state_changed","exposeToHomeAssistant":false,"eventData":"{\"new_state\":  {\"state\": \"on\", \"attributes\": { \"device_class\": \"window\"}}}","haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"$outputData(\"eventData\").event.new_state","valueType":"jsonata"},{"property":"template","propertyType":"msg","value":"\"{{ area_id('\" & $outputData(\"eventData\").entity_id & \"')}}\"","valueType":"jsonata"}],"event_type":"","x":244,"y":1104,"wires":[["ca4b9b28e27c1efd"]]},{"id":"ca4b9b28e27c1efd","type":"api-render-template","z":"892eaca92f0b4509","name":"get entities for area","server":"","version":0,"template":"","resultsLocation":"payload","resultsLocationType":"msg","templateLocation":"template","templateLocationType":"msg","x":454,"y":1104,"wires":[["39633f7c67c42b88","eb0b34b5c95576b3"]]},{"id":"39633f7c67c42b88","type":"api-call-service","z":"892eaca92f0b4509","name":"turn off climate","server":"","version":5,"debugenabled":false,"domain":"climate","service":"turn_off","areaId":["{{payload}}"],"deviceId":[],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":672,"y":1104,"wires":[[]]},{"id":"eb0b34b5c95576b3","type":"api-call-service","z":"892eaca92f0b4509","name":"open covers","server":"","version":5,"debugenabled":false,"domain":"cover","service":"set_cover_position","areaId":["{{payload}}"],"deviceId":[],"entityId":[],"data":"{\"position\": 30}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":662,"y":1152,"wires":[[]]}]
1 Like

thank you! that works incredible!

for anyone else who wants to use it, my final result (basically only copied above for window-closed and added sun.sun: below_horizon for opening the covers)

[{"id":"59c7f851f774ae47","type":"tab","label":"Global Window Open","disabled":false,"info":"","env":[]},{"id":"744b9f1935875b62","type":"server-events","z":"59c7f851f774ae47","name":"Window Opened","server":"bae62b83.87c628","version":2,"eventType":"state_changed","exposeToHomeAssistant":false,"eventData":"{\"new_state\":  {\"state\": \"on\", \"attributes\": { \"device_class\": \"window\"}}}","haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"$outputData(\"eventData\").event.new_state","valueType":"jsonata"},{"property":"template","propertyType":"msg","value":"\"{{ area_id('\" & $outputData(\"eventData\").entity_id & \"')}}\"","valueType":"jsonata"}],"event_type":"","x":245,"y":220,"wires":[["ca4b9b28e27c1efd"]]},{"id":"ca4b9b28e27c1efd","type":"api-render-template","z":"59c7f851f774ae47","name":"get entities for area","server":"bae62b83.87c628","version":0,"template":"","resultsLocation":"payload","resultsLocationType":"msg","templateLocation":"template","templateLocationType":"msg","x":475,"y":220,"wires":[["39633f7c67c42b88","92dc067bd4f2369b"]]},{"id":"39633f7c67c42b88","type":"api-call-service","z":"59c7f851f774ae47","name":"turn off climate","server":"bae62b83.87c628","version":5,"debugenabled":false,"domain":"climate","service":"turn_off","areaId":["{{payload}}"],"deviceId":[],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":693,"y":220,"wires":[[]]},{"id":"8bb71ad5d4996322","type":"server-events","z":"59c7f851f774ae47","name":"Window Closed","server":"bae62b83.87c628","version":2,"eventType":"state_changed","exposeToHomeAssistant":false,"eventData":"{\"new_state\":  {\"state\": \"off\", \"attributes\": { \"device_class\": \"window\"}}}","haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"$outputData(\"eventData\").event.new_state","valueType":"jsonata"},{"property":"template","propertyType":"msg","value":"\"{{ area_id('\" & $outputData(\"eventData\").entity_id & \"')}}\"","valueType":"jsonata"}],"event_type":"","x":250,"y":485,"wires":[["684756f832d6aa4f"]]},{"id":"684756f832d6aa4f","type":"api-render-template","z":"59c7f851f774ae47","name":"get entities for area","server":"bae62b83.87c628","version":0,"template":"","resultsLocation":"payload","resultsLocationType":"msg","templateLocation":"template","templateLocationType":"msg","x":470,"y":485,"wires":[["4540aff8a2bb80e3","a9612e0bfd6c82b5"]]},{"id":"4540aff8a2bb80e3","type":"api-call-service","z":"59c7f851f774ae47","name":"turn off climate","server":"bae62b83.87c628","version":5,"debugenabled":false,"domain":"climate","service":"turn_on","areaId":["{{payload}}"],"deviceId":[],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":708,"y":485,"wires":[[]]},{"id":"78dd80c123f6f2c9","type":"api-call-service","z":"59c7f851f774ae47","name":"open covers","server":"bae62b83.87c628","version":5,"debugenabled":false,"domain":"cover","service":"close_cover","areaId":["{{payload}}"],"deviceId":[],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":880,"y":560,"wires":[[]]},{"id":"a2a04479af5713ba","type":"api-call-service","z":"59c7f851f774ae47","name":"open covers","server":"bae62b83.87c628","version":5,"debugenabled":false,"domain":"cover","service":"set_cover_position","areaId":["{{payload}}"],"deviceId":[],"entityId":[],"data":"{\"position\": 10}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":870,"y":285,"wires":[[]]},{"id":"92dc067bd4f2369b","type":"api-current-state","z":"59c7f851f774ae47","name":"is night?","server":"bae62b83.87c628","version":3,"outputs":2,"halt_if":"below_horizon","halt_if_type":"str","halt_if_compare":"is","entity_id":"sun.sun","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":635,"y":325,"wires":[["a2a04479af5713ba"],[]]},{"id":"a9612e0bfd6c82b5","type":"api-current-state","z":"59c7f851f774ae47","name":"is night?","server":"bae62b83.87c628","version":3,"outputs":2,"halt_if":"below_horizon","halt_if_type":"str","halt_if_compare":"is","entity_id":"sun.sun","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":685,"y":560,"wires":[["78dd80c123f6f2c9"],[]]},{"id":"bae62b83.87c628","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"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","enableGlobalContextStore":true}]