Hey all
Just looking for feedback on this automation. Basically its our AC automation when we are sleeping.
The trigger is if the temperature is between 18-23 and its between 9pm-3am, then do one of the following
Option 1: if temp above 23, turn on ac
Option 2: if temp below 18, turn off ac
Option 3: if the time is 3am, then turn off ac
alias: >-
[Climate] Cool Mode On | Master Bedroom | Bedtime | Below 18-Above 23 | 21:00
- 03:00 | Or After 3am AC Off
description: ''
trigger:
- type: temperature
platform: device
device_id: a0d34c0c8dd5fa0bd3eef242d5516c77
entity_id: sensor.master_bedroom_climate_temperature
domain: sensor
above: 18
for:
hours: 0
minutes: 0
seconds: 0
below: 23
condition:
- condition: time
after: input_datetime.after_9pm
before: input_datetime.before_3am
action:
- choose:
- conditions:
- condition: numeric_state
entity_id: sensor.master_bedroom_climate_temperature
above: '23'
- condition: time
after: input_datetime.after_9pm
before: input_datetime.before_3am
sequence:
- service: script.ac_cool_mode_bedtime
data: {}
- service: notify.mobile_app_brad_s_phone
data:
message: Master Bedroom Bedtime Cool Mode On
- conditions:
- condition: numeric_state
entity_id: sensor.master_bedroom_climate_temperature
below: '18'
- condition: time
after: input_datetime.after_9pm
before: input_datetime.before_3am
sequence:
- service: script.ac_all_zones_closed_and_off
data: {}
- service: notify.mobile_app_brad_s_phone
data:
message: Master Bedroom Bedtime Cool Mode Off
- conditions:
- condition: time
after: input_datetime.after_3am
sequence:
- service: script.ac_all_zones_closed_and_off
data: {}
- service: notify.mobile_app_brad_s_phone
data:
message: Master Bedroom Bedtime Cool Mode Off
default: []
mode: single
Is there a problem with the automation?
not that im aware of, just seeing if it can be done better as i have alot of other use cases to setup
Got it. I’ve done similar things with dehumidifiers, e.g. turn on at X% turn off when drops to Y%.
A couple of thoughts
- have an input_boolean to enable / disable the control. For example, if you are away you may want this logic not to run.
- the Generic Thermostat - Home Assistant may be able to do a lot of this for free and you get UI. You’d then have an automation that turns cool mode off at 3 am, on at 9.
I found when sending setpoints to HVAC controls like NEST, it would sometimes drop them or toss an exception that would cause the automation to terminate. Likewise with zwave thermos (but a lot less often), so I implemented retries.
- id: set bedroom temperature
alias: set bedroom temperature
description: ""
mode: queued
max: 2
max_exceeded: silent
trigger:
- platform: state
entity_id: sensor.bedroom_target_temperature
- platform: state
entity_id: input_boolean.hvac_bedroom_control
to: "on"
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.hvac_bedroom_control
state: "on"
- condition: template
value_template: '{{ states("sensor.bedroom_target_temperature")|int > 57 }}'
- condition: template
value_template: '{{ states("sensor.bedroom_target_temperature")|int < 72 }}'
variables:
target_temperature: '{{ states("sensor.bedroom_target_temperature")|int }}'
action:
- service: system_log.write
data:
level: info
message: "Setting bedroom_thermostat temperature to {{ target_temperature }} in 1 minute"
logger: hvac
- delay: "00:01:00"
- service: script.climate_set_temperature
data:
entity_id: climate.bedroom_thermostat
temperature: "{{ target_temperature }}"
- delay: "00:00:05"
- condition: template
value_template: '{{ target_temperature != state_attr("climate.bedroom_thermostat","temperature") | int }}'
- service: system_log.write
data:
level: warning
message: "Unable to set bedroom_thermostat temperature to {{ target_temperature }} - retrying in 10 seconds"
logger: hvac
- delay: "00:00:10"
- service: script.climate_set_temperature
data:
entity_id: climate.bedroom_thermostat
temperature: "{{ target_temperature }}"
- delay: "00:00:05"
- condition: template
value_template: '{{ target_temperature != state_attr("climate.bedroom_thermostat","temperature") | int }}'
- service: system_log.write
data:
level: error
message: "Failed to set bedroom_thermostat temperature to {{ target_temperature }} "
logger: hvac
Ahh i dont understand what im doing when i use templates or copy someones elese lol
could I use person away trigger between those times?? so if we are both away then it shouldnt run?