-
Notifications
You must be signed in to change notification settings - Fork 50
Thermostat adjustment using Occupancy
Matthew Scoville edited this page Sep 13, 2020
·
1 revision
This script contains two (leaving/returning) to handle setting my thermostat to the desired temperatures.
The trigger is a device tracker group that I created that contains all the device trackers and will have a status of home if at least 1 person is home.
It uses the forecast temperature from 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).
"""
Thermostat occupancy script
"""
@state_trigger("group.device_trackers == 'not_home'")
def themostat_left():
trig_info = task.wait_until(
state_trigger="group.device_trackers == 'home'",
timeout=120
)
if trig_info["trigger_type"] == "timeout":
pass
else:
"""Set High Temp"""
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")
pass
@state_trigger("group.device_trackers == 'home'")
def themostat_left():
trig_info = task.wait_until(
state_trigger="group.device_trackers == 'not_home'",
timeout=30
)
if trig_info["trigger_type"] == "timeout":
pass
else:
"""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")
pass