[WIP] Started working on the boiler control service
This commit is contained in:
28
boilercontrol.py
Normal file
28
boilercontrol.py
Normal file
@@ -0,0 +1,28 @@
|
||||
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"))
|
||||
Reference in New Issue
Block a user