Fix vallox timestamp sensor (#61216)

* Fix vallox timestamp sensor

* Change old state type
This commit is contained in:
Paulus Schoutsen 2021-12-07 22:35:13 -08:00 committed by GitHub
parent 0780bf142f
commit 3519ad4309
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,7 +56,7 @@ class ValloxSensor(CoordinatorEntity, SensorEntity):
self._attr_unique_id = f"{uuid}-{description.key}" self._attr_unique_id = f"{uuid}-{description.key}"
@property @property
def native_value(self) -> StateType: def native_value(self) -> StateType | datetime:
"""Return the value reported by the sensor.""" """Return the value reported by the sensor."""
if (metric_key := self.entity_description.metric_key) is None: if (metric_key := self.entity_description.metric_key) is None:
return None return None
@ -84,7 +84,7 @@ class ValloxFanSpeedSensor(ValloxSensor):
"""Child class for fan speed reporting.""" """Child class for fan speed reporting."""
@property @property
def native_value(self) -> StateType: def native_value(self) -> StateType | datetime:
"""Return the value reported by the sensor.""" """Return the value reported by the sensor."""
fan_is_on = self.coordinator.data.get_metric(METRIC_KEY_MODE) == MODE_ON fan_is_on = self.coordinator.data.get_metric(METRIC_KEY_MODE) == MODE_ON
return super().native_value if fan_is_on else 0 return super().native_value if fan_is_on else 0
@ -94,7 +94,7 @@ class ValloxFilterRemainingSensor(ValloxSensor):
"""Child class for filter remaining time reporting.""" """Child class for filter remaining time reporting."""
@property @property
def native_value(self) -> StateType: def native_value(self) -> StateType | datetime:
"""Return the value reported by the sensor.""" """Return the value reported by the sensor."""
super_native_value = super().native_value super_native_value = super().native_value
@ -107,7 +107,7 @@ class ValloxFilterRemainingSensor(ValloxSensor):
days_remaining_delta = timedelta(days=days_remaining) days_remaining_delta = timedelta(days=days_remaining)
now = datetime.utcnow().replace(hour=13, minute=0, second=0, microsecond=0) now = datetime.utcnow().replace(hour=13, minute=0, second=0, microsecond=0)
return (now + days_remaining_delta).isoformat() return now + days_remaining_delta
class ValloxCellStateSensor(ValloxSensor): class ValloxCellStateSensor(ValloxSensor):