Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@property
def temperature(self):
"""Temperature."""
return self.convert_temperature(self.raw["state"].get("temperature"))
@staticmethod
def convert_temperature(temperature):
"""Convert temperature to celsius"""
if temperature is None:
return None
return round(float(temperature) / 100, 1)
class Thermostat(Temperature):
"""Thermostat "sensor"."""
BINARY = False
ZHATYPE = ("ZHAThermostat", "CLIPThermostat")
@property
def heatsetpoint(self):
"""Heating setpoint"""
return self.convert_temperature(self.raw["config"].get("heatsetpoint"))
@property
def locked(self):
""""""
return self.raw["config"].get("locked")
@property
def secondary_temperature(self):
"""Extra temperature available on some Xiaomi devices."""
if "temperature" not in self.raw["config"]:
return None
return Temperature.convert_temperature(self.raw["config"].get("temperature"))
Alarm,
Battery,
CarbonMonoxide,
Consumption,
Daylight,
Fire,
GenericFlag,
GenericStatus,
Humidity,
LightLevel,
OpenClose,
Power,
Presence,
Pressure,
Switch,
Temperature,
Thermostat,
Vibration,
Water,
)
def create_sensor(sensor_id, raw, request):
"""Simplify creating sensor by not needing to know type."""
for sensor_class in SENSOR_CLASSES:
if raw["type"] in sensor_class.ZHATYPE:
return sensor_class(sensor_id, raw, request)
_LOGGER.info("Unsupported sensor type %s (%s)", raw["type"], raw["name"])
return DeconzSensor(sensor_id, raw, request)