Been trying to figure out the best way to create an automation that will change the color of my light based on the outdoor temperature. I have different RGB values for all the temperatures from 0 degrees up to 100 and was planning on using rgb_color in a data_template.
Having issues getting HA to accept the rgb_color values as a data_template, and getting this error:
Invalid data for call_service at pos 1: None for dictionary value @ data[‘rgb_color’]
Tried lots of different formats to set the rgb_color, but stuck at the moment. Any suggestions or better ways to set 100 different colors based on temp is welcome. Here is my code that gets the error:
- id: Outside_Temp_Color_Change
alias: 'Outside Temp Color Change'
initial_state: 'off'
trigger:
platform: state
entity_id: sensor.outdoor_temperature
action:
service: light.turn_on
data_template:
entity_id: light.marks_office_light
rgb_color: >-
{% if trigger.to_state.state | float <= 0 %}
[{{255|int}}, {{255|int}}, {{255|int}}]
{% elif trigger.to_state.state | float >= 1 %}
[{{64|int}}, {{0|int}}, {{255|int}}]
{% endif %}
Tediore
December 15, 2019, 4:43am
2
Try just [255,255,255]
and similar for the other one.
Also…what if that sensor is between 0 and 1? Why <= 0
and >= 1
anyway?
Tried that and get the same error: Invalid data for call_service at pos 1: None for dictionary value @ data[‘rgb_color’]
I had read it has something to due to rgb_color needing to be a list of integers and not a single string. Concerning the <= 0 and >=1 was just my first test. 0 Degrees under or 1 degrees or higher. I plan to put all 100 values in there using an exact color spectrum if I can get this to work at all.
Thanks.
Tediore
December 15, 2019, 1:56pm
4
Are you manually triggering this automation to test? If so, the reason you get that error is because there’s no trigger.to_state.state
(or a trigger at all, rather) when you manually trigger the automation.
123
(Taras)
December 15, 2019, 2:28pm
5
Try this:
rgb_color: >
{% if trigger.to_state.state | float <= 0 %}
{{ '[255, 255, 255]' | from_json }}
{% elif trigger.to_state.state | float >= 1 %}
{{ '[64, 0, 255]' | from_json }}
{% endif %}
Finally got this working!!! These are test values and not the completed project, but wanted to make sure the logic was correct before doing all 100 values for each temperature rgb value.
Will post the completed project when done, but this works (for 3 values to start with, testing):
- id: Outside_Temp_Color_Change
alias: 'Outside Temp Color Change'
initial_state: 'off'
trigger:
platform: state
entity_id: sensor.outdoor_temperature
action:
service: light.turn_on
entity_id: light.marks_office_light
data_template:
rgb_color:
- >
{% if states.sensor.outdoor_temperature.state | int <= 0 %} 255
{% elif states.sensor.outdoor_temperature.state | int >= 1 %} 64
{% elif states.sensor.outdoor_temperature.state | int == 2 %} 50
{% else %} 0
{% endif %}
- >
{% if states.sensor.outdoor_temperature.state | int <= 0 %} 255
{% elif states.sensor.outdoor_temperature.state | int >= 1 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 2 %} 50
{% else %} 0
{% endif %}
- >
{% if states.sensor.outdoor_temperature.state | int <= 0 %} 255
{% elif states.sensor.outdoor_temperature.state | int >= 1 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 2 %} 50
{% else %} 0
{% endif %}
1 Like
123
(Taras)
December 15, 2019, 2:44pm
7
The example using the from_json
filter failed to work?
123:
rgb_color: > {% if trigger.to_state.state | float <= 0 %} {{ ‘[255, 255, 255]’ | from_json }} {% elif trigger.to_state.state | float >= 1 %} {{ ‘[64, 0, 255]’ | from_json }} {% endif %}
Just tested the from_json and didn’t work - getting this in the template editor:
Error rendering template: UndefinedError: ‘trigger’ is undefined
If there is a better/clearer way, that would be great as this code isn’t pretty but so far is the only thing that works.
123
(Taras)
December 15, 2019, 2:56pm
9
The Trigger State object is always undefined within the Template Editor. You cannot use the Template Editor to test templates containing trigger
.
Try it in the automation.
I tried it in the automation also… No errors, but the light never comes on.
123
(Taras)
December 15, 2019, 3:10pm
11
Just to confirm, the automaton’s action looks like this?
action:
service: light.turn_on
data_template:
entity_id: light.marks_office_light
rgb_color: >
{% if trigger.to_state.state | float <= 0 %}
{{ '[255, 255, 255]' | from_json }}
{% elif trigger.to_state.state | float >= 1 %}
{{ '[64, 0, 255]' | from_json }}
{% endif %}
How are you testing the automation? It will only trigger if sensor.outdoor_temperature
changes state. How are you making that happen?
trigger:
platform: state
entity_id: sensor.outdoor_temperature
Tried it exactly as you have it listed and forced the trigger so I didn’t have to wait for the temp change. Light doesn’t come on and getting this in the log:
Log Details (ERROR)
Sun Dec 15 2019 10:14:52 GMT-0500 (Eastern Standard Time)
Error rendering data template: UndefinedError: ‘trigger’ is undefined
123
(Taras)
December 15, 2019, 3:24pm
13
The error message you received is expected because you manually executed the automation. When you do that, the automation’s trigger and condition (if any) are ignored and only the action is evaluated. That means, once again, the Trigger State object is undefined .
From the documentation: Testing Your Automation
Please note that if you click on Trigger of an automation in the frontend, only the action
part will be executed by Home Assistant. That means you can’t test your trigger or condition part that way. It also means that if your automation uses some data from triggers, it won’t work properly as well just because trigger
is not defined in this scenario .
To trigger the automation, you will have to cause sensor.outdoor_temperature
to change its state. Rather than haul the sensor indoors, you can use the States page to set its state.
Tried again - forced the temp change in the states page for the entity. Light doesn’t come on and getting this error:
Error while executing automation automation.outside_temp_color_change. Invalid data for call_service at pos 1: None for dictionary value @ data[‘rgb_color’]
123
(Taras)
December 15, 2019, 3:39pm
15
When you stated
What were the test conditions that produced no errors?
The error in the log didn’t show up until I forced the state of the sensor. The condition with no error was because I never trigger the temp change.
123
(Taras)
December 15, 2019, 4:24pm
17
Looks like the end of the road for using the from_json
filter for rgb_color
.
If you search for posts containing rgb_color
, you’ll find may threads encountering the same issue:
rgb_color
expects to receive a list . Attempts to use templates to create a list typically fail because Jinja2 always outputs a string . Even though the template’s output looks like a list, it’s still a string (and unacceptable to rgb_color
).
I thought using from_json
might work, but nope.
The standard way to mitigate it is to ensure the list is hard-coded in YAML and only its values are templated. There are two ways to do that and your latest example is one of them.
data_template:
rgb_color:
- {{ template for RED }}
- {{ template for BLUE }}
- {{ template for GREEN}}
and the other is:
data_template:
rgb_color: [ {{ template for RED }}, {{ template for BLUE }}, {{ template for GREEN}} ]
1 Like
Finally finished the “Weather Outdoor Temperature Light - Automation”. The complete rgb color spectrum for the temperatures (in degrees F) are here:
https://www.strangeplanet.fr/work/gradient-generator/?c=100:FFFFFF:FF1493:9D00FF:0000FF:00FFEE:32D22D:8CFF00:FFFF00:FFAE00:FF2B00:FF0000
Converted the HTML colors to rgb_colors here: https://www.w3schools.com/colors/colors_hwb.asp
- id: Outside_Temp_Color_Change
alias: 'Outside Temp Color Change'
initial_state: 'off'
trigger:
platform: state
entity_id: sensor.outdoor_temperature
action:
service: light.turn_on
entity_id: light.marks_office_light
data_template:
rgb_color:
- >
{% if states.sensor.outdoor_temperature.state | int <= 0 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 1 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 2 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 3 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 4 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 5 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 6 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 7 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 8 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 9 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 10 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 11 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 12 %} 245
{% elif states.sensor.outdoor_temperature.state | int == 13 %} 235
{% elif states.sensor.outdoor_temperature.state | int == 14 %} 224
{% elif states.sensor.outdoor_temperature.state | int == 15 %} 214
{% elif states.sensor.outdoor_temperature.state | int == 16 %} 207
{% elif states.sensor.outdoor_temperature.state | int == 17 %} 198
{% elif states.sensor.outdoor_temperature.state | int == 18 %} 186
{% elif states.sensor.outdoor_temperature.state | int == 19 %} 175
{% elif states.sensor.outdoor_temperature.state | int == 20 %} 167
{% elif states.sensor.outdoor_temperature.state | int == 21 %} 157
{% elif states.sensor.outdoor_temperature.state | int == 22 %} 140
{% elif states.sensor.outdoor_temperature.state | int == 23 %} 123
{% elif states.sensor.outdoor_temperature.state | int == 24 %} 111
{% elif states.sensor.outdoor_temperature.state | int == 25 %} 93
{% elif states.sensor.outdoor_temperature.state | int == 26 %} 76
{% elif states.sensor.outdoor_temperature.state | int == 27 %} 64
{% elif states.sensor.outdoor_temperature.state | int == 28 %} 47
{% elif states.sensor.outdoor_temperature.state | int == 29 %} 30
{% elif states.sensor.outdoor_temperature.state | int == 30 %} 17
{% elif states.sensor.outdoor_temperature.state | int == 31 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 32 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 33 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 34 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 35 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 36 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 37 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 38 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 39 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 40 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 41 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 42 %} 5
{% elif states.sensor.outdoor_temperature.state | int == 43 %} 10
{% elif states.sensor.outdoor_temperature.state | int == 44 %} 15
{% elif states.sensor.outdoor_temperature.state | int == 45 %} 20
{% elif states.sensor.outdoor_temperature.state | int == 46 %} 26
{% elif states.sensor.outdoor_temperature.state | int == 47 %} 31
{% elif states.sensor.outdoor_temperature.state | int == 48 %} 36
{% elif states.sensor.outdoor_temperature.state | int == 49 %} 41
{% elif states.sensor.outdoor_temperature.state | int == 50 %} 46
{% elif states.sensor.outdoor_temperature.state | int == 51 %} 51
{% elif states.sensor.outdoor_temperature.state | int == 52 %} 61
{% elif states.sensor.outdoor_temperature.state | int == 53 %} 66
{% elif states.sensor.outdoor_temperature.state | int == 54 %} 75
{% elif states.sensor.outdoor_temperature.state | int == 55 %} 88
{% elif states.sensor.outdoor_temperature.state | int == 56 %} 96
{% elif states.sensor.outdoor_temperature.state | int == 57 %} 106
{% elif states.sensor.outdoor_temperature.state | int == 58 %} 112
{% elif states.sensor.outdoor_temperature.state | int == 59 %} 122
{% elif states.sensor.outdoor_temperature.state | int == 60 %} 132
{% elif states.sensor.outdoor_temperature.state | int == 61 %} 140
{% elif states.sensor.outdoor_temperature.state | int == 62 %} 153
{% elif states.sensor.outdoor_temperature.state | int == 63 %} 162
{% elif states.sensor.outdoor_temperature.state | int == 64 %} 174
{% elif states.sensor.outdoor_temperature.state | int == 65 %} 187
{% elif states.sensor.outdoor_temperature.state | int == 66 %} 195
{% elif states.sensor.outdoor_temperature.state | int == 67 %} 208
{% elif states.sensor.outdoor_temperature.state | int == 68 %} 221
{% elif states.sensor.outdoor_temperature.state | int == 69 %} 234
{% elif states.sensor.outdoor_temperature.state | int == 70 %} 242
{% elif states.sensor.outdoor_temperature.state | int == 71 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 72 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 73 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 74 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 75 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 76 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 77 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 78 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 79 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 80 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 81 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 82 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 83 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 84 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 85 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 86 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 87 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 88 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 89 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 90 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 91 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 92 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 93 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 94 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 95 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 96 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 97 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 98 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 99 %} 255
{% elif states.sensor.outdoor_temperature.state | int >= 100 %} 255
{% else %} 43
{% endif %}
- >
{% if states.sensor.outdoor_temperature.state | int <= 0 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 1 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 2 %} 232
{% elif states.sensor.outdoor_temperature.state | int == 3 %} 209
{% elif states.sensor.outdoor_temperature.state | int == 4 %} 184
{% elif states.sensor.outdoor_temperature.state | int == 5 %} 161
{% elif states.sensor.outdoor_temperature.state | int == 6 %} 138
{% elif states.sensor.outdoor_temperature.state | int == 7 %} 115
{% elif states.sensor.outdoor_temperature.state | int == 8 %} 89
{% elif states.sensor.outdoor_temperature.state | int == 9 %} 66
{% elif states.sensor.outdoor_temperature.state | int == 10 %} 43
{% elif states.sensor.outdoor_temperature.state | int == 11 %} 20
{% elif states.sensor.outdoor_temperature.state | int == 12 %} 18
{% elif states.sensor.outdoor_temperature.state | int == 13 %} 15
{% elif states.sensor.outdoor_temperature.state | int == 14 %} 13
{% elif states.sensor.outdoor_temperature.state | int == 15 %} 13
{% elif states.sensor.outdoor_temperature.state | int == 16 %} 10
{% elif states.sensor.outdoor_temperature.state | int == 17 %} 8
{% elif states.sensor.outdoor_temperature.state | int == 18 %} 5
{% elif states.sensor.outdoor_temperature.state | int == 19 %} 3
{% elif states.sensor.outdoor_temperature.state | int == 20 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 21 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 22 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 23 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 24 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 25 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 26 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 27 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 28 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 29 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 30 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 31 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 32 %} 25
{% elif states.sensor.outdoor_temperature.state | int == 33 %} 50
{% elif states.sensor.outdoor_temperature.state | int == 34 %} 75
{% elif states.sensor.outdoor_temperature.state | int == 35 %} 103
{% elif states.sensor.outdoor_temperature.state | int == 36 %} 126
{% elif states.sensor.outdoor_temperature.state | int == 37 %} 155
{% elif states.sensor.outdoor_temperature.state | int == 38 %} 178
{% elif states.sensor.outdoor_temperature.state | int == 39 %} 206
{% elif states.sensor.outdoor_temperature.state | int == 40 %} 228
{% elif states.sensor.outdoor_temperature.state | int == 41 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 42 %} 250
{% elif states.sensor.outdoor_temperature.state | int == 43 %} 245
{% elif states.sensor.outdoor_temperature.state | int == 44 %} 242
{% elif states.sensor.outdoor_temperature.state | int == 45 %} 237
{% elif states.sensor.outdoor_temperature.state | int == 46 %} 232
{% elif states.sensor.outdoor_temperature.state | int == 47 %} 227
{% elif states.sensor.outdoor_temperature.state | int == 48 %} 222
{% elif states.sensor.outdoor_temperature.state | int == 49 %} 219
{% elif states.sensor.outdoor_temperature.state | int == 50 %} 214
{% elif states.sensor.outdoor_temperature.state | int == 51 %} 209
{% elif states.sensor.outdoor_temperature.state | int == 52 %} 214
{% elif states.sensor.outdoor_temperature.state | int == 53 %} 219
{% elif states.sensor.outdoor_temperature.state | int == 54 %} 222
{% elif states.sensor.outdoor_temperature.state | int == 55 %} 227
{% elif states.sensor.outdoor_temperature.state | int == 56 %} 232
{% elif states.sensor.outdoor_temperature.state | int == 57 %} 237
{% elif states.sensor.outdoor_temperature.state | int == 58 %} 242
{% elif states.sensor.outdoor_temperature.state | int == 59 %} 245
{% elif states.sensor.outdoor_temperature.state | int == 60 %} 250
{% elif states.sensor.outdoor_temperature.state | int == 61 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 62 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 63 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 64 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 65 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 66 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 67 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 68 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 69 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 70 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 71 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 72 %} 247
{% elif states.sensor.outdoor_temperature.state | int == 73 %} 238
{% elif states.sensor.outdoor_temperature.state | int == 74 %} 230
{% elif states.sensor.outdoor_temperature.state | int == 75 %} 221
{% elif states.sensor.outdoor_temperature.state | int == 76 %} 213
{% elif states.sensor.outdoor_temperature.state | int == 77 %} 204
{% elif states.sensor.outdoor_temperature.state | int == 78 %} 200
{% elif states.sensor.outdoor_temperature.state | int == 79 %} 191
{% elif states.sensor.outdoor_temperature.state | int == 80 %} 183
{% elif states.sensor.outdoor_temperature.state | int == 81 %} 174
{% elif states.sensor.outdoor_temperature.state | int == 82 %} 162
{% elif states.sensor.outdoor_temperature.state | int == 83 %} 149
{% elif states.sensor.outdoor_temperature.state | int == 84 %} 136
{% elif states.sensor.outdoor_temperature.state | int == 85 %} 119
{% elif states.sensor.outdoor_temperature.state | int == 86 %} 106
{% elif states.sensor.outdoor_temperature.state | int == 87 %} 94
{% elif states.sensor.outdoor_temperature.state | int == 88 %} 81
{% elif states.sensor.outdoor_temperature.state | int == 89 %} 68
{% elif states.sensor.outdoor_temperature.state | int == 90 %} 55
{% elif states.sensor.outdoor_temperature.state | int == 91 %} 43
{% elif states.sensor.outdoor_temperature.state | int == 92 %} 38
{% elif states.sensor.outdoor_temperature.state | int == 93 %} 34
{% elif states.sensor.outdoor_temperature.state | int == 94 %} 30
{% elif states.sensor.outdoor_temperature.state | int == 95 %} 21
{% elif states.sensor.outdoor_temperature.state | int == 96 %} 17
{% elif states.sensor.outdoor_temperature.state | int == 97 %} 13
{% elif states.sensor.outdoor_temperature.state | int == 98 %} 9
{% elif states.sensor.outdoor_temperature.state | int == 99 %} 4
{% elif states.sensor.outdoor_temperature.state | int >= 100 %} 0
{% else %} 255
{% endif %}
- >
{% if states.sensor.outdoor_temperature.state | int <= 0 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 1 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 2 %} 244
{% elif states.sensor.outdoor_temperature.state | int == 3 %} 234
{% elif states.sensor.outdoor_temperature.state | int == 4 %} 222
{% elif states.sensor.outdoor_temperature.state | int == 5 %} 211
{% elif states.sensor.outdoor_temperature.state | int == 6 %} 202
{% elif states.sensor.outdoor_temperature.state | int == 7 %} 190
{% elif states.sensor.outdoor_temperature.state | int == 8 %} 178
{% elif states.sensor.outdoor_temperature.state | int == 9 %} 167
{% elif states.sensor.outdoor_temperature.state | int == 10 %} 156
{% elif states.sensor.outdoor_temperature.state | int == 11 %} 146
{% elif states.sensor.outdoor_temperature.state | int == 12 %} 158
{% elif states.sensor.outdoor_temperature.state | int == 13 %} 169
{% elif states.sensor.outdoor_temperature.state | int == 14 %} 179
{% elif states.sensor.outdoor_temperature.state | int == 15 %} 191
{% elif states.sensor.outdoor_temperature.state | int == 16 %} 200
{% elif states.sensor.outdoor_temperature.state | int == 17 %} 212
{% elif states.sensor.outdoor_temperature.state | int == 18 %} 222
{% elif states.sensor.outdoor_temperature.state | int == 19 %} 232
{% elif states.sensor.outdoor_temperature.state | int == 20 %} 245
{% elif states.sensor.outdoor_temperature.state | int == 21 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 22 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 23 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 24 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 25 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 26 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 27 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 28 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 29 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 30 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 31 %} 255
{% elif states.sensor.outdoor_temperature.state | int == 32 %} 252
{% elif states.sensor.outdoor_temperature.state | int == 33 %} 250
{% elif states.sensor.outdoor_temperature.state | int == 34 %} 250
{% elif states.sensor.outdoor_temperature.state | int == 35 %} 247
{% elif states.sensor.outdoor_temperature.state | int == 36 %} 245
{% elif states.sensor.outdoor_temperature.state | int == 37 %} 245
{% elif states.sensor.outdoor_temperature.state | int == 38 %} 242
{% elif states.sensor.outdoor_temperature.state | int == 39 %} 242
{% elif states.sensor.outdoor_temperature.state | int == 40 %} 240
{% elif states.sensor.outdoor_temperature.state | int == 41 %} 238
{% elif states.sensor.outdoor_temperature.state | int == 42 %} 217
{% elif states.sensor.outdoor_temperature.state | int == 43 %} 198
{% elif states.sensor.outdoor_temperature.state | int == 44 %} 182
{% elif states.sensor.outdoor_temperature.state | int == 45 %} 161
{% elif states.sensor.outdoor_temperature.state | int == 46 %} 143
{% elif states.sensor.outdoor_temperature.state | int == 47 %} 122
{% elif states.sensor.outdoor_temperature.state | int == 48 %} 101
{% elif states.sensor.outdoor_temperature.state | int == 49 %} 83
{% elif states.sensor.outdoor_temperature.state | int == 50 %} 66
{% elif states.sensor.outdoor_temperature.state | int == 51 %} 46
{% elif states.sensor.outdoor_temperature.state | int == 52 %} 41
{% elif states.sensor.outdoor_temperature.state | int == 53 %} 36
{% elif states.sensor.outdoor_temperature.state | int == 54 %} 31
{% elif states.sensor.outdoor_temperature.state | int == 55 %} 28
{% elif states.sensor.outdoor_temperature.state | int == 56 %} 23
{% elif states.sensor.outdoor_temperature.state | int == 57 %} 18
{% elif states.sensor.outdoor_temperature.state | int == 58 %} 13
{% elif states.sensor.outdoor_temperature.state | int == 59 %} 8
{% elif states.sensor.outdoor_temperature.state | int == 60 %} 5
{% elif states.sensor.outdoor_temperature.state | int == 61 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 62 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 63 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 64 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 65 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 66 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 67 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 68 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 69 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 70 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 71 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 72 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 73 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 74 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 75 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 76 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 77 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 78 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 79 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 80 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 81 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 82 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 83 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 84 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 85 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 86 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 87 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 88 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 89 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 90 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 91 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 92 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 93 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 94 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 95 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 96 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 97 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 98 %} 0
{% elif states.sensor.outdoor_temperature.state | int == 99 %} 0
{% elif states.sensor.outdoor_temperature.state | int >= 100 %} 0
{% else %} 113
{% endif %}
2 Likes
Tediore
December 15, 2019, 7:19pm
19
Good lord. My phone does not like that code block lol.
2 Likes
123
(Taras)
December 16, 2019, 1:59am
20
FWIW, there are alternative ways to do this using mathematics (the Internet abounds with color fading and color cycling examples, often employed in light-strip controllers). However, seeing that you’ve already hard-coded each degree to a color, the alternatives are left for others to explore.