#Check if windows/doors open if AC/HEAT on Send message of which are open.

1 messages · Page 1 of 1 (latest)

autumn grotto
#
alias: HVAC Warning
description: ""
trigger:
  - platform: device
    device_id: 6d06b040d205c45c4670360cafae872b
    domain: climate
    entity_id: 0ca52937a8390e85104ffe95833963c2
    type: hvac_mode_changed
    to: cool
  - platform: device
    device_id: 6d06b040d205c45c4670360cafae872b
    domain: climate
    entity_id: 0ca52937a8390e85104ffe95833963c2
    type: hvac_mode_changed
    to: heat
condition:
  - type: is_open
    condition: device
    device_id: 8bd004479cc4ca9f47707c1c3fff7867
    entity_id: 78977c6f7016bdefa7077e1c4e6c4ecf
    domain: binary_sensor
  - type: is_open
    condition: device
    device_id: 8bd004479cc4ca9f47707c1c3fff7867
    entity_id: b8a314e84e6091a43c5d6bea523bbbad
    domain: binary_sensor
action:
  - service: notify.all_devices
    data:
      message: The kitchen window is open.
mode: single
worldly flame
#

you've also been here long enough to know how to format things when posting

autumn grotto
#

You're too fast.

worldly flame
#

your condition is and

#

so, you can just list them manually

#

or just say "both are open"

#

because that's how your automation is written, both have to be open for the notification to occur

autumn grotto
#

is there an or?

worldly flame
#

Yes

autumn grotto
#

I have 16 contacts to check that was just a sample of two how would you go about that?

worldly flame
#

I'd use templates for both

#

what are the entity_ids?

autumn grotto
#

sensor.ttgo_poe_001_zone_01_sensor

#

sensor.ttgo_poe_001_zone_02_sensor

#

etc

worldly flame
#

ok

#

that makes it easier

#

16 of them?

autumn grotto
#

yes

#

oh but some will not be included

#

as 1 controls a doorbell contact

#

and another is the garage door which is not in the house hvac area

worldly flame
#
alias: HVAC Warning
description: ""
trigger:
  - platform: device
    device_id: 6d06b040d205c45c4670360cafae872b
    domain: climate
    entity_id: 0ca52937a8390e85104ffe95833963c2
    type: hvac_mode_changed
    to: cool
  - platform: device
    device_id: 6d06b040d205c45c4670360cafae872b
    domain: climate
    entity_id: 0ca52937a8390e85104ffe95833963c2
    type: hvac_mode_changed
    to: heat
variables:
  entities: >
    [{% for i in range(1, 17) %}sensor.ttgo_poe_001_zone_{{ '%02i'%i }}_sensor{% endfor %}]
  open: >
    {{ entities | select('is_state', 'on') | map('state_attr', 'friendly_name') | sort }}
condition:
  - condition: template
    value_template: "{{ open | count > 0 }}"
action:
  - service: notify.all_devices
    data:
      message: "The following windows are open: {{ open | join(', ') }}"
mode: single
autumn grotto
#

say zone 3 is the doorbell and 7/8 are the garage door

#

