-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbitcoin_awtrix_app.yaml
127 lines (125 loc) · 4.51 KB
/
bitcoin_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
124
125
126
127
blueprint:
name: "AWTRIX Bitcoin"
description: "This blueprint will show the status of the exchange rate for the bitcoin in USD"
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: bitcoin
bitcoin_sensor:
name: Bitcoin sensor
description: Bitcoin sensor
selector:
entity:
multiple: false
filter:
- integration: bitcoin
bitcoin_icon:
name: Icon
description: Enter the Icon Name or ID of the icon that you like to show.
selector:
text:
default: "12460"
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_bitcoin:
name: Text Color for bitcoin
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
icon: !input bitcoin_icon
txt_color_bitcoin: !input txt_color_bitcoin
sensor_bitcoin: !input bitcoin_sensor
push_icon: !input push_icon
duration: !input duration
repeat: !input repeat
lifetime: !input lifetime
awtrix_devices: >-
{%- set ns = namespace(awtrix = []) -%}
{%- for device_id in device_ids -%}
{%- set device_name = iif(device_attr(device_id, 'name_by_user') != none, device_attr(device_id, 'name_by_user'), device_attr(device_id, 'name')) -%}
{%- set entity = expand(device_entities(device_id)) | select('search', 'device_topic') | map(attribute='entity_id') | first -%}
{%- set topic = states(entity) -%}
{% set ns.awtrix = ns.awtrix + [{"device": device_name, "entity": entity, "topic": topic}] -%}
{%- endfor -%}
{{ ns.awtrix }}
trigger:
- platform: state
entity_id:
- !input bitcoin_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_bitcoin) not in ['unavailable', 'unknown'] }}
sequence:
- service: mqtt.publish
data:
qos: 0
retain: false
topic: "{{ repeat.item.topic ~ '/custom/' ~ app }}"
payload: |
{
"text": "{{ states(sensor_bitcoin) | round(0) }}",
"color": {{ txt_color_bitcoin }},
"icon": "{{ icon }}",
"pushIcon": {{ push_icon }},
"duration": {{ duration }},
"lifetime": {{ lifetime }}
}
mode: restart