diff --git a/custom_components/fuel_prices/manifest.json b/custom_components/fuel_prices/manifest.json index b3d9897..7da2cca 100644 --- a/custom_components/fuel_prices/manifest.json +++ b/custom_components/fuel_prices/manifest.json @@ -13,7 +13,7 @@ "xmltodict", "brotli", "these-united-states==1.1.0.21", - "pyfuelprices==2024.11.4" + "pyfuelprices==2024.11.5" ], "ssdp": [], "version": "0.0.0", diff --git a/custom_components/fuel_prices/sensor.py b/custom_components/fuel_prices/sensor.py index 6453495..2ed0c93 100644 --- a/custom_components/fuel_prices/sensor.py +++ b/custom_components/fuel_prices/sensor.py @@ -10,6 +10,7 @@ from datetime import datetime, timedelta from homeassistant.components.sensor import SensorEntity +from homeassistant.components.sensor.const import SensorDeviceClass from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_RADIUS, CONF_NAME, STATE_UNKNOWN from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -117,6 +118,13 @@ def state_class(self) -> str: return None return "total" + @property + def device_class(self) -> SensorDeviceClass | None: + """Return device class.""" + if isinstance(self.native_value, str): + return None + return SensorDeviceClass.MONETARY + class CheapestFuelSensor(CheapestFuelEntity, SensorEntity): """A entity that shows the cheapest fuel for an area.""" @@ -126,6 +134,7 @@ class CheapestFuelSensor(CheapestFuelEntity, SensorEntity): _last_update = None _next_update = datetime.now() _cached_data = None + _attr_device_class = SensorDeviceClass.MONETARY async def async_update(self) -> None: """Update device data.""" @@ -176,6 +185,6 @@ def extra_state_attributes(self) -> Mapping[str, Any] | None: """Return extra state attributes.""" data = self._cached_data data["area"] = self._area - data["last_updated"] = self._last_update - data["next_update"] = self._next_update + data["sensor_last_poll"] = self._last_update + data["sensor_next_poll"] = self._next_update return data diff --git a/requirements.txt b/requirements.txt index db5dbcb..fdf28eb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,4 @@ colorlog==6.7.0 homeassistant==2024.11.0 pip>=21.0,<23.2 ruff==0.0.292 -pyfuelprices==2024.11.4 \ No newline at end of file +pyfuelprices==2024.11.5 \ No newline at end of file