<s> """<STR_LIT>""" <EOL> import logging <EOL> from homeassistant . const import CONF_NAME , DEVICE_DEFAULT_NAME , TEMP_FAHRENHEIT <EOL> from homeassistant . helpers . entity import Entity <EOL> _LOGGER = logging . getLogger ( __name__ ) <EOL> REQUIREMENTS = [ '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ] <EOL> def setup_platform ( hass , config , add_devices_callback , discovery_info = None ) : <EOL> """<STR_LIT>""" <EOL> from temperusb . temper import TemperHandler <EOL> temp_unit = hass . config . temperature_unit <EOL> name = config . get ( CONF_NAME , DEVICE_DEFAULT_NAME ) <EOL> temper_devices = TemperHandler ( ) . get_devices ( ) <EOL> add_devices_callback ( [ TemperSensor ( dev , temp_unit , name + '<STR_LIT:_>' + str ( idx ) ) <EOL> for idx , dev in enumerate ( temper_devices ) ] ) <EOL> class TemperSensor ( Entity ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , temper_device , temp_unit , name ) : <EOL> """<STR_LIT>""" <EOL> self . temper_device = temper_device <EOL> self . temp_unit = temp_unit <EOL> self . current_value = None <EOL> self . _name = name <EOL> @ property <EOL> def name ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _name <EOL> @ property <EOL> def state ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . current_value <EOL> @ property <EOL> def unit_of_measurement ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . temp_unit <EOL> def update ( self ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> format_str = ( '<STR_LIT>' if self . temp_unit == TEMP_FAHRENHEIT <EOL> else '<STR_LIT>' ) <EOL> self . current_value = self . temper_device . get_temperature ( format_str ) <EOL> except IOError : <EOL> _LOGGER . error ( '<STR_LIT>' <EOL> '<STR_LIT>' ) </s>
