Radiator on and door/window open - help with multiple rooms

I think you can add each one as a list under entity_id and the use a template for the alert message.
Let me see if I can dig out my low disk space alert, that should point you in the right direction.

- alias: 'Alert On Disk space issues via pushbullet'
  initial_state: 'on'
  trigger:
      entity_id:
        - sensor.ssh_disk_used
        - sensor.jackett_disk_used
        - sensor.downloader_storage_used
        - sensor.downloader_disk_used
      above: 80
  action:
    - service: notify.james
      data_template:
        message: "Server {{ trigger.entity_id }} is low on space"
        title: "Disk Space Issues {{ trigger.entity_id }}"

The formatting might be little messed up as copy and pasta on my phone seems to have issues with yaml…

2 Likes

That’s easy if you just want a general announcement that one of the entities is a trigger.

But the problems come when you want to try to compare a specific trigger against a specific condition of a different entity.

Such as if the office door is open and the office radiator is on its a problem. But if the office door is open but only the library radiator is on then the office door being open is ok.

1 Like

I see,
If your getting to that level you might want to look at nodered, as you can start doing really crazy things there.

1 Like

Dude, check Node RED, I wasted so much time not doing that :slight_smile:

Of course it is nice to learn about YAML and HA but if you want to become effective and productive, give it a try.

1 Like

thanks man
any good places to start with node red?

A good start could be this for example:

And for more complex stuff help here in the forum is great, as usual :wink:

1 Like

AppDaemon also works really well for more compex automations.

1 Like

thanks.
another idea i have had, which is maybe “easier” (as i dont know node red)…

create a seperate “group” for each combination of doors/windows & rads.
eg. “living rooms”, “bedroom”, “study” etc…
then, put all the groups withing a master “group”

trigger the condition off this group and pull out the room name from the master group, which trigger it.

this might work?

ok, i think ive got it?

first, i created a binary_sensor for all my rads, so that i know if they are on/off (the doors/windows already have this).
then i create a group for each room, which is only “on” if all rads + doors/windows are “on” (all: true). note: this doesnt take into account if you have multiple doors/windows per room at this point, so not sure what you would want to do in this situaiton?

then i created a “super group”, which has all my rooms in it.

with an auotmation now, i can get it to tell me which is on and what room.

now ive tested this a bit, but im not 100% sure if its correct?
also, once i know its working, i will set a 1min timer, so it doesnt pop if you just open a door/window quickly for whatever reason.

binary_sensor:
  - platform: template
    sensors:
      rad_boolean_jamie_office:
        friendly_name: "Radiator Boolean Jamie Office"
        value_template: '{{state_attr("climate.jamie_office","hvac_action") == "heating"}}'
      rad_boolean_b_office:
        friendly_name: "Radiator Boolean B Office"
        value_template: '{{state_attr("climate.b_office","hvac_action") == "heating"}}'
      rad_boolean_en_suite:
        friendly_name: "Radiator Boolean en_suite"
        value_template: '{{state_attr("climate.en_suite","hvac_action") == "heating"}}'
groups:
heating_group_jamie_office:
  name: heating group jamie office 
  all: true
  entities:
    - binary_sensor.mps_jamie_office_door_contact
    - binary_sensor.rad_boolean_jamie_office

heating_group_b_office:
  name: heating group b office 
  all: true
  entities:
    - binary_sensor.mps_b_office_window_contact
    - binary_sensor.rad_b_briony_office

heating_group_ensuite_office:
  name: heating group ensuite office 
  all: true
  entities:
    - binary_sensor.mps_en_suite_window_contact
    - binary_sensor.rad_boolean_en_suite

all_heating_groups:
  name: All Heating Groups 
  entities: 
    - group.heating_group_jamie_office
    - group.heating_group_b_office
    - group.heating_group_ensuite_office
