PyTado icon indicating copy to clipboard operation
PyTado copied to clipboard

Add support to get/set a schedule for a zone

Open mattthewclayton opened this issue 5 years ago • 1 comments

Add API to get/set a schedule for a zone. Possible Usecases:

  • Programatically update a zone to different schedules (Summer/Winter, Guest Room with/without guest)
  • Clone schedules across all zones - so multiple rooms can share the same schedule without having to enter them manually in the Tado app.

Example Usage:

from PyTado.PyTado.interface import Tado

t = Tado('user','pass')

## Set Tado in zone 5 to use the THREE_DAY timetable
t.setTimetable(5,Tado.Timetable.THREE_DAY)

## Get the schedule for zone 5,  MONDAY_TO_FRIDAY in the THREE_DAY timetable.
schedule = t.getSchedule(5,Tado.Timetable.THREE_DAY,"MONDAY_TO_FRIDAY")

## Somehow modify the current schedule, i am just setting all temps to 19
for item in schedule:
    item['setting']['temperature']['celsius'] = 19 
    del(item['setting']['temperature']['fahrenheit']) # Just because It would be wrong otherwise

## Tell Tado to apply the new schedule to the "Monday to Friday" day in the THREE_DAY timetable
newSchedule = t.setSchedule(5, Tado.Timetable.THREE_DAY, "MONDAY_TO_FRIDAY", schedule)

## Print out the returned data from the Tado API, which should be the new schedule
print(newSchedule)

mattthewclayton avatar May 17 '19 18:05 mattthewclayton

Added a bit more to allow you to get and set the current timetable mode for a zone (i.e is it THREE_DAY, ONE_DAY or SEVEN_DAY)

Added an enum to make this easier, updated the earlier example to factor this in.

mattthewclayton avatar May 18 '19 12:05 mattthewclayton