diff --git a/homeassistant/components/esphome/sensor.py b/homeassistant/components/esphome/sensor.py
index 4c99463505f08f889eee8c3dbdc6037a54b7dc05..0742bebed2893e20253c21191060fb9b063dfc5b 100644
--- a/homeassistant/components/esphome/sensor.py
+++ b/homeassistant/components/esphome/sensor.py
@@ -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}"