def query_attributes(self):
        """Return temperature point and modes query attributes."""
        domain = self.state.domain
        units = self.state.tempunit
        response = {}
        if self.state.battery <= configuration['Low_battery_limit']:
            response['exceptionCode'] = 'lowBattery'

        if domain == domains['temperature']:
            response['thermostatMode'] = 'heat'
            current_temp = float(self.state.temp)
            if current_temp is not None:
                test_temp = round(tempConvert(current_temp, _google_temp_unit(units)), 1)
                response['thermostatTemperatureAmbient'] = round(tempConvert(current_temp, _google_temp_unit(units)), 1)
                response['thermostatTemperatureSetpoint'] = round(tempConvert(current_temp, _google_temp_unit(units)), 1)
            current_humidity = self.state.humidity
            if current_humidity is not None:
                response['thermostatHumidityAmbient'] = current_humidity

        if domain == domains['thermostat']:
            if self.state.modes_idx is not None:
                levelName = base64.b64decode(self.state.selectorLevelName).decode('UTF-8').split("|")
                level = self.state.level
                index = int(level / 10)
                response['thermostatMode'] = levelName[index].lower()
            else:
                response['thermostatMode'] = 'heat'
            current_temp = float(self.state.state)
            if current_temp is not None:
                response['thermostatTemperatureAmbient'] = round(tempConvert(current_temp, _google_temp_unit(units)), 1)
            setpoint = float(self.state.setpoint)
            if setpoint is not None:
                response['thermostatTemperatureSetpoint'] = round(tempConvert(setpoint, _google_temp_unit(units)), 1)

        return response
示例#2
0
    def query_attributes(self):
        """Return temperature point and modes query attributes."""
        domain = self.state.domain
        units = self.state.tempunit
        response = {}
        if self.state.battery <= configuration['Low_battery_limit']:
            response['exceptionCode'] = 'lowBattery'

        if domain == tempDOMAIN:
            response['thermostatMode'] = 'heat'
            current_temp = self.state.temp
            if current_temp is not None:
                response['thermostatTemperatureAmbient'] = round(
                    tempConvert(current_temp, _google_temp_unit(units)), 1)
                response['thermostatTemperatureSetpoint'] = round(
                    tempConvert(current_temp, _google_temp_unit(units)), 1)
            current_humidity = self.state.humidity
            if current_humidity is not None:
                response['thermostatHumidityAmbient'] = current_humidity

        if domain == climateDOMAIN:
            response['thermostatMode'] = 'heat'
            current_temp = float(self.state.state)
            if current_temp is not None:
                response['thermostatTemperatureAmbient'] = round(
                    tempConvert(current_temp, _google_temp_unit(units)), 1)
            setpoint = float(self.state.setpoint)
            if setpoint is not None:
                response['thermostatTemperatureSetpoint'] = round(
                    tempConvert(setpoint, _google_temp_unit(units)), 1)

        return response