Climate - Turn off AC when Door Opens for Extended Period

- id: '12-test--1599803262053'

  alias: '12-test--test ac '

  description: ''

  

  trigger:

    - platform: state

      entity_id:

        - binary_sensor.front_door_open_or_closed_contact

        - binary_sensor.kitchen_window_contact

        - binary_sensor.big_salon_window_contact

      to: 'on'

      for: '00:03:00'

  condition:

  - condition: and

    conditions:

    - condition: state

      entity_id: device_tracker.yuval_phone

      state: home

    - condition: state

      entity_id: input_boolean.disable_climate

      state: 'off'

  action:

  - choose:

    - conditions: []

      sequence:

      - data:

          message: ' has been opened for about 3 minutes and The A/C turn off so close

            the door.'

        service: notify.mobile_app_sm_a705fn

      - delay: '00:01:00'

      - choose:

        - conditions:

          - condition: state

            entity_id: binary_sensor.big_salon_window_contact

            state: 'on'

          - condition: or

            conditions:

            - condition: state

              entity_id: binary_sensor.front_door_open_or_closed_contact

              state: 'on'

            - condition: or

              conditions:

              - condition: state

                entity_id: binary_sensor.kitchen_window_contact

                state: 'on'

          sequence:

          - data: {}

            entity_id: script.turn_off_salon_ac

            service: script.turn_on

          - data:

              message: A/C turned OFF

            service: notify.mobile_app_sm_a705fn 

    default: []

  mode: single

Hello everyone,

I am trying to do for some sensors as a condition and not working, possible help

I put one condition in the sensor and it works fine

###########################################################

# Turn off AC when Door Opens for Extended Period         #

###########################################################

- id: 'Climate - Turn off AC when Door Opens for Extended Period'

  alias: 'Climate - Turn off AC when Door Opens for Extended Period'

  trigger:

    - platform: state

      entity_id:

        - binary_sensor.front_door_open_or_closed_contact

        - binary_sensor.kitchen_window_contact

        - binary_sensor.big_salon_window_contact

      to: 'on'

      for: '00:03:00'

  condition:

  - condition: and

    conditions:

    - condition: state

      entity_id: device_tracker.yuval_phone

      state: home

    - condition: state

      entity_id: input_boolean.disable_climate

      state: 'off'

  action:

  - choose:

    - conditions: []

      sequence:

      - data:

          message: ' has been opened for about 3 minutes and The A/C turn off so close

            the door.'

        service: notify.mobile_app_sm_a705fn

      - delay: '00:01:00'

      - choose:

        - conditions:

          - condition: state

            entity_id: binary_sensor.big_salon_window_contact

            state: 'on'

          sequence:

          - data: {}

            entity_id: script.turn_off_salon_ac

            service: script.turn_on

          - data:

              message: A/C turned OFF - Big Salon Window Open 

            service: notify.mobile_app_sm_a705fn 

        - conditions:

          - condition: state

            entity_id: binary_sensor.front_door_open_or_closed_contact

            state: 'on'

          sequence:

          - data: {}

            entity_id: script.turn_off_salon_ac

            service: script.turn_on

          - data:

              message: A/C turned OFF - Front Door Open

            service: notify.mobile_app_sm_a705fn 

        - conditions:

          - condition: state

            entity_id: binary_sensor.kitchen_window_contact

            state: 'on'

          sequence:

          - data: {}

            entity_id: script.turn_off_salon_ac

            service: script.turn_on

          - data:

              message: A/C turned OFF - Kitchen Window Open

            service: notify.mobile_app_sm_a705fn          

    default: []

  mode: single

I was able to run but how can I make the automation smarter?

help :slightly_frowning_face:

Could you please clarify what the problem is now/what you mean by smarter? The automations have had so many updates that yes, we probably can make it smarter. :slight_smile:

Ok I’ll try to explain.
Thank you first! for the help. :slight_smile:

I found the

I did exact what is listed here.
It seems right to me to make a timer for 3 min.

But I want to send a message for each open sensor and not one large group.

I can’t write out the syntax now (mobile), but I would keep your triggers and conditions the same.

In the actions, use a wait for trigger on the trigger.entity_id going to closed, and a continue on timeout to false. Then you can send the message, using a choose block like you have using the trigger.entity_id to change the message. You can also set this automations run mode to parallel to let it run for multiple windows at once.

Also, are you on the latest version of home assistant? Take a look at the extensive release notes on all of the automation changes.

I’m in the latest version of the system.

I was unable to do proper automation.
I’ll wait for you to get to the computer :slight_smile:

I’m happy to have an excuse to use these new features. Be warned it may not be for a day or two because I have to get some projects done!

Here is my stab at it. I tweaked your sensor and scipt names further down because I was in a rush, so you’ll certainly have to fix that. I’m also almost certain that there is some syntacitcal or illegal thing in here, but hopefully you can debug it.

automation:
  - trigger:
      - platform: state
        entity_id: 
        - binary_sensor.front_door_open_or_closed_contact
        - binary_sensor.kitchen_window_contact
        - binary_sensor.big_salon_window_contact
      to: 'on'
      for: '00:03:00'
  condition:
  - condition: and
    conditions:
    - condition: state
      entity_id: device_tracker.yuval_phone
      state: home
    - condition: state
      entity_id: input_boolean.disable_climate
      state: 'off'
    action:
      - wait_for_trigger:
          - platform: state
            entity_id: "{{ trigger.entity_id }}"
            to: "off"
        timeout: 60
        continue_on_timeout: false
      - choose:
          - conditions:
              - condition: template
                value_template: "{{ trigger.entity_id == 'binary_sensor.front_door_open_or_closed_contact' }}"
            sequence:
              - variables:
                opening: Front Door
                ac: script.turn_off__front_door
          - conditions:
              - condition: template
                value_template: "{{ trigger.entity_id == 'binary_sensor.salon' }}"
            sequence:
              - variables:
                opening: Salon
                ac: script.turn_off_salon_ac
          - conditions:
              - condition: template
                value_template: "{{ trigger.entity_id == 'binary_sensor.kitchen' }}"
            sequence:
              - variables:
                opening: Salon
                ac: script.turn_off_kitchen_ac
      - service: script.turn_on
        data:
          - entity_id: "{{ ac }}"
      - service: notify.mobile_app_sm_a705fn 
        data:
          - message: The {{opening}} is open. The ac has been turned off.
1 Like

thank you for help.

i managed to get something , what you think?
,

  • id: Security - window or door open after leaving home
    alias: Security - window or door open after leaving home
    trigger:
    platform: state
    entity_id: input_boolean.yuval_away
    to: ‘on’

    condition:

    • condition: state
      entity_id: group.door_and_window_all_livng_room
      state: ‘on’

    action:
    data_template:
    message: >
    You left your house, pay attention still open: {{ states | selectattr(‘entity_id’,‘in’, state_attr(‘group.door_and_window_all_livng_room’,‘entity_id’)) | selectattr(‘state’,‘eq’,‘on’) | map(attribute=‘name’) | join(’, ') }}
    service: telegram_bot.send_message
    mode: single
    ,
    the automation work so well ,
    it gives me names sensor open from group :))

hello
i really what to work with your code
bat system do not know number of code
for example;

ac…opening…

can you help me one more time