From 0022a15636934c778ca17ad2c28e817301b117fa Mon Sep 17 00:00:00 2001 From: ribbal Date: Tue, 30 Jul 2024 11:51:47 +0100 Subject: [PATCH 1/4] fix message formatting --- custom_components/greenapi/notify.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/greenapi/notify.py b/custom_components/greenapi/notify.py index e062d09..f2dde77 100644 --- a/custom_components/greenapi/notify.py +++ b/custom_components/greenapi/notify.py @@ -48,7 +48,7 @@ def send_message(self, message="", **kwargs): title = kwargs.get(ATTR_TITLE) if title is not None: title = f"*{title}*" - message = f"{title} \n {message}" + message = f"{title}\n{message}" data = kwargs.get(ATTR_DATA) target = kwargs.get(ATTR_TARGET)[0] if kwargs.get(ATTR_TARGET) is not None else self._target #Allow setting the target from either the service-call or the service config. Service call target can override the default config. _LOGGER.info(f"Sending message to {target}") From fc1349877dc5027fc567fd54adcf3ed30db8e61c Mon Sep 17 00:00:00 2001 From: Tomer Klein Date: Tue, 13 Aug 2024 12:31:00 +0300 Subject: [PATCH 2/4] Update notify.py --- custom_components/greenapi/notify.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/greenapi/notify.py b/custom_components/greenapi/notify.py index e062d09..6fda492 100644 --- a/custom_components/greenapi/notify.py +++ b/custom_components/greenapi/notify.py @@ -32,7 +32,7 @@ def get_service(hass, config, discovery_info=None): class GreenAPINotificationService(BaseNotificationService): - def __init__(self, title, token,instance_id, target): + def __init__(self, title, token,instance_id, target, linkPreview=False): """Initialize the service.""" self._title = title self._token = token @@ -64,4 +64,4 @@ def send_message(self, message="", **kwargs): else: self._greenAPI.sending.sendMessage(target, message) except Exception as e: - _LOGGER.error("Sending message to %s: has failed with the following error %s", kwargs.get(ATTR_TARGET)[0] ,str(e)) \ No newline at end of file + _LOGGER.error("Sending message to %s: has failed with the following error %s", kwargs.get(ATTR_TARGET)[0] ,str(e)) From b1356ca33bbe6472441e17f172a66ed4e03fbe9a Mon Sep 17 00:00:00 2001 From: Tomer Klein Date: Tue, 13 Aug 2024 12:32:09 +0300 Subject: [PATCH 3/4] Update manifest.json --- custom_components/greenapi/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/greenapi/manifest.json b/custom_components/greenapi/manifest.json index 2c405db..afd46e2 100644 --- a/custom_components/greenapi/manifest.json +++ b/custom_components/greenapi/manifest.json @@ -8,5 +8,5 @@ "iot_class": "local_polling", "issue_tracker": "https://github.com/t0mer/green-api-custom-notifier", "requirements": ["whatsapp-api-client-python"], - "version": "0.3.0" + "version": "0.4.0" } From d671adda0747d25e9908d1332da5c181a2c3cc64 Mon Sep 17 00:00:00 2001 From: Tomer Klein Date: Tue, 13 Aug 2024 12:34:11 +0300 Subject: [PATCH 4/4] Update notify.py --- custom_components/greenapi/notify.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/greenapi/notify.py b/custom_components/greenapi/notify.py index 6fda492..84e3a24 100644 --- a/custom_components/greenapi/notify.py +++ b/custom_components/greenapi/notify.py @@ -32,7 +32,7 @@ def get_service(hass, config, discovery_info=None): class GreenAPINotificationService(BaseNotificationService): - def __init__(self, title, token,instance_id, target, linkPreview=False): + def __init__(self, title, token,instance_id, target): """Initialize the service.""" self._title = title self._token = token @@ -62,6 +62,6 @@ def send_message(self, message="", **kwargs): file_name = basename(url.path) send_file_by_url_response = self._greenAPI.sending.sendFileByUrl(target, url_file, file_name, caption=message) else: - self._greenAPI.sending.sendMessage(target, message) + self._greenAPI.sending.sendMessage(target, message, linkPreview=False) except Exception as e: _LOGGER.error("Sending message to %s: has failed with the following error %s", kwargs.get(ATTR_TARGET)[0] ,str(e))