Help with resuming Automation on State Change? - Ductless AC

Good morning all!

I have four Carrier Ductless Mini-Splits installed in my home and they are connected to HA. I have it set up so that the heads turn on and off based on the ecobee thermostats in each of the rooms.

For efficiency and sanity, I also have it monitoring for the state of the windows and doors in the house. If the AC or Heat is running and a door or window is opened, it shuts off the Heat or AC. This is working perfectly fine. What I cannot figure out, though, is how to trigger it to resume the Heat or AC upon the doors or windows being closed again.

I would like some assistance from you wonderful people. Below is one of the automations (hopefully formatted correctly):

alias: Kitchen Carrier Controls
description: Handles Heat/Cool modes and set-points for the Kitchen
trigger:
  - alias: AC On Over 74
    platform: device
    device_id: ffde3966021fd46b417b11031e7fc459
    domain: climate
    entity_id: 0256d4dc8f58b32843a9b1cee1666cd7
    type: current_temperature_changed
    id: ac_on
    above: 74
  - alias: AC Off Below 72
    platform: device
    device_id: ffde3966021fd46b417b11031e7fc459
    domain: climate
    entity_id: 0256d4dc8f58b32843a9b1cee1666cd7
    type: current_temperature_changed
    id: ac_off
    below: 72
  - alias: Heat On Below 64
    platform: device
    device_id: ffde3966021fd46b417b11031e7fc459
    domain: climate
    entity_id: 0256d4dc8f58b32843a9b1cee1666cd7
    type: current_temperature_changed
    id: heat_on
    below: 64
  - alias: Heat Off Over 68
    platform: device
    device_id: ffde3966021fd46b417b11031e7fc459
    domain: climate
    entity_id: 0256d4dc8f58b32843a9b1cee1666cd7
    type: current_temperature_changed
    id: heat_off
    above: 68
  - platform: state
    entity_id:
      - binary_sensor.house_windows_doors
    to: "on"
    id: door_open
condition: []
action:
  - choose:
      - conditions:
          - condition: and
            conditions:
              - condition: trigger
                id:
                  - ac_on
              - condition: state
                entity_id: input_select.carrier_mode
                state: Cool
              - condition: numeric_state
                entity_id: climate.kitchen_carrier
                above: 72
                attribute: current_temperature
        sequence:
          - device_id: c09dbff29c67d22d14b8539b179007bc
            domain: climate
            entity_id: 7b6ff5533eed9e3fef3dec67c4f0466d
            type: set_hvac_mode
            hvac_mode: cool
          - metadata: {}
            data:
              temperature: 72
            target:
              entity_id:
                - climate.kitchen_carrier
            action: climate.set_temperature
        alias: AC On
      - conditions:
          - condition: and
            conditions:
              - condition: trigger
                id:
                  - ac_off
                  - door_open
        sequence:
          - device_id: c09dbff29c67d22d14b8539b179007bc
            domain: climate
            entity_id: 7b6ff5533eed9e3fef3dec67c4f0466d
            type: set_hvac_mode
            hvac_mode: "off"
        alias: AC Off
      - conditions:
          - condition: and
            conditions:
              - condition: trigger
                id:
                  - heat_on
              - condition: state
                entity_id: input_select.carrier_mode
                state: Heat
              - condition: numeric_state
                entity_id: climate.kitchen_carrier
                below: 68
                attribute: current_temperature
        sequence:
          - device_id: c09dbff29c67d22d14b8539b179007bc
            domain: climate
            entity_id: 7b6ff5533eed9e3fef3dec67c4f0466d
            type: set_hvac_mode
            hvac_mode: heat
          - metadata: {}
            data:
              temperature: 68
            target:
              entity_id:
                - climate.kitchen_carrier
            action: climate.set_temperature
        alias: Heat On
      - conditions:
          - condition: and
            conditions:
              - condition: trigger
                id:
                  - heat_off
                  - door_open
        sequence:
          - device_id: c09dbff29c67d22d14b8539b179007bc
            domain: climate
            entity_id: 7b6ff5533eed9e3fef3dec67c4f0466d
            type: set_hvac_mode
            hvac_mode: "off"
        alias: Heat Off
