Add llamalab_automate optional message delivery priority ()

* Add optional message delivery priority

* Sort components.notify import

* Sort components.notify import
This commit is contained in:
fb22 2020-06-03 02:32:08 +02:00 committed by GitHub
parent d2e6b863b7
commit a5d520b603
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,13 +4,19 @@ import logging
import requests
import voluptuous as vol
from homeassistant.components.notify import PLATFORM_SCHEMA, BaseNotificationService
from homeassistant.components.notify import (
ATTR_DATA,
PLATFORM_SCHEMA,
BaseNotificationService,
)
from homeassistant.const import CONF_API_KEY, CONF_DEVICE, HTTP_OK
from homeassistant.helpers import config_validation as cv
_LOGGER = logging.getLogger(__name__)
_RESOURCE = "https://llamalab.com/automate/cloud/message"
ATTR_PRIORITY = "priority"
CONF_TO = "to"
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
@ -42,11 +48,20 @@ class AutomateNotificationService(BaseNotificationService):
def send_message(self, message="", **kwargs):
"""Send a message to a user."""
_LOGGER.debug("Sending to: %s, %s", self._recipient, str(self._device))
# Extract params from data dict
data = dict(kwargs.get(ATTR_DATA) or {})
priority = data.get(ATTR_PRIORITY, "Normal")
_LOGGER.debug(
"Sending to: %s, %s, prio: %s", self._recipient, str(self._device), priority
)
data = {
"secret": self._secret,
"to": self._recipient,
"device": self._device,
"priority": priority,
"payload": message,
}