Is there a way to add like an array that would contain the sensors we only want to evaluate [{% for i in range(1, 17)

#

{1,2,4,5,6,9,10,11,12,13,14,16} etc

worldly flame
#

that's what this does

#

you have 16 zones right?

autumn grotto
#

yes 16 zones some are not to be checked against

worldly flame
#

why?

autumn grotto
#

One of the zones is a contact strapped to a door bell dinger

worldly flame
#

if you have a list of the numbers you don't want to check, post them

autumn grotto
#

Posted above

#

in that array like number line above

worldly flame
#

[{% for i in [1,2,4,5,6,9,10,11,12,13,14,16] %}sensor.ttgo_poe_001_zone_{{ '%02i'%i }}_sensor{% endfor %}]

autumn grotto
#

3 7 8 15 are missing from the array that are not to be checked for

#

Perfect thank you

#

When you add two things in an automation like at the top there where it list heat and cooling does this mean it's going to check if one or the other or it's saying if both are activated then it will trigger

worldly flame
#

triggers are 'or'

#

essentially

autumn grotto
#

For the message is it going to output the number it found open or it's going to say the name ie like zone 1 ideally I want to add custom names like "kitchen window" would I just add that to the entity name and the above code would take care of reading that into the message?

worldly flame
#

it's going to say custom names

autumn grotto
#

How would I add so that it also does the check if someone opens the windows while it's on?

worldly flame
#

while what's on

autumn grotto
#

AC/Heat

#

(Nest Thermostat)

worldly flame
#

make a separate automation that uses the binary sensors as the trigger and conditions that check heat/cool

#

you can use the same variables to notify which windows are open

autumn grotto
#
alias: HVAC If window/door gets opened send warning message
description: ""
trigger:
  - type: opened
    platform: device
    device_id: 8bd004479cc4ca9f47707c1c3fff7867
    entity_id: 78977c6f7016bdefa7077e1c4e6c4ecf
    domain: binary_sensor
  - type: opened
    platform: device
    device_id: 8bd004479cc4ca9f47707c1c3fff7867
    entity_id: b8a314e84e6091a43c5d6bea523bbbad
    domain: binary_sensor
  - type: opened
    platform: device
    device_id: 8bd004479cc4ca9f47707c1c3fff7867
    entity_id: 4f71b5632c68a4915d0060ad9b63c08f
    domain: binary_sensor
  - type: opened
    platform: device
    device_id: 8bd004479cc4ca9f47707c1c3fff7867
    entity_id: 5c8ac63938843f27e2cf9214ad0ffc79
    domain: binary_sensor
  - type: opened
    platform: device
    device_id: 8bd004479cc4ca9f47707c1c3fff7867
    entity_id: 0c7a0f45f3ddc96de0e39b712dacb51f
    domain: binary_sensor
  - type: opened
    platform: device
    device_id: 8bd004479cc4ca9f47707c1c3fff7867
    entity_id: d14767b5e9a52daba41863a60c79405c
    domain: binary_sensor
  - type: opened
    platform: device
    device_id: 8bd004479cc4ca9f47707c1c3fff7867
    entity_id: e02dbaabc660aa6f61b62dcd0ce32458
    domain: binary_sensor
variables:
  entities: >
    [{% for i in [1,2,4,5,6,9,10,11,12,13,14,16] %}sensor.ttgo_poe_001_zone_{{ '%02i'%i }}_sensor{% endfor %}]
  open: >
    {{ entities | select('is_state', 'on') | map('state_attr', 'friendly_name') | sort }}
condition:
  - condition: device
    device_id: 6d06b040d205c45c4670360cafae872b
    domain: climate
    entity_id: 0ca52937a8390e85104ffe95833963c2
    type: is_hvac_mode
    hvac_mode: cool
  - condition: device
    device_id: 6d06b040d205c45c4670360cafae872b
    domain: climate
    entity_id: 0ca52937a8390e85104ffe95833963c2
    type: is_hvac_mode
    hvac_mode: heat
action:
  - service: notify.all_devices
    data:
      message: "The following windows are open: {{ open | join(', ') }}"
mode: single
worldly flame
#

you need to add the variables I put in from the other automation

autumn grotto
#

Like that?

worldly flame
#

yeah

autumn grotto
#

Thank you

worldly flame
#

np

autumn grotto
#

So I opened the door the trace timeline shows this

Triggered by the state of binary_sensor.ttgo_poe_001_zone_03 at June 4, 2024 at 3:58:36 PM
Test Dining Room is set to a specific HVAC mode
Test Dining Room is set to a specific HVAC mode
Stopped because a condition failed at June 4, 2024 at 3:58:36 PM (runtime: 0.00 seconds)

#

Is that saying it wasn't able to check if it was on heating or cooling

#
In Dining Room
Device info
Thermostat
by Google Nest

Controls
Dining Room
Cooling (Cool) 23.8 °C
Currently: 25.8 °C

Sensors
Humidity
49%
Temperature
25.8 °C
#

Doesn't seem like it gets to send out the message at that point

worldly flame
#

post the trace for the automation

#

click the 3 dots and download trace, share here

autumn grotto
#

Are threads locked for file transfer and pictures?

worldly flame
autumn grotto
worldly flame
#

oops

#

change

#

  entities: >
    [{% for i in [1,2,4,5,6,9,10,11,12,13,14,16] %}sensor.ttgo_poe_001_zone_{{ '%02i'%i }}_sensor,{% endfor %}]
#

was missing important comma

#

wait, still missing things

#
  entities: >
    [{% for i in [1,2,4,5,6,9,10,11,12,13,14,16] %}"sensor.ttgo_poe_001_zone_{{ '%02i'%i }}_sensor",{% endfor %}]
#

that should work now

autumn grotto
#

Triggered by the state of binary_sensor.ttgo_poe_001_zone_03 at June 4, 2024 at 4:17:37 PM
Test Dining Room is set to a specific HVAC mode
Test Dining Room is set to a specific HVAC mode
Stopped because a condition failed at June 4, 2024 at 4:17:37 PM (runtime: 0.00 seconds)
Will paste the trace in a second

#

oops 3 is the door were using to test but not scanning for

#

in the array

#

5 was the door bell will change

#

Still no luck

worldly flame
#

Are they sensors or binary_sensors?

autumn grotto
#

They say domain binary_sensor

#

esphome

binary_sensor:
- platform: template
    name: Zone 03
    id: zone_03
    device_class: door
    lambda: return (id(zone_03_str).state != "OK");
  - platform: template
    name: Zone 03 Tamper
    id: zone_03_tamper
    device_class: tamper
    lambda: |-
      if ((id(zone_03_str).state == "Tamper") || (id(zone_03_str).state == "Short")) {
        return true;
      } else {
        return false;
      }
sensor:
  - platform: template
    name: "Zone 03 Sensor"
    id: zone_03_int
    icon: "${sensor_icon}"
    on_value:
      # When Zone state (1-4) changes, set effect if Lights enabled, Set Text State
      - lambda: |-
          std::string out_state[] = {"Unset","${alarm_state1}","${alarm_state2}","${alarm_state3}","${alarm_state4}" };
          int y = (int) x;
          id(zone_03_str).publish_state(out_state[y]);
worldly flame
#

Yes, then change the template from sensor to binary_sensor

autumn grotto
#
  entities: >
    [{% for i in [1,2,4,5,6,9,10,11,12,13,14,16] %}"binary_sensor.ttgo_poe_001_zone_{{ '%02i'%i }}_sensor",{% endfor %}]
worldly flame
#

Yep

autumn grotto
#

binary_sensor.ttgo_poe_001_zone_03

#

so I dropped _sensor off the end as well

#

still failed 😦

#

does it still use is_state for a binary_sensor?

worldly flame
#

Your last trace shows it working

autumn grotto
#

Hmm no message went out could it be because I didn't set any friendly names yet?

worldly flame
#

did you use or for your condition, your second condition is failing so conditions are failing

autumn grotto
#

In the webui I don't see a way to set "or" specifically thought you said above that if they are in the list that is assumed OR ?

worldly flame
#

lists are and

#

for conditions

autumn grotto
#

Oh you can select an or from the condition

#

Do I put both of them under the "or" condition or that would then be "Nothing OR heat AND cool"?

#
condition:
  - condition: or
    conditions:
      - condition: device
        device_id: 6d06b040d205c45c4670360cafae872b
        domain: climate
        entity_id: 0ca52937a8390e85104ffe95833963c2
        type: is_hvac_mode
        hvac_mode: heat
      - condition: device
        device_id: 6d06b040d205c45c4670360cafae872b
        domain: climate
        entity_id: 0ca52937a8390e85104ffe95833963c2
        type: is_hvac_mode
        hvac_mode: cool
#

Is this OR heat AND cool

#

or is it

condition:
  - condition: device
    device_id: 6d06b040d205c45c4670360cafae872b
    domain: climate
    entity_id: 0ca52937a8390e85104ffe95833963c2
    type: is_hvac_mode
    hvac_mode: cool
  - condition: or
    conditions:
      - condition: device
        device_id: 6d06b040d205c45c4670360cafae872b
        domain: climate
        entity_id: 0ca52937a8390e85104ffe95833963c2
        type: is_hvac_mode
        hvac_mode: heat

Condition: OR
heat
OR
cool

#

I put them both under the OR Condition and it seems to be working

#

Should I change the trigger to an OR list as well

#

Guess it doesn't have an or function in trigger

#

So the trigger list are OR's, The "and if conditions" are ANDs unless you specify an OR condition.