<s> import json <EOL> import requests <EOL> from . base import EvohomeBase , EvohomeClientInvalidPostData <EOL> class ZoneBase ( EvohomeBase ) : <EOL> def __init__ ( self ) : <EOL> super ( ZoneBase , self ) . __init__ ( ) <EOL> def schedule ( self ) : <EOL> r = requests . get ( '<STR_LIT>' % ( self . zone_type , self . zoneId ) , headers = self . client . headers ) <EOL> r . raise_for_status ( ) <EOL> mapping = [ <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> j = r . text <EOL> for f , t in mapping : <EOL> j = j . replace ( f , t ) <EOL> d = self . _convert ( j ) <EOL> for day_of_week , schedule in enumerate ( d [ '<STR_LIT>' ] ) : <EOL> schedule [ '<STR_LIT>' ] = day_of_week <EOL> return d <EOL> def set_schedule ( self , zone_info ) : <EOL> try : <EOL> t1 = json . loads ( zone_info ) <EOL> except : <EOL> raise EvohomeClientInvalidPostData ( '<STR_LIT>' ) <EOL> headers = dict ( self . client . headers ) <EOL> headers [ '<STR_LIT:Content-Type>' ] = '<STR_LIT:application/json>' <EOL> r = requests . put ( '<STR_LIT>' % ( self . zone_type , self . zoneId ) , data = zone_info , headers = headers ) <EOL> return self . _convert ( r . text ) <EOL> class Zone ( ZoneBase ) : <EOL> def __init__ ( self , client , data = None ) : <EOL> super ( Zone , self ) . __init__ ( ) <EOL> self . client = client <EOL> self . zone_type = '<STR_LIT>' <EOL> if data is not None : <EOL> self . __dict__ . update ( data ) <EOL> def set_temperature ( self , temperature , until = None ) : <EOL> if until is None : <EOL> data = { "<STR_LIT>" : temperature , "<STR_LIT>" : <NUM_LIT:1> , "<STR_LIT>" : None } <EOL> else : <EOL> data = { "<STR_LIT>" : temperature , "<STR_LIT>" : <NUM_LIT:2> , "<STR_LIT>" : until . strftime ( '<STR_LIT>' ) } <EOL> self . _set_heat_setpoint ( data ) <EOL> def _set_heat_setpoint ( self , data ) : <EOL> url = '<STR_LIT>' % self . zoneId <EOL> headers = dict ( self . client . headers ) <EOL> headers [ '<STR_LIT:Content-Type>' ] = '<STR_LIT:application/json>' <EOL> response = requests . put ( url , json . dumps ( data ) , headers = headers ) <EOL> def cancel_temp_override ( self , zone ) : <EOL> data = { "<STR_LIT>" : <NUM_LIT:0.0> , "<STR_LIT>" : <NUM_LIT:0> , "<STR_LIT>" : None } <EOL> self . _set_heat_setpoint ( data ) </s>
