/
inovelli_led.yaml
152 lines (146 loc) · 3.98 KB
/
inovelli_led.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
---
# Calculation References:
# https://nathanfiscus.github.io/inovelli-notification-calc/
# https://community.inovelli.com/t/home-assistant-2nd-gen-switch-rgb-working/168/62
# https://docs.google.com/spreadsheets/u/1/d/1SGJrJHCUtz8AzznWL_mLCTJjjr2U0IpltcUkRr7N_6M/edit?usp=sharing
#
# Changes:
# July 22, 2020: Incorporating changes from Kevin Schlichter.
# https://github.com/kschlichter/Home-Assistant-Inovelli-Red-Dimmer-Switch
variables:
# The dimmer's "supported_features" attribute is 33.
parameter: |
{%- if state_attr(entity_id,"supported_features")|int == 33 %}
16
{%- else %}
8
{% endif %}
color: |
{%- if color is not number %}
{{ color|default("Yellow") }}
{%- else %}
{{ color|int }}
{% endif %}
# 1-10
level: '{{ level|default(4) }}'
duration: '{{ duration|default("Indefinitely") }}'
effect: '{{ effect|default("Blink") }}'
colors:
"Off": 0
"Red": 1
"Orange": 21
"Yellow": 42
"Green": 85
"Cyan": 127
"Teal": 145
"Blue": 170
"Purple": 195
"Light Pink": 220
"Pink": 234
durations:
"Off": 0
"1 Second": 1
"2 Seconds": 2
"3 Seconds": 3
"4 Seconds": 4
"5 Seconds": 5
"6 Seconds": 6
"7 Seconds": 7
"8 Seconds": 8
"9 Seconds": 9
"10 Seconds": 10
"15 Seconds": 15
"20 Seconds": 20
"25 Seconds": 25
"30 Seconds": 30
"35 Seconds": 35
"40 Seconds": 40
"45 Seconds": 45
"50 Seconds": 50
"55 Seconds": 55
"60 Seconds": 60
"2 Minutes": 62
"3 Minutes": 63
"4 Minutes": 64
"10 Minutes": 70
"15 Minutes": 75
"30 Minutes": 90
"45 Minutes": 105
"1 Hour": 120
"2 Hours": 122
"Indefinitely": 255
effects_dimmer:
"Off": 0
"Solid": 1
"Chase": 2
"Fast Blink": 3
"Slow Blink": 4
"Blink": 4
"Pulse": 5
"Breath": 5
effects_switch:
"Off": 0
"Solid": 1
"Fast Blink": 2
"Slow Blink": 3
"Blink": 3
"Pulse": 4
"Breath": 4
sequence:
# Preform the Inovelli math.
- variables:
color: '{{ colors[color|title]|int }}'
duration: '{{ durations[duration|title]|int }}'
effect_original: '{{ effect }}'
effect: |
{% if state_attr(entity_id,"supported_features")|int == 33 %}
{{- effects_dimmer[effect|title]|int }}
{%- else %}
{{- effects_switch[effect|title]|int }}
{% endif %}
inovelli_math: |
{%- if effect_original|title == "Off" %}
0
{%- else %}
{{ color|int + (level|int * 256) + (duration|int * 65536) + (effect|int * 16777216) }}
{% endif %}
# - service: script.debug
# data:
# id: "inovelli_led"
# message: |
# node_id: '{{ state_attr(entity_id,"node_id") }}'
# parameter: '{{ parameter }}'
# value: '{{ inovelli_math }}'
- choose:
# The Z-wave integration requires this service call.
- conditions:
- '{{ entity_id.split(".")[0] == "zwave" }}'
sequence:
# Clear the previous effect.
- service: zwave.set_config_parameter
data_template:
node_id: '{{ state_attr(entity_id,"node_id") }}'
parameter: '{{ parameter }}'
size: 4
value: '0'
# Start the new effect.
- service: zwave.set_config_parameter
data_template:
node_id: '{{ state_attr(entity_id,"node_id") }}'
parameter: '{{ parameter }}'
size: 4
value: '{{ inovelli_math }}'
# The OZW integration requires this service call.
default:
# Clear the previous effect.
- service: ozw.set_config_parameter
data_template:
node_id: '{{ state_attr(entity_id,"node_id") }}'
parameter: '{{ parameter }}'
value: '0'
# Start the new effect.
- service: ozw.set_config_parameter
data_template:
node_id: '{{ state_attr(entity_id,"node_id") }}'
parameter: '{{ parameter }}'
value: '{{ inovelli_math }}'