'Parse temperature sensor value.'

@staticmethod
def _update_temp_sensor(state):

    unit = state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
    temp = util.convert(state.state, float)
    if (temp is None):
        _LOGGER.error('Unable    to    parse    sensor    temperature:    %s', state.state)
        return None
    if (unit == TEMP_FAHRENHEIT):
        return util.temperature.fahrenheit_to_celsius(temp)
    elif (unit == TEMP_CELSIUS):
        return temp
    else:
        _LOGGER.error('Temp    sensor    has    unsupported    unit:    %s    (allowed:    %s,    %s)', unit, TEMP_CELSIUS, TEMP_FAHRENHEIT)
    return None
