Use identity check for ESPHome sensor device_class (#121828)

This commit is contained in:
J. Nick Koston 2024-07-11 22:47:32 -05:00 committed by GitHub
parent df8c949884
commit 76d6a1fe13
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -99,7 +99,7 @@ class EsphomeSensor(EsphomeEntity[SensorInfo, SensorState], SensorEntity):
state = self._state
if state.missing_state or not math.isfinite(state.state):
return None
if self._attr_device_class == SensorDeviceClass.TIMESTAMP:
if self._attr_device_class is SensorDeviceClass.TIMESTAMP:
return dt_util.utc_from_timestamp(state.state)
return f"{state.state:.{self._static_info.accuracy_decimals}f}"