From cd81e45c713b471eaf77c3ae21122cb846721fcd Mon Sep 17 00:00:00 2001 From: Frederik Kemner Date: Tue, 29 Oct 2024 22:18:59 +0100 Subject: [PATCH] Replace DEVICE_CLASS_TIMESTAMP with SensorDeviceClass.TIMESTAMP (#23) Update sensor.py to use SensorDeviceClass.TIMESTAMP instead of the deprecated DEVICE_CLASS_TIMESTAMP, ensuring compatibility with Home Assistant Core 2025.1. --- custom_components/hass_stadtreinigung_hamburg/sensor.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/custom_components/hass_stadtreinigung_hamburg/sensor.py b/custom_components/hass_stadtreinigung_hamburg/sensor.py index 86d8cc4..be47c6f 100644 --- a/custom_components/hass_stadtreinigung_hamburg/sensor.py +++ b/custom_components/hass_stadtreinigung_hamburg/sensor.py @@ -1,13 +1,12 @@ import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorDeviceClass import homeassistant.helpers.config_validation as cv from homeassistant.util import Throttle, slugify from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_NAME, DEVICE_CLASS_TIMESTAMP +from homeassistant.const import CONF_NAME from homeassistant.helpers.entity import Entity import logging -from datetime import datetime -from datetime import timedelta +from datetime import datetime, timedelta from homeassistant.core import HomeAssistant from typing import Optional @@ -99,7 +98,7 @@ def unit_of_measurement(self): @property def device_class(self) -> Optional[str]: """Return the class of this device, from component DEVICE_CLASSES.""" - return DEVICE_CLASS_TIMESTAMP + return SensorDeviceClass.TIMESTAMP @property def extra_state_attributes(self):