Skip to content

Commit

Permalink
Merge pull request #951 from alandtse/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
alandtse authored Apr 26, 2024
2 parents f315261 + d5040ac commit caed20d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions custom_components/tesla_custom/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
UnitOfPressure,
UnitOfSpeed,
UnitOfTemperature,
UnitOfTime,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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)

0 comments on commit caed20d

Please sign in to comment.