Going Greener with IoT
2.5 years ago I wrote a post titled Going Green with IoT about minimizing the cost of my temporary, rag-tag heating system using my electricity provider’s hourly pricing and the corresponding Home Assistant integration. In that setup I set a single threshold for when I would turn off/on my HVAC and beer fridge when the electricity became too expensive.
- alias: 'Turn Off Expensive ComEd'
trigger:
platform: numeric_state
entity_id: sensor.comed_current_hour_average_price
above: 25
condition:
condition: numeric_state
entity_id: sensor.comed_current_hour_average_price
above: 25
action:
- service: climate.turn_off
data:
entity_id:
- group.am_ac
- service: switch.turn_off
data:
entity_id:
- switch.hvac_basement
- switch.kegerator
- alias: 'Turn On Cheap ComEd'
trigger:
platform: numeric_state
entity_id: sensor.comed_current_hour_average_price
below: 25
condition:
condition: numeric_state
entity_id: sensor.comed_current_hour_average_price
below: 25
action:
- service: climate.turn_on
data:
entity_id:
- group.am_ac
- service: switch.turn_on
data:
entity_id:
- switch.hvac_basement
- switch.kegerator
Where group.am_ac
corresponds to this in the groups.yaml:
AM_AC:
name: am_ac
entities:
- climate.frunchroom
- climate.den
- climate.guest_room
- climate.media_room
- climate.hvac_office
- climate.hvac_master
Upgrade!
Since then I’ve upgraded to Mr. Cool mini splits/heat pumps controlled with Sensibo Air controllers. This last heatwave in the US motivated me to take this system to the next level by using the new choose
(i.e. if/elif/…/else) functionality to raise the thermostat when prices rise and lower the thermostat when prices fall. I still turn everything off completely when it gets too expensive, but this allows me to throttle usage more frequently/gradually.
- alias: 'Temperature by Electricity Price'
trigger:
- platform: state
entity_id: sensor.comed_current_hour_average_price
- platform: homeassistant
event: start
condition:
condition: time
after: '05:30:00'
before: '19:00:00'
action:
- choose:
# IF under 5c
- conditions:
- condition: numeric_state
entity_id: sensor.comed_current_hour_average_price
below: 5
sequence:
- service: climate.set_temperature
entity_id:
- group.am_ac
data:
temperature: 70
# IF under 10c
- conditions:
- condition: numeric_state
entity_id: sensor.comed_current_hour_average_price
above: 5
below: 10
sequence:
- service: climate.set_temperature
entity_id:
- group.am_ac
data:
temperature: 72
# IF under 15c
- conditions:
- condition: numeric_state
entity_id: sensor.comed_current_hour_average_price
above: 10
below: 15
sequence:
- service: climate.set_temperature
entity_id:
- group.am_ac
data:
temperature: 74
# IF under 20c
- conditions:
- condition: numeric_state
entity_id: sensor.comed_current_hour_average_price
above: 15
below: 20
sequence:
- service: climate.set_temperature
entity_id:
- group.am_ac
data:
temperature: 76
# IF under 25c
- conditions:
- condition: numeric_state
entity_id: sensor.comed_current_hour_average_price
above: 20
below: 25
sequence:
- service: climate.set_temperature
entity_id:
- group.am_ac
data:
temperature: 78
# ELSE in case no ComEd data
default:
- service: climate.set_temperature
entity_id:
- group.am_ac
data:
temperature: 74
The most difficult part of getting this to work was digging into the documentation to realize that I should use platform: state
instead of platform: numeric_state
for the trigger with sensor.comed_current_hour_average_price
. This triggers the automation whenever the electricity price changes, allowing me to use the range of prices as a condition. If anyone has a more elegant solution, I’m glad to hear it!
Dehumidifying
Additionally, I noticed that my humidity was hitting mid-60’s on particularly hot days and decided to finally make use of the Dry
mode on the mini splits. I set it up so that it goes to dry mode whenever the temperature is below 74 and the humidity is above 55%. That is, whenever I need less cooling and more dehumidifying, it goes to dry mode. When it starts to get sufficiently warm in the house, I change it back to full AC mode. Not only does this make the house more comfortable and safe, it should also reduce electricity usage.
Edit: the original post didn’t have the necessary condition: or
nested within the condition: and
on the Cool 1st Floor
automation.
- alias: 'Dry 1st Floor'
trigger:
- platform: time
at: '05:30:00'
- platform: homeassistant
event: start
- platform: numeric_state
entity_id: sensor.netatmo_home_1st_floor_humidity
above: 55
condition:
condition: and
conditions:
- condition: time
after: '05:30:00'
before: '19:00:00'
- condition: numeric_state
entity_id: sensor.netatmo_home_1st_floor_temperature
below: 73
- condition: numeric_state
entity_id: sensor.netatmo_home_1st_floor_humidity
above: 55
action:
- service: climate.set_hvac_mode
entity_id:
- group.ac_1f
data:
hvac_mode: dry
- alias: 'Cool 1st Floor'
trigger:
- platform: time
at: '05:30:00'
- platform: homeassistant
event: start
- platform: numeric_state
entity_id: sensor.netatmo_home_1st_floor_humidity
below: 55
- platform: numeric_state
entity_id : sensor.netatmo_home_1st_floor_temperature
above: 73
condition:
condition: and
conditions:
- condition: time
after: '05:30:00'
before: '19:00:00'
- condition: or
conditions:
- condition: numeric_state
entity_id: sensor.netatmo_home_1st_floor_temperature
above: 73
- condition: numeric_state
entity_id: sensor.netatmo_home_1st_floor_humidity
below: 55
action:
- service: climate.set_hvac_mode
entity_id:
- group.ac_1f
data:
hvac_mode: cool
I can report that this was the most comfortable heat wave that we’ve experienced in this house yet. Mini splits + Home Assistant FTW! We’ll see how much more effective this automation is at reducing my electricity bill next month, but thought I’d share the choose
code that took me some effort to figure out.
Cross-posted on reddit here.