-
Notifications
You must be signed in to change notification settings - Fork 3
/
weather_awtrix_app.yaml
124 lines (121 loc) · 4.49 KB
/
weather_awtrix_app.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
blueprint:
name: "Multi Weather"
description: "This blueprint will show the weather"
#source_url: https://github.com/RDG88/Homeassistant_Blueprints/blob/main/bitcoin_awtrix_app.yaml
domain: automation
input:
awtrix:
name: AWTRIX Light
description: Select the Awtrix light
selector:
device:
filter:
- integration: mqtt
manufacturer: Blueforcer
model: AWTRIX Light
multiple: true
awtrix_app_name:
name: AWTRIX Application name
description: This is the custom app name that will be added to AWTRIX, should be unique
selector:
text: {}
default: weather
weather_sensor:
name: Weather sensor
description: Weather sensor
selector:
entity:
multiple: false
filter:
- integration: buienradar
push_icon:
name: pushIcon
description:
"Please select the pushIcon setting for the icon\n\n - `0` Icon
doesn't move\n\n - `1` Icon moves with text and will not appear again\n\n
\ - `2` Icon moves with text but appears again when the text starts to scroll
again\n"
selector:
select:
options:
- label: "Icon doesn't move."
value: "0"
- label: "Icon moves with text and will not reappear."
value: "1"
- label: "Icon moves with text but appears again when the text starts."
value: "2"
mode: list
default: "0"
txt_color_weather:
name: Text Color for Weather Sensor
description: Select the Text color
selector:
color_rgb:
default: [255, 255, 255]
duration:
name: Duration (in seconds)
description: Sets how long the app or notification should be displayed.
default: "10"
repeat:
name: Repeat
description: Sets how many times the text should be scrolled through the matrix before the app/notification ends.
default: "4"
lifetime:
name: Lifetime of the app (in seconds)
description: Removes the custom app when there is no update after the given time in seconds. Keep this value higher than 59 seconds to get the AWTRIX app automatically deleted when disabling the automation.
default: "70"
variables:
device_ids: !input awtrix
app: !input awtrix_app_name
txt_color_weather: !input txt_color_weather
sensor_weather: !input weather_sensor
push_icon: !input push_icon
duration: !input duration
repeat: !input repeat
lifetime: !input lifetime
awtrix_devices: >-
{%- macro get_awl_entities(device_id) %}
{%- set awl_device = iif(device_attr(device_id, 'name_by_user') != none, device_attr(device_id, 'name_by_user'), device_attr(device_id, 'name')) %}
{%- set awl_entity = expand(device_entities(device_id)) | select('search', 'device_topic') | map(attribute='entity_id') | first %}
{%- set awl_topic = states(awl_entity) -%}
{{ {'device': awl_device, 'topic': awl_topic, 'entity': awl_entity } }}
{%- endmacro %}
{% set ns = namespace(awtrix=[]) %}
{% for device_id in device_ids %}
{%- set ns.awtrix = ns.awtrix + [get_awl_entities(device_id)] %}
{%- endfor %}
{{ ns.awtrix|replace('"','') }}
trigger:
- platform: state
entity_id:
- !input weather_sensor
- platform: time_pattern
seconds: /59
action:
- repeat:
for_each: "{{ awtrix_devices }}"
sequence:
- choose:
- conditions:
- condition: template
value_template: >
{{ states(repeat.item.entity) not in ['unavailable', 'unknown'] }}
- condition: template
value_template: >
{{ states(sensor_weather) not in ['unavailable', 'unknown'] }}
sequence:
- service: mqtt.publish
data:
qos: 0
retain: false
topic: "{{ repeat.item.topic ~ '/custom/' ~ app }}"
payload: |
{
"text": "{{ state_attr(sensor_weather, 'temperature') }}{{state_attr(sensor_weather, "temperature_unit")}}",
"color": {{ txt_color_weather }},
"icon": "w-{{ states(sensor_weather) }}",
"pushIcon": {{ push_icon }},
"duration": {{ duration }},
"lifetime": {{ lifetime }}
}
mode: restart