I have an app where I am trying to schedule the starting of a pump. The automation seems to work with the initial time parameter; however when the input_datetime is changed in HA, the variable is not updated in appdaemon. Any ideas?
import appdaemon.plugins.hass.hassapi as hass
import datetime
class poolPumpMain(hass.Hass):
def initialize(self):
startTime = self.get_state(self.args["startTime"])
startTimeHour = int(startTime[0:2])
startTimeMinute = int(startTime[3:5])
stopTime = self.get_state(self.args["stopTime"])
stopTimeHour = int(stopTime[0:2])
stopTimeMinute = int(stopTime[3:5])
on_time = datetime.time(startTimeHour, startTimeMinute, 0)
off_time = datetime.time(stopTimeHour, stopTimeMinute, 0)
self.handle = self.listen_state(self.startTimeChangedCallBack, "input_datetime.pool_pump_start_time")
self.log("***********************")
self.log("hass start hour=")
self.log(startTimeHour)
self.log("hass start minute=")
self.log(startTimeMinute)
self.log("hass stop hour=")
self.log(stopTimeHour)
self.log("hass stop minute=")
self.log(stopTimeMinute)
self.run_daily(self.off_time_callback, off_time)
self.run_daily(self.on_time_callback, on_time)
def on_time_callback(self, kwargs):
# Call to Home Assistant to turn the porch light on
self.turn_on("switch.pool_main_pump")
self.log("on_time_callback called")
def off_time_callback(self, kwargs):
# Call to Home Assistant to turn the porch light on
self.turn_off("switch.pool_main_pump")
def startTimeChangedCallBack(self, kwargs):
self.log("start time changed")