diff --git a/homeassistant/components/verisure/sensor.py b/homeassistant/components/verisure/sensor.py index 028e5877e51..4336f52f159 100644 --- a/homeassistant/components/verisure/sensor.py +++ b/homeassistant/components/verisure/sensor.py @@ -56,6 +56,8 @@ class VerisureThermometer(CoordinatorEntity, SensorEntity): """Initialize the sensor.""" super().__init__(coordinator) self.serial_number = serial_number + self._device_class = DEVICE_CLASS_TEMPERATURE + self._unit_of_measurement = TEMP_CELSIUS @property def name(self) -> str: @@ -68,11 +70,6 @@ class VerisureThermometer(CoordinatorEntity, SensorEntity): """Return the unique ID for this entity.""" return f"{self.serial_number}_temperature" - @property - def device_class(self) -> str: - """Return the class of this entity.""" - return DEVICE_CLASS_TEMPERATURE - @property def device_info(self) -> DeviceInfo: """Return device information about this entity.""" @@ -103,11 +100,6 @@ class VerisureThermometer(CoordinatorEntity, SensorEntity): and "temperature" in self.coordinator.data["climate"][self.serial_number] ) - @property - def unit_of_measurement(self) -> str: - """Return the unit of measurement of this entity.""" - return TEMP_CELSIUS - class VerisureHygrometer(CoordinatorEntity, SensorEntity): """Representation of a Verisure hygrometer.""" @@ -119,6 +111,9 @@ class VerisureHygrometer(CoordinatorEntity, SensorEntity): ) -> None: """Initialize the sensor.""" super().__init__(coordinator) + self._device_class = DEVICE_CLASS_HUMIDITY + self._unit_of_measurement = PERCENTAGE + self.serial_number = serial_number @property @@ -132,11 +127,6 @@ class VerisureHygrometer(CoordinatorEntity, SensorEntity): """Return the unique ID for this entity.""" return f"{self.serial_number}_humidity" - @property - def device_class(self) -> str: - """Return the class of this entity.""" - return DEVICE_CLASS_HUMIDITY - @property def device_info(self) -> DeviceInfo: """Return device information about this entity.""" @@ -167,11 +157,6 @@ class VerisureHygrometer(CoordinatorEntity, SensorEntity): and "humidity" in self.coordinator.data["climate"][self.serial_number] ) - @property - def unit_of_measurement(self) -> str: - """Return the unit of measurement of this entity.""" - return PERCENTAGE - class VerisureMouseDetection(CoordinatorEntity, SensorEntity): """Representation of a Verisure mouse detector.""" @@ -183,6 +168,8 @@ class VerisureMouseDetection(CoordinatorEntity, SensorEntity): ) -> None: """Initialize the sensor.""" super().__init__(coordinator) + self._unit_of_measurement = "Mice" + self.serial_number = serial_number @property @@ -222,8 +209,3 @@ class VerisureMouseDetection(CoordinatorEntity, SensorEntity): and self.serial_number in self.coordinator.data["mice"] and "detections" in self.coordinator.data["mice"][self.serial_number] ) - - @property - def unit_of_measurement(self) -> str: - """Return the unit of measurement of this entity.""" - return "Mice"