<s> """<STR_LIT>""" <EOL> import logging <EOL> from homeassistant . components import ecobee <EOL> from homeassistant . components . thermostat import ( <EOL> STATE_COOL , STATE_HEAT , STATE_IDLE , ThermostatDevice ) <EOL> from homeassistant . const import STATE_OFF , STATE_ON , TEMP_FAHRENHEIT <EOL> DEPENDENCIES = [ '<STR_LIT>' ] <EOL> _LOGGER = logging . getLogger ( __name__ ) <EOL> ECOBEE_CONFIG_FILE = '<STR_LIT>' <EOL> _CONFIGURING = { } <EOL> def setup_platform ( hass , config , add_devices , discovery_info = None ) : <EOL> """<STR_LIT>""" <EOL> if discovery_info is None : <EOL> return <EOL> data = ecobee . NETWORK <EOL> hold_temp = discovery_info [ '<STR_LIT>' ] <EOL> _LOGGER . info ( <EOL> "<STR_LIT>" , <EOL> hold_temp ) <EOL> add_devices ( Thermostat ( data , index , hold_temp ) <EOL> for index in range ( len ( data . ecobee . thermostats ) ) ) <EOL> class Thermostat ( ThermostatDevice ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , data , thermostat_index , hold_temp ) : <EOL> """<STR_LIT>""" <EOL> self . data = data <EOL> self . thermostat_index = thermostat_index <EOL> self . thermostat = self . data . ecobee . get_thermostat ( <EOL> self . thermostat_index ) <EOL> self . _name = self . thermostat [ '<STR_LIT:name>' ] <EOL> self . _away = '<STR_LIT>' in self . thermostat [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> self . hold_temp = hold_temp <EOL> def update ( self ) : <EOL> """<STR_LIT>""" <EOL> self . data . update ( ) <EOL> self . thermostat = self . data . ecobee . get_thermostat ( <EOL> self . thermostat_index ) <EOL> @ property <EOL> def name ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . thermostat [ '<STR_LIT:name>' ] <EOL> @ property <EOL> def unit_of_measurement ( self ) : <EOL> """<STR_LIT>""" <EOL> return TEMP_FAHRENHEIT <EOL> @ property <EOL> def current_temperature ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . thermostat [ '<STR_LIT>' ] [ '<STR_LIT>' ] / <NUM_LIT:10> <EOL> @ property <EOL> def target_temperature ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . hvac_mode == '<STR_LIT>' or self . hvac_mode == '<STR_LIT>' : <EOL> return self . target_temperature_low <EOL> elif self . hvac_mode == '<STR_LIT>' : <EOL> return self . target_temperature_high <EOL> else : <EOL> return ( self . target_temperature_low + <EOL> self . target_temperature_high ) / <NUM_LIT:2> <EOL> @ property <EOL> def target_temperature_low ( self ) : <EOL> """<STR_LIT>""" <EOL> return int ( self . thermostat [ '<STR_LIT>' ] [ '<STR_LIT>' ] / <NUM_LIT:10> ) <EOL> @ property <EOL> def target_temperature_high ( self ) : <EOL> """<STR_LIT>""" <EOL> return int ( self . thermostat [ '<STR_LIT>' ] [ '<STR_LIT>' ] / <NUM_LIT:10> ) <EOL> @ property <EOL> def humidity ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . thermostat [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> @ property <EOL> def desired_fan_mode ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . thermostat [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> @ property <EOL> def fan ( self ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT>' in self . thermostat [ '<STR_LIT>' ] : <EOL> return STATE_ON <EOL> else : <EOL> return STATE_OFF <EOL> @ property <EOL> def operation ( self ) : <EOL> """<STR_LIT>""" <EOL> status = self . thermostat [ '<STR_LIT>' ] <EOL> if status == '<STR_LIT>' : <EOL> return STATE_IDLE <EOL> elif '<STR_LIT>' in status : <EOL> return STATE_COOL <EOL> elif '<STR_LIT>' in status : <EOL> return STATE_HEAT <EOL> elif '<STR_LIT>' in status : <EOL> return STATE_HEAT <EOL> else : <EOL> return status <EOL> @ property <EOL> def mode ( self ) : <EOL> """<STR_LIT>""" <EOL> mode = self . thermostat [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> self . _away = '<STR_LIT>' in mode <EOL> return mode <EOL> @ property <EOL> def hvac_mode ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . thermostat [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> @ property <EOL> def device_state_attributes ( self ) : <EOL> """<STR_LIT>""" <EOL> return { <EOL> "<STR_LIT>" : self . humidity , <EOL> "<STR_LIT>" : self . fan , <EOL> "<STR_LIT>" : self . mode , <EOL> "<STR_LIT>" : self . hvac_mode <EOL> } <EOL> @ property <EOL> def is_away_mode_on ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _away <EOL> def turn_away_mode_on ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _away = True <EOL> if self . hold_temp : <EOL> self . data . ecobee . set_climate_hold ( self . thermostat_index , <EOL> "<STR_LIT>" , "<STR_LIT>" ) <EOL> else : <EOL> self . data . ecobee . set_climate_hold ( self . thermostat_index , "<STR_LIT>" ) <EOL> def turn_away_mode_off ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _away = False <EOL> self . data . ecobee . resume_program ( self . thermostat_index ) <EOL> def set_temperature ( self , temperature ) : <EOL> """<STR_LIT>""" <EOL> temperature = int ( temperature ) <EOL> low_temp = temperature - <NUM_LIT:1> <EOL> high_temp = temperature + <NUM_LIT:1> <EOL> if self . hold_temp : <EOL> self . data . ecobee . set_hold_temp ( self . thermostat_index , low_temp , <EOL> high_temp , "<STR_LIT>" ) <EOL> else : <EOL> self . data . ecobee . set_hold_temp ( self . thermostat_index , low_temp , <EOL> high_temp ) <EOL> def set_hvac_mode ( self , mode ) : <EOL> """<STR_LIT>""" <EOL> self . data . ecobee . set_hvac_mode ( self . thermostat_index , mode ) </s>
