###########################################################
# 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?
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.
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.
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.
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 :))