From 3b059d83314396f5011e3bdb4cb2c6dc5e519516 Mon Sep 17 00:00:00 2001 From: Jaxom Nutt <40261038+JaxomCS@users.noreply.github.com> Date: Tue, 23 Oct 2018 13:14:00 +0800 Subject: [PATCH 1/3] Bug fix Current version causes 500 error since it is sending an array of from numbers to ClickSend. Changing the from number to 'hass' identifies all messages as coming from Home Assistant making them more recognisable and removes the bug. --- homeassistant/components/notify/clicksend.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/notify/clicksend.py b/homeassistant/components/notify/clicksend.py index c028da2c57942f..512178b7647325 100644 --- a/homeassistant/components/notify/clicksend.py +++ b/homeassistant/components/notify/clicksend.py @@ -69,7 +69,7 @@ def send_message(self, message="", **kwargs): for recipient in self.recipients: data["messages"].append({ 'source': 'hass.notify', - 'from': self.sender, + 'from': 'hass', 'to': recipient, 'body': message, }) From edf85ec1b82b67968a3cf0141df51e6f6aa0c1c1 Mon Sep 17 00:00:00 2001 From: Jaxom Nutt <40261038+JaxomCS@users.noreply.github.com> Date: Tue, 23 Oct 2018 14:20:30 +0800 Subject: [PATCH 2/3] Amendment Changed it to use 'hass' as the default instead of defaulting to the recipient which is the array. Would have worked if users set their own name but users who were using the default were experiencing the issue. --- homeassistant/components/notify/clicksend.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/notify/clicksend.py b/homeassistant/components/notify/clicksend.py index 512178b7647325..c26cddc1e44088 100644 --- a/homeassistant/components/notify/clicksend.py +++ b/homeassistant/components/notify/clicksend.py @@ -29,7 +29,7 @@ def validate_sender(config): """Set the optional sender name if sender name is not provided.""" if CONF_SENDER in config: return config - config[CONF_SENDER] = config[CONF_RECIPIENT] + config[CONF_SENDER] = 'hass' return config @@ -61,7 +61,7 @@ def __init__(self, config): self.username = config.get(CONF_USERNAME) self.api_key = config.get(CONF_API_KEY) self.recipients = config.get(CONF_RECIPIENT) - self.sender = config.get(CONF_SENDER, CONF_RECIPIENT) + self.sender = config.get(CONF_SENDER) def send_message(self, message="", **kwargs): """Send a message to a user.""" @@ -69,7 +69,7 @@ def send_message(self, message="", **kwargs): for recipient in self.recipients: data["messages"].append({ 'source': 'hass.notify', - 'from': 'hass', + 'from': self.sender, 'to': recipient, 'body': message, }) From f3e01200dcacd37c5819a33974bca755419cfbf8 Mon Sep 17 00:00:00 2001 From: Jaxom Nutt <40261038+JaxomCS@users.noreply.github.com> Date: Tue, 23 Oct 2018 15:27:17 +0800 Subject: [PATCH 3/3] Added DEFAULT_SENDER variable --- homeassistant/components/notify/clicksend.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/notify/clicksend.py b/homeassistant/components/notify/clicksend.py index c26cddc1e44088..5506d6ed6d040d 100644 --- a/homeassistant/components/notify/clicksend.py +++ b/homeassistant/components/notify/clicksend.py @@ -22,6 +22,8 @@ BASE_API_URL = 'https://rest.clicksend.com/v3' +DEFAULT_SENDER = 'hass' + HEADERS = {CONTENT_TYPE: CONTENT_TYPE_JSON} @@ -29,7 +31,7 @@ def validate_sender(config): """Set the optional sender name if sender name is not provided.""" if CONF_SENDER in config: return config - config[CONF_SENDER] = 'hass' + config[CONF_SENDER] = DEFAULT_SENDER return config