mode: single

If anyone is looking to do the same, I have implemented a scene creation before the units are turned off. I used the link below to create the automation that handles this.

You need to add a trigger for the binary_sensor.house_windows_doors going to off.

I’d also look at getting rid of the device ids and making everything work off of entity ids.

Also consider what happens if you lose connectivity to the ecobee or if the ecobee stops sending updates for a long period of time. Does the heat run forever?

Usually with doors and windows I add a delay before turning the hvac off. Such that opening the door to step outside doesn’t turn it off, but leaving the door open for 10 minutes does.

I also have a bias towards never turning the heat off, I may set the thermostat back if the door is open and send a notification - since turning the heat off in the winter could cause pipes to freeze up - I don’t want a malfunctioning automation or sensor to cause this problem. Whereas with AC there is less of a downside if something does wrong.

Some of your automation can be accomplished using the generic thermostat integration.

Hey Pete, thank you for responding. I do have a trigger for the windows and doors. I agree about the necessity to change to entity ids, and that is something I plan to change today. Thank you for drawing attention to that.

It is funny you bring up the risk of what happens with lack of responsiveness because that happened just this morning and the AC was continuing to run. What do you use to mitigate risk there? Tie to a series of sensors in the room and use an helper to average it?

Excellent point around the delay. I’ll incorporate that today too.

With respect to the heat shutting off, this is a secondary heat system that only turns on when main floor heating is not working well enough. I might be able to use your suggestion as a second level of security against heat issues.

Having looked at the generic tstat integration, can you help me understand what parts of the automation could be helped? I didn’t see much there that I could make use of, but I know a lot of what you can do in HA is really limited by our own imagination. Thank you for your help!

Regarding the temperature sensor. The approaches usually are integration specific. In an ideal world the integration should make the sensor unavailable if communication is lost. You’ll want to test that by removing power from the ecobee and determine how long it takes to become unavailable. If it doesn’t then that is a bug that should be reported. So when your sensor goes unavailable you can turn the heat pumps off.

Additionally, I’ve seen sensors get “stuck” where while they are “online” they fail to send updates. I have an Aeotec zwave multisensor that does this whenever there is a power fluctuation. For this sensor I use the zwavejs events to drive a template that records the last time a sensor reading was received. Since the sensor is configured to send every 10 minutes, if it hasn’t been heard from in 21 minutes (10 minutes * 210%) a binary sensor template (e.x. Living_room_temperature_online) turns off and triggers automations.

I like this approach to the determination of an entity or sensor being “down”. Would you mind sharing your template that you use for this purpose so I can learn from it, please? Though I feel good about my ability in HA, Templates are still black magic to me.

Thank you for everything

Sure. This is very zwave integration specific. A challenge with temperatures is they often don’t change so looking for a state change may yield false positives when the temperature is stable for a while. In contrast this event trigger triggers whenever an update is received from the sensor regardless of whether the value changed.

template:
  - trigger:
      - platform: homeassistant
        event: start
      - platform: zwave_js.value_updated
        entity_id:
          - sensor.basement_temperature
        command_class: 49
        property: Air temperature
    sensor:
      - name: "zw_basement_sensor_last_updated"
        state: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }} "
binary_sensor:
  - platform: template
    sensors:
      zw_basement_sensor_online:
        value_template: >-
          {{ ( 1600 - (states('sensor.zw_basement_sensor_latency') | int(0))) > 0  and

               states('sensor.basement_sensor_node_status') != 'dead' and
               states('sensor.basement_sensor_node_status') != 'unavailable' and
               states('sensor.basement_sensor_node_status') != 'unknown'
          }}

This is fantastic, thank you so much