From eba5b50e5887024b02c432cc74de2ab595b69a77 Mon Sep 17 00:00:00 2001 From: matlimatli Date: Wed, 3 Jun 2020 19:28:02 +0200 Subject: [PATCH] Add support for showing text on Keba EV chargers (#36056) * Add support for showing text on Keba EV chargers * Changed implementation to use the notify interface * Removed stale references to set_text * Clean up Co-authored-by: Martin Hjelmare --- homeassistant/components/keba/__init__.py | 2 +- homeassistant/components/keba/manifest.json | 2 +- homeassistant/components/keba/notify.py | 33 +++++++++++++++++++++ requirements_all.txt | 2 +- 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 homeassistant/components/keba/notify.py diff --git a/homeassistant/components/keba/__init__.py b/homeassistant/components/keba/__init__.py index cbc9428b2ea..764110f94b9 100644 --- a/homeassistant/components/keba/__init__.py +++ b/homeassistant/components/keba/__init__.py @@ -12,7 +12,7 @@ import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) DOMAIN = "keba" -SUPPORTED_COMPONENTS = ["binary_sensor", "sensor", "lock"] +SUPPORTED_COMPONENTS = ["binary_sensor", "sensor", "lock", "notify"] CONF_RFID = "rfid" CONF_FS = "failsafe" diff --git a/homeassistant/components/keba/manifest.json b/homeassistant/components/keba/manifest.json index 0b1b72d99ab..29c4ec86c49 100644 --- a/homeassistant/components/keba/manifest.json +++ b/homeassistant/components/keba/manifest.json @@ -2,6 +2,6 @@ "domain": "keba", "name": "Keba Charging Station", "documentation": "https://www.home-assistant.io/integrations/keba", - "requirements": ["keba-kecontact==1.0.0"], + "requirements": ["keba-kecontact==1.1.0"], "codeowners": ["@dannerph"] } diff --git a/homeassistant/components/keba/notify.py b/homeassistant/components/keba/notify.py new file mode 100644 index 00000000000..7b3f23277a6 --- /dev/null +++ b/homeassistant/components/keba/notify.py @@ -0,0 +1,33 @@ +"""Support for Keba notifications.""" +import logging + +from homeassistant.components.notify import ATTR_DATA, BaseNotificationService + +from . import DOMAIN + +_LOGGER = logging.getLogger(__name__) + + +async def async_get_service(hass, config, discovery_info=None): + """Return the notify service.""" + + client = hass.data[DOMAIN] + return KebaNotificationService(client) + + +class KebaNotificationService(BaseNotificationService): + """Notification service for KEBA EV Chargers.""" + + def __init__(self, client): + """Initialize the service.""" + self._client = client + + async def async_send_message(self, message="", **kwargs): + """Send the message.""" + text = message.replace(" ", "$") # Will be translated back by the display + + data = kwargs[ATTR_DATA] or {} + min_time = float(data.get("min_time", 2)) + max_time = float(data.get("max_time", 10)) + + await self._client.set_text(text, min_time, max_time) diff --git a/requirements_all.txt b/requirements_all.txt index 065b06fda40..1e17ef46fae 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -807,7 +807,7 @@ jsonrpc-websocket==0.6 kaiterra-async-client==0.0.2 # homeassistant.components.keba -keba-kecontact==1.0.0 +keba-kecontact==1.1.0 # homeassistant.scripts.keyring keyring==21.2.0