-
Notifications
You must be signed in to change notification settings - Fork 47
Thermostat Adjustment using Time Trigger
Matthew Scoville edited this page Sep 13, 2020
·
2 revisions
This is the Script that I use to handle adjusting my Z-Wave Thermostat based off the forecast temperature for the next day.
I have this split into two separate script files, day and night, with the day one split into two scripts inside the file, workday and non-workday with the difference being the time trigger.
This checks a binary sensor (Workday) and then gets the forecast temperature by checking Dark Sky (which I'll have to switch off when they go dark). It sets two variables (hightemp/lowtemp) and then calls the Climate set_temperature function to set the high/low temp on my thermostat (which just stays in auto mode all the time).
Temps are in Fahrenheit so would need to be converted for those in civilized countries.
"""
Thermostat day script
"""
@time_trigger("once(7:30:00)")
def thermostat_work_day():
"""Trigger at 7:30am every"""
"""Only trigger on workday"""
if binary_sensor.workday == 'on':
"""Set High Temp"""
if float(sensor.dark_sky_daytime_high_temperature_0d) > 85.0:
hightemp = 75
elif float(sensor.dark_sky_daytime_high_temperature_0d) < 85.0:
hightemp = 85
"""Set Low Temp"""
if float(sensor.dark_sky_overnight_low_temperature_0d) > 50.0:
lowtemp = 55
elif float(sensor.dark_sky_overnight_low_temperature_0d) < 50.0:
lowtemp = 65
"""Send the actual command to the thermostat"""
climate.set_temperature(entity_id="climate.radio_thermostat_company_of_america_ct101_thermostat_iris_mode",target_temp_low=lowtemp,target_temp_high=hightemp,hvac_mode="heat_cool")
@time_trigger("once(8:30:00)")
def thermostat_nonwork_day():
"""Trigger at 8:30am every"""
if binary_sensor.workday != 'on':
"""Set High Temp"""
if float(sensor.dark_sky_daytime_high_temperature_0d) > 85.0:
hightemp = 75
elif float(sensor.dark_sky_daytime_high_temperature_0d) < 85.0:
hightemp = 85
"""Set Low Temp"""
if float(sensor.dark_sky_overnight_low_temperature_0d) > 50.0:
lowtemp = 55
elif float(sensor.dark_sky_overnight_low_temperature_0d) < 50.0:
lowtemp = 65
"""Send the actual command to the thermostat"""
climate.set_temperature(entity_id="climate.radio_thermostat_company_of_america_ct101_thermostat_iris_mode",target_temp_low=lowtemp,target_temp_high=hightemp,hvac_mode="heat_cool")
"""
Thermostat night script
"""
@time_trigger("once(23:00:00)")
def thermostat_night():
"""Trigger at 11pm every night"""
"""Set High Temp"""
if float(sensor.dark_sky_daytime_high_temperature_0d) > 85.0:
hightemp = 75
elif float(sensor.dark_sky_daytime_high_temperature_0d) < 85.0:
hightemp = 85
"""Set Low Temp"""
if float(sensor.dark_sky_overnight_low_temperature_0d) > 50.0:
lowtemp = 55
elif float(sensor.dark_sky_overnight_low_temperature_0d) < 50.0:
lowtemp = 65
"""Send the actual command to the thermostat"""
climate.set_temperature(entity_id="climate.radio_thermostat_company_of_america_ct101_thermostat_iris_mode",target_temp_low=lowtemp,target_temp_high=hightemp,hvac_mode="heat_cool")