Ensure _attr_native_value type matches what SensorExtraStoredData produces (#73970)

This commit is contained in:
Aaron Bach 2022-06-29 03:16:06 -06:00 committed by GitHub
parent 1970e36f10
commit 981249d330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -264,7 +264,7 @@ class SensorEntity(Entity):
_attr_device_class: SensorDeviceClass | str | None
_attr_last_reset: datetime | None
_attr_native_unit_of_measurement: str | None
_attr_native_value: StateType | date | datetime = None
_attr_native_value: StateType | date | datetime | Decimal = None
_attr_state_class: SensorStateClass | str | None
_attr_state: None = None # Subclasses of SensorEntity should not set this
_attr_unit_of_measurement: None = (
@ -349,7 +349,7 @@ class SensorEntity(Entity):
return None
@property
def native_value(self) -> StateType | date | datetime:
def native_value(self) -> StateType | date | datetime | Decimal:
"""Return the value reported by the sensor."""
return self._attr_native_value