Files
boiler-control-appdaemon/boilercontrol.py

28 lines
844 B
Python

import hassapi as hass
import datetime
#
# Boiler Controller. Tries to optimize when to power (heat up) the boiler with respect to the hourly (dynamic) electricity prices
#
# Args:
#
class BoilerControl(hass.Hass):
def initialize(self):
self.log("Initializing boiler control")
self.boiler_switch = self.args['boiler_switch']
self.price_sensor = self.args['price_sensor']
self.determine_cheapest_hours()
self.run_daily(self.determine_cheapest_hours, datetime.time(0, 1, 0))
def determine_cheapest_hours(self):
# Get the prices for the current day
prices = self.get_state(self.price_sensor, attribute="raw_today")
for price in prices:
self.log("Price: " + str(price["value"]) + " at " + datetime.datetime.fromisoformat(price["start"]).strftime("%H:%M"))