Update Integration of Keba charging station (#30125)
* fixed parsing of current to float in service set_current * Added optional name in the config file in order to get a better entety naming (easier to find) * fix parsing of all parameters to service calls * addressed code review comments + updated pypi dependency * config name imported from cont.py + minor naming changes to be more clear about the meaning of a sensor * removed name in config again, use product name gathered from the charging station instead * implemented suggested changes * changed variable naming as requested
This commit is contained in:
1 parent
83768be814
commit
70f8bfbd4f
6 files changed
+72
-32
No files matched your search
@@ -17,15 +17,40 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||
keba = hass.data[DOMAIN]
|
||||
|
||||
sensors = [
|
||||
KebaSensor(keba, "Curr user", "Max current", "mdi:flash", "A"),
|
||||
KebaSensor(keba, "Curr user", "Max Current", "max_current", "mdi:flash", "A"),
|
||||
KebaSensor(
|
||||
keba, "Setenergy", "Energy target", "mdi:gauge", ENERGY_KILO_WATT_HOUR
|
||||
keba,
|
||||
"Setenergy",
|
||||
"Energy Target",
|
||||
"energy_target",
|
||||
"mdi:gauge",
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
),
|
||||
KebaSensor(keba, "P", "Charging power", "mdi:flash", "kW", DEVICE_CLASS_POWER),
|
||||
KebaSensor(
|
||||
keba, "E pres", "Session energy", "mdi:gauge", ENERGY_KILO_WATT_HOUR
|
||||
keba,
|
||||
"P",
|
||||
"Charging Power",
|
||||
"charging_power",
|
||||
"mdi:flash",
|
||||
"kW",
|
||||
DEVICE_CLASS_POWER,
|
||||
),
|
||||
KebaSensor(
|
||||
keba,
|
||||
"E pres",
|
||||
"Session Energy",
|
||||
"session_energy",
|
||||
"mdi:gauge",
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
),
|
||||
KebaSensor(
|
||||
keba,
|
||||
"E total",
|
||||
"Total Energy",
|
||||
"total_energy",
|
||||
"mdi:gauge",
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
),
|
||||
KebaSensor(keba, "E total", "Total Energy", "mdi:gauge", ENERGY_KILO_WATT_HOUR),
|
||||
]
|
||||
async_add_entities(sensors)
|
||||
|
||||
@@ -33,14 +58,16 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||
class KebaSensor(Entity):
|
||||
"""The entity class for KEBA charging stations sensors."""
|
||||
|
||||
def __init__(self, keba, key, name, icon, unit, device_class=None):
|
||||
def __init__(self, keba, key, name, entity_type, icon, unit, device_class=None):
|
||||
"""Initialize the KEBA Sensor."""
|
||||
self._key = key
|
||||
self._keba = keba
|
||||
self._key = key
|
||||
self._name = name
|
||||
self._device_class = device_class
|
||||
self._entity_type = entity_type
|
||||
self._icon = icon
|
||||
self._unit = unit
|
||||
self._device_class = device_class
|
||||
|
||||
self._state = None
|
||||
self._attributes = {}
|
||||
|
||||
@@ -52,12 +79,12 @@ class KebaSensor(Entity):
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the unique ID of the binary sensor."""
|
||||
return f"{self._keba.device_name}_{self._name}"
|
||||
return f"{self._keba.device_id}_{self._entity_type}"
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the device."""
|
||||
return self._name
|
||||
return f"{self._keba.device_name} {self._name}"
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
|
||||
Reference in new issue
Block a user