Bug fix for clicksend (#17713)

* 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.

* 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.

* Added DEFAULT_SENDER variable
This commit is contained in:
Jaxom Nutt 2018-10-23 16:28:49 +08:00 committed by Daniel Høyer Iversen
parent 324587b2db
commit 44e35b7f52
1 changed files with 4 additions and 2 deletions

View File

@ -22,6 +22,8 @@ _LOGGER = logging.getLogger(__name__)
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] = config[CONF_RECIPIENT]
config[CONF_SENDER] = DEFAULT_SENDER
return config
@ -61,7 +63,7 @@ class ClicksendNotificationService(BaseNotificationService):
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."""