diff --git a/custom_components/tesla_custom/sensor.py b/custom_components/tesla_custom/sensor.py index 14e4c9f1..dbedd8b6 100644 --- a/custom_components/tesla_custom/sensor.py +++ b/custom_components/tesla_custom/sensor.py @@ -16,6 +16,7 @@ UnitOfPressure, UnitOfSpeed, UnitOfTemperature, + UnitOfTime, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory @@ -73,6 +74,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_entitie entities.append(TeslaCarArrivalTime(car, coordinator)) entities.append(TeslaCarDistanceToArrival(car, coordinator)) entities.append(TeslaCarDataUpdateTime(car, coordinator)) + entities.append(TeslaCarPollingInterval(car, coordinator)) for energy_site_id, energysite in energysites.items(): coordinator = coordinators[energy_site_id] @@ -649,3 +651,19 @@ def native_value(self) -> datetime: else: date_obj = last_time.replace(tzinfo=dt.UTC) return date_obj + + +class TeslaCarPollingInterval(TeslaCarEntity, SensorEntity): + """Representation of a Tesla car polling interval.""" + + type = "polling interval" + _attr_device_class = SensorDeviceClass.DURATION + _attr_state_class = SensorStateClass.MEASUREMENT + _attr_native_unit_of_measurement = UnitOfTime.SECONDS + _attr_entity_category = EntityCategory.DIAGNOSTIC + _attr_icon = "mdi:timer-sync" + + @property + def native_value(self) -> int: + """Return the update time interval.""" + return self.coordinator.controller.get_update_interval_vin(vin=self._car.vin)