From 9a72a401f893bd7443f6cca4ac8a29185bac93a3 Mon Sep 17 00:00:00 2001 From: Danny Tsang Date: Sun, 29 Oct 2023 15:39:55 +0000 Subject: [PATCH] Add icon (ID) and duration as parameters to Awtrix light. --- packages/integrations/awtrix_light.yaml | 49 ++++++++++++++++++++----- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/packages/integrations/awtrix_light.yaml b/packages/integrations/awtrix_light.yaml index 74523efd..55391c58 100644 --- a/packages/integrations/awtrix_light.yaml +++ b/packages/integrations/awtrix_light.yaml @@ -5,17 +5,48 @@ script: alias: Send Bedroom Clock Notification fields: message: - description: Message to post + description: Message to post. required: true selector: text: multiline: true + icon: + description: Icon number to display. + selector: + number: + min: 1 + max: 100 + mode: box + duration: + description: Time in seconds to display the notification. + default: 10 + selector: + number: + min: 1 + max: 120 + unit_of_measurement: secs + mode: box sequence: - - service: mqtt.publish - data: - topic: "{{ states('sensor.bedroom_clock_device_topic')}}/notify" - payload_template: >- - "{ - 'text': '{{ message }}', - 'duration': 5 - }" + - if: + - condition: template + value_template: "{{ icon|default('', true)|length > 0 }}" + then: + - service: mqtt.publish + data: + topic: "{{ states('sensor.bedroom_clock_device_topic')}}/notify" + payload_template: >- + "{ + 'text': '{{ message }}', + 'icon': '{{ icon }}' + 'duration': {{ duration|default(10, true) }} + }" + else: + - service: mqtt.publish + data: + topic: "{{ states('sensor.bedroom_clock_device_topic')}}/notify" + payload_template: >- + "{ + 'text': '{{ message }}', + 'duration': {{ duration|default(10, true) }} + }" + mode: single