From a5d520b60307dbdf2961d8340b1ef9377f3a2a76 Mon Sep 17 00:00:00 2001 From: fb22 <4872297+fb22@users.noreply.github.com> Date: Wed, 3 Jun 2020 02:32:08 +0200 Subject: [PATCH] Add llamalab_automate optional message delivery priority (#34234) * Add optional message delivery priority * Sort components.notify import * Sort components.notify import --- .../components/llamalab_automate/notify.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/llamalab_automate/notify.py b/homeassistant/components/llamalab_automate/notify.py index f093edbbc6b..b4ed9a4e628 100644 --- a/homeassistant/components/llamalab_automate/notify.py +++ b/homeassistant/components/llamalab_automate/notify.py @@ -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, }