Add llamalab_automate optional message delivery priority (#34234)
* Add optional message delivery priority * Sort components.notify import * Sort components.notify import
This commit is contained in:
parent
d2e6b863b7
commit
a5d520b603
1 changed files with 17 additions and 2 deletions
|
@ -4,13 +4,19 @@ import logging
|
||||||
import requests
|
import requests
|
||||||
import voluptuous as vol
|
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.const import CONF_API_KEY, CONF_DEVICE, HTTP_OK
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
_RESOURCE = "https://llamalab.com/automate/cloud/message"
|
_RESOURCE = "https://llamalab.com/automate/cloud/message"
|
||||||
|
|
||||||
|
ATTR_PRIORITY = "priority"
|
||||||
|
|
||||||
CONF_TO = "to"
|
CONF_TO = "to"
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
|
@ -42,11 +48,20 @@ class AutomateNotificationService(BaseNotificationService):
|
||||||
|
|
||||||
def send_message(self, message="", **kwargs):
|
def send_message(self, message="", **kwargs):
|
||||||
"""Send a message to a user."""
|
"""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 = {
|
data = {
|
||||||
"secret": self._secret,
|
"secret": self._secret,
|
||||||
"to": self._recipient,
|
"to": self._recipient,
|
||||||
"device": self._device,
|
"device": self._device,
|
||||||
|
"priority": priority,
|
||||||
"payload": message,
|
"payload": message,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue