<s> """<STR_LIT>""" <EOL> import logging <EOL> from homeassistant . components import ecobee <EOL> from homeassistant . const import TEMP_FAHRENHEIT <EOL> from homeassistant . helpers . entity import Entity <EOL> DEPENDENCIES = [ '<STR_LIT>' ] <EOL> SENSOR_TYPES = { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , TEMP_FAHRENHEIT ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT:%>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , None ] <EOL> } <EOL> _LOGGER = logging . getLogger ( __name__ ) <EOL> ECOBEE_CONFIG_FILE = '<STR_LIT>' <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> dev = list ( ) <EOL> for index in range ( len ( data . ecobee . thermostats ) ) : <EOL> for sensor in data . ecobee . get_remote_sensors ( index ) : <EOL> for item in sensor [ '<STR_LIT>' ] : <EOL> if item [ '<STR_LIT:type>' ] not in ( '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ) : <EOL> continue <EOL> dev . append ( EcobeeSensor ( sensor [ '<STR_LIT:name>' ] , item [ '<STR_LIT:type>' ] , index ) ) <EOL> add_devices ( dev ) <EOL> class EcobeeSensor ( Entity ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , sensor_name , sensor_type , sensor_index ) : <EOL> """<STR_LIT>""" <EOL> self . _name = sensor_name + '<STR_LIT:U+0020>' + SENSOR_TYPES [ sensor_type ] [ <NUM_LIT:0> ] <EOL> self . sensor_name = sensor_name <EOL> self . type = sensor_type <EOL> self . index = sensor_index <EOL> self . _state = None <EOL> self . _unit_of_measurement = SENSOR_TYPES [ sensor_type ] [ <NUM_LIT:1> ] <EOL> self . update ( ) <EOL> @ property <EOL> def name ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _name . rstrip ( ) <EOL> @ property <EOL> def state ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _state <EOL> @ property <EOL> def unique_id ( self ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" . format ( self . _name , self . index ) <EOL> @ property <EOL> def unit_of_measurement ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _unit_of_measurement <EOL> def update ( self ) : <EOL> """<STR_LIT>""" <EOL> data = ecobee . NETWORK <EOL> data . update ( ) <EOL> for sensor in data . ecobee . get_remote_sensors ( self . index ) : <EOL> for item in sensor [ '<STR_LIT>' ] : <EOL> if ( <EOL> item [ '<STR_LIT:type>' ] == self . type and <EOL> self . type == '<STR_LIT>' and <EOL> self . sensor_name == sensor [ '<STR_LIT:name>' ] ) : <EOL> self . _state = float ( item [ '<STR_LIT:value>' ] ) / <NUM_LIT:10> <EOL> elif ( <EOL> item [ '<STR_LIT:type>' ] == self . type and <EOL> self . type == '<STR_LIT>' and <EOL> self . sensor_name == sensor [ '<STR_LIT:name>' ] ) : <EOL> self . _state = item [ '<STR_LIT:value>' ] <EOL> elif ( <EOL> item [ '<STR_LIT:type>' ] == self . type and <EOL> self . type == '<STR_LIT>' and <EOL> self . sensor_name == sensor [ '<STR_LIT:name>' ] ) : <EOL> self . _state = item [ '<STR_LIT:value>' ] </s>
