I've developped a different approche for the thermostat schedule. At home, I have multiple thermostarts and this approche is simpler for me. Here the python script:
- Code: Select all
from datetime import datetime
# ---------------------------------------------------------------------
# SCHEDULE DATA FOR ONE SCENARIO
# - Add you own device constants: id and name.
# - Cut and paste dictionary from the Excel thermo schedule tool.
# - Dictionary name should be identical of your defined tab name
# and declared constants.
# - If you have many scenarios, create a variable and activate
# the right indigo schedule with different script.
# ---------------------------------------------------------------------
kTHERMO_BEDROOM = xxxxxxxxx # Your device id -> Thermostat: Bedroom
kTHERMO_OFFICE = xxxxxxxxx # Your device id -> Thermostat: Office
kTHERMO_SCHEDULE = {
kTHERMO_BEDROOM:
[[(0.00, 4.50, 15.0), (4.50, 7.50, 18.6), (7.50, 16.00, 16.0), (16.00, 21.00, 18.6), (21.00, 24.00, 15.0)],
[(0.00, 4.50, 15.0), (4.50, 7.50, 18.6), (7.50, 16.00, 16.0), (16.00, 21.00, 18.6), (21.00, 24.00, 15.0)],
[(0.00, 4.50, 15.0), (4.50, 7.50, 18.6), (7.50, 16.00, 16.0), (16.00, 21.00, 18.6), (21.00, 24.00, 15.0)],
[(0.00, 4.50, 15.0), (4.50, 7.50, 18.6), (7.50, 16.00, 16.0), (16.00, 21.00, 18.6), (21.00, 24.00, 15.0)],
[(0.00, 4.50, 15.0), (4.50, 7.50, 18.6), (7.50, 16.00, 16.0), (16.00, 21.00, 18.6), (21.00, 24.00, 15.0)],
[(0.00, 8.00, 15.0), (8.00, 22.00, 18.6), (22.00, 24.00, 15.0)],
[(0.00, 8.00, 15.0), (8.00, 22.00, 18.6), (22.00, 24.00, 15.0)]],
kTHERMO_OFFICE:
[[(0.00, 4.50, 15.0), (4.50, 7.50, 18.6), (7.50, 16.00, 16.0), (16.00, 21.00, 18.6), (21.00, 24.00, 15.0)],
[(0.00, 4.50, 15.0), (4.50, 7.50, 18.6), (7.50, 16.00, 16.0), (16.00, 21.00, 18.6), (21.00, 24.00, 15.0)],
[(0.00, 4.50, 15.0), (4.50, 7.50, 18.6), (7.50, 16.00, 16.0), (16.00, 21.00, 18.6), (21.00, 24.00, 15.0)],
[(0.00, 4.50, 15.0), (4.50, 7.50, 18.6), (7.50, 16.00, 16.0), (16.00, 21.00, 18.6), (21.00, 24.00, 15.0)],
[(0.00, 4.50, 15.0), (4.50, 7.50, 18.6), (7.50, 16.00, 16.0), (16.00, 21.00, 18.6), (21.00, 24.00, 15.0)],
[(0.00, 8.00, 15.0), (8.00, 22.00, 18.6), (22.00, 24.00, 15.0)],
[(0.00, 8.00, 15.0), (8.00, 22.00, 18.6), (22.00, 24.00, 15.0)]]
}
# ---------------------------------------------------------------------
# SCRIPT
# ---------------------------------------------------------------------
cT = datetime.now().hour + (datetime.now().minute / 60.0)
wDay = datetime.now().weekday() # 0=Monday, ...
# Loop across all devices
for devId, devWeekSch in kTHERMO_SCHEDULE.items():
# Get current device set point
dev = indigo.devices[devId]
curSP = dev.heatSetpoint
# Loop across all day schedule
try:
for start, stop, SP in devWeekSch[wDay]:
if start <= cT < stop:
if SP != curSP:
# Set new SP of the current device
indigo.thermostat.setHeatSetpoint(devId, value=SP)
break
except:
# Manage error if is the case
indigo.server.log("Script error. Hint: array contain 7 days?")
Here the 'how to':
- 1. With the Excel file, generate the temperture table for each thermostat you have -> LINK
2. Generate the array data 'kTHERMO_SCHEDULE' with the Excel file.
3 Copy and paste the array in the script.
4. Create all dedicated constants (e.g. kTHERMO____). Those constants names are Excel tab(s) and variable(s) in the Python script.
5. Assign those constants the thermostat device id.
6. Save the script on you server HD.
7. Create a 15 minutes schedule (LINK) with a the external python script.
OPTION
- 8. Create a variable with the active mode (e.g. at home, hollidays, ...);
9. In the schedule condition, compare the new variable if is equal to the desired mode. In fact, you will have a script for each mode you have.
Thanks
Joël