1 """Support for KEBA charging station sensors."""
3 from __future__
import annotations
8 SensorEntityDescription,
16 from .
import DOMAIN, KebaHandler
22 async_add_entities: AddEntitiesCallback,
23 discovery_info: DiscoveryInfoType |
None =
None,
25 """Set up the KEBA charging station platform."""
26 if discovery_info
is None:
29 keba = hass.data[DOMAIN]
38 native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
39 device_class=SensorDeviceClass.CURRENT,
48 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
49 device_class=SensorDeviceClass.ENERGY,
57 name=
"Charging Power",
58 native_unit_of_measurement=UnitOfPower.KILO_WATT,
59 device_class=SensorDeviceClass.POWER,
60 state_class=SensorStateClass.MEASUREMENT,
68 name=
"Session Energy",
69 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
70 device_class=SensorDeviceClass.ENERGY,
79 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
80 device_class=SensorDeviceClass.ENERGY,
81 state_class=SensorStateClass.TOTAL_INCREASING,
89 """The entity class for KEBA charging stations sensors."""
91 _attr_should_poll =
False
97 description: SensorEntityDescription,
99 """Initialize the KEBA Sensor."""
103 self.
_attr_name_attr_name = f
"{keba.device_name} {description.name}"
106 self._attributes: dict[str, str] = {}
110 """Return the state attributes of the binary sensor."""
111 return self._attributes
114 """Get latest cached states from the device."""
118 self._attributes[
"power_factor"] = self.
_keba_keba.
get_value(
"PF")
126 self._attributes[
"max_current_hardware"] = self.
_keba_keba.
get_value(
"Curr HW")
129 """Schedule a state update."""
133 """Add update callback after being added to hass."""
None async_added_to_hass(self)
None update_callback(self)
dict[str, str] extra_state_attributes(self)
None __init__(self, KebaHandler keba, str entity_type, SensorEntityDescription description)
None async_schedule_update_ha_state(self, bool force_refresh=False)
None async_setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback async_add_entities, DiscoveryInfoType|None discovery_info=None)
float|int|str|None get_value(Sensor sensor, str field)