automations:
- alias: rad_on_something_open_alert
  trigger:
  - platform: state
    entity_id:
    - group.all_heating_groups
    to: 'on'
    #for:
      #minutes: 1
  action:
  - service: persistent_notification.create
    data_template:
      message: "{% set open = states.group\n   |selectattr('entity_id','in',state_attr('group.all_heating_groups','entity_id'))\n\
        \   |selectattr('state','eq','on')\n   |map(attribute='name')|list %}\n{{\
        \ open|join(', ') }} {{ 'are' if open|length > 1 else 'is' }} open and \
        \ the rad is on!\n"
      title: Heating Alert!
  - service: notify.notify
    data_template:
      message: "{% set open = states.group\n   |selectattr('entity_id','in',state_attr('group.all_heating_groups','entity_id'))\n\
        \   |selectattr('state','eq','on')\n   |map(attribute='name')|list %}\n{{\
        \ open|join(', ') }} {{ 'are' if open|length > 1 else 'is' }} open and \
        \ the rad is on!\n"
      title: Heating Alert!

1 Like

How about a Bayesian sensor ?
That way if one item is on/true it can out weigh all the other items.
Tho I’m not sure how you could then have an alert on which one it is.

Just read that you’ve solved it.
https://www.home-assistant.io/integrations/bayesian/

Glad you got it working but as an unrelated question…

Did you write your templates by hand or use an editor?

I ask because if you wrote them by hand then you don’t need to put all of the newlines in there if you write them as a multi-line template. And it makes them easier to read as well.

for example you could do it like this with each section on its own line:

data_template:
  message: >
    {% set open = states.group | selectattr('entity_id','in',state_attr('group.all_heating_groups','entity_id')) | selectattr('state','eq','on') | map(attribute='name') | list %}
    {{ open|join(', ') }} {{ 'are' if open|length > 1 else 'is' }} open and the rad is on!

or to make a bit more easy to read you could also do this:

data_template:
  message: >
    {% set open = states.group 
      | selectattr('entity_id','in',state_attr('group.all_heating_groups','entity_id')) 
      | selectattr('state','eq','on') 
      | map(attribute='name') 
      | list %}
    {{ open|join(', ') }} {{ 'are' if open|length > 1 else 'is' }} open and the rad is on!

thanks for the tip
wrote everything by hand.

what editor would you recommend?

I personally use Notepad++.

I’ve heard VSCode is good and it has a HA plugin for autocomplete using HA entities and a yaml syntax highlighter.

what editor would you recommend?

If you’re using hassio I really recommend the IDE Cloud 9 addon. Built in SSH terminal, flexible layouts, image previewer, YAML highlighting. I can use it from work where I can’t install any other software.

I used to use VSCode on Windows, it’s very good too. Really bummed it doesn’t run on a RPi. Notepad++ is really decent too. Nice and lightweight. Very fast.

1 Like

Thanks for your great solution.
Just FYI, I’ve done the same but I’ve created a binary sensor for each room that includes all the windows & doors of that room, so my heating_group (actually, AC_group) includes the binary sensor of the AC + the binary sensor of the room open/close status…
So I’ve got:
room open binary_sensor (all windows & doors for that room)
ac_boolean binary_sensor (like you did)
ac_room group (the room open + ac_boolean for the room, on only if all are on)
all_ac_groups (like you did)
Works like a charm, so thank you very much :slight_smile:

1 Like

Hi,

there could be a way to avoid the groups.
Have a look at What the heck it is not possible to use area in automations and vote. :wink:

Nice! Can you share your yaml as an example please!?

I only use Bayesian sensor for my sensor of me being home or not, as i use rather complex nodered flow for turning the heating on based on whether my daughters room is cold and the door is close, or if my wife is home (as she like it warmer than me in the house)

  - platform: bayesian
    prior: 0.5
    probability_threshold: 0.9
    name: 'J Home'
    observations:
      - entity_id: 'device_tracker.j_wifi'
        prob_given_true: 0.50
        prob_given_false: 0.09
        platform: 'state'
        to_state: 'home'
      - entity_id: 'device_tracker.j_app'
        prob_given_true: 0.50
        prob_given_false: 0.09
        platform: 'state'
        to_state: 'home'
      - entity_id: 'sensor.j_ble'
        prob_given_true: 0.99
        prob_given_false: 0.05
        platform: 'numeric_state'
        above: 85
1 Like

very cool! thanks for sharing