This is my current script, and i realized today that for some reason the set_temperature call service doesn’t change my hvac_mode which is really weird. Therefore, i created a follow up call service for set_hvac_mode to make sure it changes it. The good morning temp is triggered when an input boolean is turned off, and i just noticed that i have to toggle the sensor about 4 times for it to set the 2 thermostats to the right temp (73) and the right mode (heat).
I have z wave thermostats and that may be why they are slow. What can i add in my python script to fix this?
I know i am not suppose to put a wait, so wondering what can i do to send a call service one at a time to make sure home assistant reacts to them all and doesn’t skip one.
import appdaemon.plugins.hass.hassapi as hass
class Climate(hass.Hass):
def initialize(self):
# Morning
self.listen_state(self.home, "input_boolean.sleep_mode", new="off")
# Arriving home
self.listen_state(self.home, "alarm_control_panel.ring_alarm", old="armed_away", new="disarmed")
# Night
# self.listen_state(self.night, "input_boolean.sleep_mode", new="on")
# Away
# self.listen_state(self.away, "binary_sensor.house_occupied", new="off")
def home(self, entity, attribute, old, new, kwargs):
#todays_high = float(self.get_state("sensor.dark_sky_daytime_high_apparent_temperature_0d"))
todays_high = float(self.get_state("sensor.nws_temperature_high_today"))
if todays_high >= 80:
# set thermostat to 72 cool
self.log("Setting thermostat to 72 cool")
# Upstairs thermostat
self.call_service("climate/set_temperature", entity_id = "climate.trane_corporation_model_tcont624as42daa_mode_2", temperature = 72)
self.call_service("climate/set_hvac_mode", entity_id = "climate.trane_corporation_model_tcont624as42daa_mode_2", hvac_mode = "cool")
# Downstairs thermostat
self.call_service("climate/set_temperature", entity_id = "climate.trane_corporation_model_tcont624as42daa_mode", temperature = 72)
self.call_service("climate/set_hvac_mode", entity_id = "climate.trane_corporation_model_tcont624as42daa_mode", hvac_mode = "cool")
elif todays_high < 80 and todays_high >= 70:
# set thermostat to 74 cool
self.log("Setting thermostat to 74 cool")
# Upstairs thermostat
self.call_service("climate/set_temperature", entity_id = "climate.trane_corporation_model_tcont624as42daa_mode_2", temperature = 74)
self.call_service("climate/set_hvac_mode", entity_id = "climate.trane_corporation_model_tcont624as42daa_mode_2", hvac_mode = "cool")
# Downstairs thermostat
self.call_service("climate/set_temperature", entity_id = "climate.trane_corporation_model_tcont624as42daa_mode", temperature = 74)
self.call_service("climate/set_hvac_mode", entity_id = "climate.trane_corporation_model_tcont624as42daa_mode", hvac_mode = "cool")
else:
# set thermostat to 73 heat
self.log("Setting thermostat to 73 heat")
# Upstairs thermostat
self.call_service("climate/set_temperature", entity_id = "climate.trane_corporation_model_tcont624as42daa_mode_2", temperature = 73)
self.call_service("climate/set_hvac_mode", entity_id = "climate.trane_corporation_model_tcont624as42daa_mode_2", hvac_mode = "heat")
# Downstairs thermostat
self.call_service("climate/set_temperature", entity_id = "climate.trane_corporation_model_tcont624as42daa_mode", temperature = 73)
self.call_service("climate/set_hvac_mode", entity_id = "climate.trane_corporation_model_tcont624as42daa_mode", hvac_mode = "heat")