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:
Philipp Danner 2019-12-22 19:46:53 +01:00 committed by Martin Hjelmare
parent 83768be814
commit 70f8bfbd4f
6 changed files with 72 additions and 32 deletions

View file

@ -22,10 +22,16 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
keba = hass.data[DOMAIN]
sensors = [
KebaBinarySensor(keba, "Online", "Wallbox", DEVICE_CLASS_CONNECTIVITY),
KebaBinarySensor(keba, "Plug", "Plug", DEVICE_CLASS_PLUG),
KebaBinarySensor(keba, "State", "Charging state", DEVICE_CLASS_POWER),
KebaBinarySensor(keba, "Tmo FS", "Failsafe Mode", DEVICE_CLASS_SAFETY),
KebaBinarySensor(
keba, "Online", "Status", "device_state", DEVICE_CLASS_CONNECTIVITY
),
KebaBinarySensor(keba, "Plug", "Plug", "plug_state", DEVICE_CLASS_PLUG),
KebaBinarySensor(
keba, "State", "Charging State", "charging_state", DEVICE_CLASS_POWER
),
KebaBinarySensor(
keba, "Tmo FS", "Failsafe Mode", "failsafe_mode_state", DEVICE_CLASS_SAFETY
),
]
async_add_entities(sensors)
@ -33,11 +39,12 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
class KebaBinarySensor(BinarySensorDevice):
"""Representation of a binary sensor of a KEBA charging station."""
def __init__(self, keba, key, sensor_name, device_class):
def __init__(self, keba, key, name, entity_type, device_class):
"""Initialize the KEBA Sensor."""
self._key = key
self._keba = keba
self._name = sensor_name
self._name = name
self._entity_type = entity_type
self._device_class = device_class
self._is_on = None
self._attributes = {}
@ -50,12 +57,12 @@ class KebaBinarySensor(BinarySensorDevice):
@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):