This project was to use an ecobee room sensors temperature and a space heater plugged into a smart switch to remedy my wife’s cold room. Prior to this her room ran about two degress colder than the rest of the home.
I’ve merged everything that was required into my configuration.yaml and present it as such below. I understand this is not the preferred practice, but I’m new to HA and don’t know how you would otherwise keep the segments of a project together. Advice and suggestions are welcome.
# Nancy's Thermostat
##################################################################
# Virtual switch controlled by the generic_thermostat platform
input_boolean nancy_thermostat_state_requested:
nancy_thermostat_state_requested:
name: On/Off heater state requested by Nancy's thermostat
icon: mdi:radiator
# Virtual switch state to aggregate the thermostat's requested state
# with user requested overrides, slaved to real switch by automation
binary_sensor nancy_thermostat_heat_on:
platform: template
sensors:
nancy_thermostat_heat_on:
value_template: >
{{ (states('input_boolean.nancy_thermostat_state_requested') == 'on'
and state_attr('automation.nancy_thermostat_override_off', 'current') == 0)
or state_attr('automation.nancy_thermostat_override_on', 'current') == 1
}}
# Slaves the real smart plug relay to the virtual switch above
automation nancy_thermostat_set_switch:
id: '1640919108087'
alias: nancy_thermostat_set_switch
description: Nancy's Thermostat - Slaves the actual heater plug switch to the template
binary sensor
trigger:
- platform: state
entity_id: binary_sensor.nancy_thermostat_heat_on
condition: []
action:
- service: switch.turn_{{ trigger.to_state.state }}
target:
entity_id: switch.heater
mode: single
# Set's the virtual thermostat's target temperature to the main thermostat's
# actual temperature
automation nancy_thermostat_set_target:
id: '1640908807365'
alias: nancy_thermostat_set_target
description: Set Nancy's thermostat to main home temperature
trigger:
- platform: state
entity_id: sensor.home_current_temperature
condition: []
action:
- service: climate.set_temperature
data:
temperature: '{{ states(''sensor.home_current_temperature'') | float }}'
target:
entity_id: climate.nancy_thermostat
mode: single
# Overrides thermostat control to force the heater on for 1 hour
automation nancy_thermostat_override_on:
id: '1640912314847'
alias: nancy_thermostat_override_on
description: Nancy's Thermostat - Override to 'On' for 1 hour
trigger:
- platform: event
event_type: ''
condition: []
action:
- delay:
hours: 1
minutes: 0
seconds: 0
milliseconds: 0
mode: restart
# Overrides thermostat control to force the heater off for 1 hour
automation nancy_thermostat_override_off:
id: '1640912744849'
alias: nancy_thermostat_override_off
description: Nancy's Thermostat - Override to 'Off' for 1 hour
trigger:
- platform: event
event_type: ''
condition: []
action:
- delay:
hours: 1
minutes: 0
seconds: 0
milliseconds: 0
mode: restart
# On override, cancels any off override and forces 1 hour on
script nancy_thermostat_on:
nancy_thermostat_on:
alias: Nancy's Thermostat - Override to 'On' for 1 hour
sequence:
- service: automation.turn_off
target:
entity_id: automation.nancy_thermostat_override_off
- service: automation.turn_on
target:
entity_id: automation.nancy_thermostat_override_off
- service: automation.trigger
target:
entity_id: automation.nancy_thermostat_override_on
mode: restart
icon: mdi:thermometer-plus
# Off override, cancels any on override and forces 1 hour off
script nancy_thermostat_off:
nancy_thermostat_off:
alias: Nancy's Thermostat - Override to 'Off' for 1 hour
sequence:
- service: automation.turn_off
target:
entity_id: automation.nancy_thermostat_override_on
- service: automation.turn_on
target:
entity_id: automation.nancy_thermostat_override_on
- service: automation.trigger
target:
entity_id: automation.nancy_thermostat_override_off
mode: single
icon: mdi:thermometer-off
# Cancel overrides, any on or off override is reset
script nancy_thermostat_cancel:
nancy_thermostat_cancel:
alias: Nancy's Thermostat - Cancel overrides
sequence:
- service: automation.turn_off
target:
entity_id:
- automation.nancy_thermostat_override_off
- automation.nancy_thermostat_override_on
- service: automation.turn_on
target:
entity_id:
- automation.nancy_thermostat_override_off
- automation.nancy_thermostat_override_on
mode: single
icon: mdi:thermometer-lines
# The virtual thermostat to tie the temperature sensor to the virtual
# switch and provide hysteresis
climate nancy_thermostat:
platform: generic_thermostat
name: "Nancy's Thermostat"
unique_id: nancy_thermostat
target_sensor: sensor.nancys_bedroom_temperature
heater: input_boolean.nancy_thermostat_state_requested
keep_alive:
minutes: 60
initial_hvac_mode: "heat"
precision: 0.1
##################################################################