As part of the earlier post regarding Home Assistant notification automation cheaper electricity Nordpool, I have made an automation with adaptive heating based on the outdoor temperature and electricity prices. It can be used as a base for your own automation but should be adjusted to your own liking. We our self have a comfort temperature of 23 degrees C indoor.
I have planed to add weather forecast into the adaptive automation. We have water based heating that is very slow, and on sunny days there are some problem with excess heat. So we could benefit of reducing the heating on sunny days.
Heating automation:
# Heating state
- alias: Heating state
id: heating_state
trigger:
- platform: homeassistant
event: start
- platform: time_pattern
minutes: 1
- platform: state
entity_id: group.all_people
to: 'home'
- platform: state
entity_id: group.all_people
to: 'away'
- platform: state
entity_id: input_boolean.vacation_mode
to: 'on'
- platform: state
entity_id: input_boolean.vacation_mode
to: 'off'
action:
- choose:
# Temperature below 24.9c outside and vacation mode set heating to 18
- conditions:
- condition: and
conditions:
- condition: state
entity_id: group.all_people
state: 'not_home'
- condition: state
entity_id: input_boolean.vacation_mode
state: 'on'
- condition: numeric_state
entity_id: sensor.garden_motion_sensor_temperature
below: 24.9
sequence:
- service: climate.set_temperature
entity_id: climate.living_room_thermostat
data:
hvac_mode: 'heat'
temperature: 18
- service: climate.set_temperature
entity_id: climate.office_thermostat
data:
hvac_mode: 'heat'
temperature: 18
- service: climate.set_temperature
entity_id: climate.hallway_thermostat
data:
hvac_mode: 'heat'
temperature: 18
- service: climate.set_temperature
entity_id: climate.bathroom_thermostat
data:
hvac_mode: 'heat'
temperature: 18
- service: climate.set_temperature
entity_id: climate.attic_thermostat
data:
hvac_mode: 'heat'
temperature: 18
- service: climate.set_temperature
entity_id: climate.main_bathroom_thermostat
data:
hvac_mode: 'heat'
temperature: 18
# Temperature below 24.9c outside and users away set heating to 22
- conditions:
- condition: and
conditions:
- condition: state
entity_id: group.all_people
state: 'not_home'
- condition: state
entity_id: input_boolean.vacation_mode
state: 'off'
- condition: numeric_state
entity_id: sensor.garden_temperature
below: 24.9
sequence:
- service: climate.set_temperature
entity_id: climate.living_room_thermostat
data:
hvac_mode: 'heat'
temperature: 22
- service: climate.set_temperature
entity_id: climate.office_thermostat
data:
hvac_mode: 'heat'
temperature: 20
- service: climate.set_temperature
entity_id: climate.hallway_thermostat
data:
hvac_mode: 'heat'
temperature: 20
- service: climate.set_temperature
entity_id: climate.bathroom_thermostat
data:
hvac_mode: 'heat'
temperature: 22
- service: climate.set_temperature
entity_id: climate.attic_thermostat
data:
hvac_mode: 'heat'
temperature: 20
- service: climate.set_temperature
entity_id: climate.main_bathroom_thermostat
data:
hvac_mode: 'heat'
temperature: 22
# Temperature below 4.9c outside and users home set heating to 23.5
- conditions:
- condition: and
conditions:
- condition: state
entity_id: group.all_people
state: 'home'
- condition: state
entity_id: input_boolean.vacation_mode
state: 'off'
- condition: numeric_state
entity_id: sensor.garden_temperature
below: 4.9
sequence:
- service: climate.set_temperature
entity_id: climate.living_room_thermostat
data:
hvac_mode: 'heat'
temperature: 23.5
- service: climate.set_temperature
entity_id: climate.office_thermostat
data:
hvac_mode: 'heat'
temperature: 22
- service: climate.set_temperature
entity_id: climate.hallway_thermostat
data:
hvac_mode: 'heat'
temperature: 22
- service: climate.set_temperature
entity_id: climate.bathroom_thermostat
data:
hvac_mode: 'heat'
temperature: 24
- service: climate.set_temperature
entity_id: climate.attic_thermostat
data:
hvac_mode: 'heat'
temperature: 21
- service: climate.set_temperature
entity_id: climate.main_bathroom_thermostat
data:
hvac_mode: 'heat'
temperature: 24
# Temperature between 5c to 14.9c outside and users home set heating to 23
- conditions:
- condition: and
conditions:
- condition: state
entity_id: group.all_people
state: 'home'
- condition: state
entity_id: input_boolean.vacation_mode
state: 'off'
- condition: numeric_state
entity_id: sensor.garden_temperature
above: 5
below: 14.9
sequence:
- service: climate.set_temperature
entity_id: climate.living_room_thermostat
data:
hvac_mode: 'heat'
temperature: 23
- service: climate.set_temperature
entity_id: climate.office_thermostat
data:
hvac_mode: 'heat'
temperature: 22
- service: climate.set_temperature
entity_id: climate.hallway_thermostat
data:
hvac_mode: 'heat'
temperature: 20
- service: climate.set_temperature
entity_id: climate.bathroom_thermostat
data:
hvac_mode: 'heat'
temperature: 24
- service: climate.set_temperature
entity_id: climate.attic_thermostat
data:
hvac_mode: 'heat'
temperature: 20
- service: climate.set_temperature
entity_id: climate.main_bathroom_thermostat
data:
hvac_mode: 'heat'
temperature: 24
# Temperature between 15c and 21.9c outside and users home set heating to 22.5
- conditions:
- condition: and
conditions:
- condition: state
entity_id: group.all_people
state: 'home'
- condition: state
entity_id: input_boolean.vacation_mode
state: 'off'
- condition: numeric_state
entity_id: sensor.garden_temperature
above: 15
below: 21.9
sequence:
- service: climate.set_temperature
entity_id: climate.living_room_thermostat
data:
hvac_mode: 'heat'
temperature: 22
- service: climate.set_temperature
entity_id: climate.office_thermostat
data:
hvac_mode: 'heat'
temperature: 22
- service: climate.set_temperature
entity_id: climate.hallway_thermostat
data:
hvac_mode: 'heat'
temperature: 20
- service: climate.set_temperature
entity_id: climate.bathroom_thermostat
data:
hvac_mode: 'heat'
temperature: 24
- service: climate.set_temperature
entity_id: climate.attic_thermostat
data:
hvac_mode: 'heat'
temperature: 20
- service: climate.set_temperature
entity_id: climate.main_bathroom_thermostat
data:
hvac_mode: 'heat'
temperature: 24
# Temperature between 22c and 24.9c outside and users home set heating to 21
- conditions:
- condition: and
conditions:
- condition: state
entity_id: group.all_people
state: 'home'
- condition: state
entity_id: input_boolean.vacation_mode
state: 'off'
- condition: numeric_state
entity_id: sensor.garden_temperature
above: 22
below: 24.9
sequence:
- service: climate.set_temperature
entity_id: climate.living_room_thermostat
data:
hvac_mode: 'heat'
temperature: 21
- service: climate.set_temperature
entity_id: climate.office_thermostat
data:
hvac_mode: 'heat'
temperature: 21
- service: climate.set_temperature
entity_id: climate.hallway_thermostat
data:
hvac_mode: 'heat'
temperature: 21
- service: climate.set_temperature
entity_id: climate.bathroom_thermostat
data:
hvac_mode: 'heat'
temperature: 24
- service: climate.set_temperature
entity_id: climate.attic_thermostat
data:
hvac_mode: 'heat'
temperature: 20
- service: climate.set_temperature
entity_id: climate.main_bathroom_thermostat
data:
hvac_mode: 'heat'
temperature: 24
# Temperature above 25c outside and users home set heating to off
- conditions:
- condition: and
conditions:
- condition: numeric_state
entity_id: sensor.outdoor_temperature
above: 25
sequence:
- service: climate.turn_off
entity_id: climate.living_room_thermostat
- service: climate.turn_off
entity_id: climate.office_thermostat
- service: climate.turn_off
entity_id: climate.hallway_thermostat
- service: climate.set_temperature
entity_id: climate.bathroom_thermostat
data:
hvac_mode: 'heat'
temperature: 23
- service: climate.turn_off
entity_id: climate.attic_thermostat
- service: climate.set_temperature
entity_id: climate.main_bathroom_thermostat
data:
hvac_mode: 'heat'
temperature: 23
# Adaptive heating based on home state and energy prices
- alias: Adaptive heating
id: adaptive_heating
trigger:
- platform: homeassistant
event: start
- platform: time_pattern
minutes: 2
action:
- choose:
# Low energy prices below 4.9c outside
- conditions:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.cheap_electricity
state: 'on'
- condition: numeric_state
entity_id: sensor.outdoor_temperature
below: 4.9
- condition: not
conditions:
- condition: time
after: "21:00:00"
before: "03:00:00"
sequence:
# - service_template: notify.pushover
# data_template:
# title: "Cheap electricity - Baymax has increased heating"
# message: "The price for electricity is now {{states('sensor.nordpool_kwh_oslo_nok_3_10_025')}} kWh. No action needed"
# data:
# priority: 0
# sound: "pianobar"
- service: climate.set_temperature
data_template:
entity_id: climate.living_room_thermostat
temperature: "{{(state_attr('climate.living_room_thermostat', 'temperature') | float + 1) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.office_thermostat
temperature: "{{(state_attr('climate.office_thermostat', 'temperature') | float + 1) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.hallway_thermostat
temperature: "{{(state_attr('climate.hallway_thermostat', 'temperature') | float + 1) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.bathroom_thermostat
temperature: "{{(state_attr('climate.bathroom_thermostat', 'temperature') | float + 1) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.attic_thermostat
temperature: "{{(state_attr('climate.attic_thermostat', 'temperature') | float + 1) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.main_bathroom_thermostat
temperature: "{{(state_attr('climate.main_bathroom_thermostat', 'temperature') | float + 1) }}"
# Low energy prices between 5c to 14.9c outside
- conditions:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.cheap_electricity
state: 'on'
- condition: numeric_state
entity_id: sensor.outdoor_temperature
above: 5
below: 14.9
- condition: not
conditions:
- condition: time
after: "21:00:00"
before: "03:00:00"
sequence:
# - service_template: notify.pushover
# data_template:
# title: "Cheap electricity - Baymax has increased heating"
# message: "The price for electricity is now {{states('sensor.nordpool_kwh_oslo_nok_3_10_025')}} kWh. No action needed"
# data:
# priority: 0
# sound: "pianobar"
- service: climate.set_temperature
data_template:
entity_id: climate.living_room_thermostat
temperature: "{{(state_attr('climate.living_room_thermostat', 'temperature') | float + 0.5) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.office_thermostat
temperature: "{{(state_attr('climate.office_thermostat', 'temperature') | float + 0.5) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.hallway_thermostat
temperature: "{{(state_attr('climate.hallway_thermostat', 'temperature') | float + 0.5) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.bathroom_thermostat
temperature: "{{(state_attr('climate.bathroom_thermostat', 'temperature') | float + 0.5) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.attic_thermostat
temperature: "{{(state_attr('climate.attic_thermostat', 'temperature') | float + 0.5) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.main_bathroom_thermostat
temperature: "{{(state_attr('climate.main_bathroom_thermostat', 'temperature') | float + 0.5) }}"
# Normal energy prices
- conditions:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.average_electricity
state: 'on'
- condition: not
conditions:
- condition: time
after: "21:00:00"
before: "03:00:00"
sequence:
# - service_template: notify.pushover
# data_template:
# title: "Cheaper electricity"
# message: "The price for electricity is now {{states('sensor.nordpool_kwh_oslo_nok_3_10_025')}} kWh. No action needed"
# data:
# priority: 0
# sound: "pianobar"
- service: automation.trigger
entity_id: automation.heating_state
# High energy prices below 4.9c outside
- conditions:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.expensive_electricity
state: 'on'
- condition: numeric_state
entity_id: sensor.outdoor_temperature
below: 4.9
- condition: not
conditions:
- condition: time
after: "21:00:00"
before: "03:00:00"
sequence:
# - service_template: notify.pushover
# data_template:
# title: "Expensive electricity - Baymax has reduced heating"
# message: "The price for electricity is now {{states('sensor.nordpool_kwh_oslo_nok_3_10_025')}} kWh. It is {{states('sensor.outdoor_temperature')}} degrees outside and {{states('weather.met_no')}} weather. Decide if fireplace needs to be lit"
# data:
# priority: 0
# sound: "pianobar"
- service: climate.set_temperature
data_template:
entity_id: climate.living_room_thermostat
temperature: "{{(state_attr('climate.living_room_thermostat', 'temperature') | float - 0.5) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.office_thermostat
temperature: "{{(state_attr('climate.office_thermostat', 'temperature') | float - 0.5) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.hallway_thermostat
temperature: "{{(state_attr('climate.hallway_thermostat', 'temperature') | float - 0.5) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.bathroom_thermostat
temperature: "{{(state_attr('climate.bathroom_thermostat', 'temperature') | float - 0.5) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.attic_thermostat
temperature: "{{(state_attr('climate.attic_thermostat', 'temperature') | float - 0.5) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.main_bathroom_thermostat
temperature: "{{(state_attr('climate.main_bathroom_thermostat', 'temperature') | float - 0.5) }}"
# High energy prices between 5c to 14.9c outside
- conditions:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.expensive_electricity
state: 'on'
- condition: numeric_state
entity_id: sensor.outdoor_temperature
above: 5
below: 14.9
- condition: not
conditions:
- condition: time
after: "21:00:00"
before: "03:00:00"
sequence:
# - service_template: notify.pushover
# data_template:
# title: "Expensive electricity - Baymax has reduced heating"
# message: "The price for electricity is now {{states('sensor.nordpool_kwh_oslo_nok_3_10_025')}} kWh. It is {{states('sensor.outdoor_temperature')}} degrees outside and {{states('weather.met_no')}} weather. Decide if fireplace needs to be lit"
# data:
# priority: 0
# sound: "pianobar"
- service: climate.set_temperature
data_template:
entity_id: climate.living_room_thermostat
temperature: "{{(state_attr('climate.living_room_thermostat', 'temperature') | float - 0.5) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.office_thermostat
temperature: "{{(state_attr('climate.office_thermostat', 'temperature') | float - 0.5) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.hallway_thermostat
temperature: "{{(state_attr('climate.hallway_thermostat', 'temperature') | float - 0.5) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.bathroom_thermostat
temperature: "{{(state_attr('climate.bathroom_thermostat', 'temperature') | float - 0.5) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.attic_thermostat
temperature: "{{(state_attr('climate.attic_thermostat', 'temperature') | float - 0.5) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.main_bathroom_thermostat
temperature: "{{(state_attr('climate.main_bathroom_thermostat', 'temperature') | float - 0.5) }}"
# Nightfall - adjust temperature
- conditions:
- condition: and
conditions:
- condition: time
after: "21:00:00"
before: "03:00:00"
sequence:
# - service_template: notify.pushover
# data_template:
# title: "Expensive electricity - Baymax has reduced heating"
# message: "The price for electricity is now {{states('sensor.nordpool_kwh_oslo_nok_3_10_025')}} kWh. It is {{states('sensor.outdoor_temperature')}} degrees outside and {{states('weather.met_no')}} weather. Decide if fireplace needs to be lit"
# data:
# priority: 0
# sound: "pianobar"
- service: climate.set_temperature
data_template:
entity_id: climate.living_room_thermostat
temperature: "{{(state_attr('climate.living_room_thermostat', 'temperature') | float - 1) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.office_thermostat
temperature: "{{(state_attr('climate.office_thermostat', 'temperature') | float - 1) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.hallway_thermostat
temperature: "{{(state_attr('climate.hallway_thermostat', 'temperature') | float - 1) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.bathroom_thermostat
temperature: "{{(state_attr('climate.bathroom_thermostat', 'temperature') | float - 1) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.attic_thermostat
temperature: "{{(state_attr('climate.attic_thermostat', 'temperature') | float - 1) }}"
- service: climate.set_temperature
data_template:
entity_id: climate.main_bathroom_thermostat
temperature: "{{(state_attr('climate.main_bathroom_thermostat', 'temperature') | float - 1) }}"