Hi,
my energy provider AMBER here in Australia provides a price forecast and the AMBER integration makes that available as a sensor in HA.
On their app they show it like this:
Now I want to replicate that same display on a LED strip. I would install the strip in the laundry to remind us to start the machine now or delay a bit.
I am thinking of using WLED and splitting the strip into segments. Then each segment becomes its own light in HA. The only thing I need to do now is set all the colors correctly with an automation.
I have all the code to find the light and the relevant color, but how do I set all the lights differently in one automation?
my code so far:
{%
set forecast=state_attr('sensor.homeambermeter_general_forecast', 'forecasts') | map(attribute='descriptor')|list
%}
{%
set color_map={'spike': 'purple',
'high': 'red',
'neutral': 'darkorange',
'low': 'orange',
'very_low': 'green',
'extremely_low': 'cyan'
} %}
{%
set lightsegments= [
'light.amberlight',
'light.amberlight_segment_1',
'light.amberlight_segment_2',
'light.amberlight_segment_3']
%}
{% for segment in lightsegments %}
{{loop.index0}} light entity: {{ state_attr( segment , "friendly_name" ) }}
price {{ forecast[loop.index0] }}
color {{ color_map[forecast[loop.index0]]}}.
{% endfor %}
that generates this output:
0 light entity: AmberLight
price low
color orange.
1 light entity: AmberLight Segment 1
price high
color red.
2 light entity: AmberLight Segment 2
price high
color red.
3 light entity: AmberLight Segment 3
price high
color red.
So I have all the details I need, how do I write the action in the automation?
This example only uses 4 segments, I am hoping to use at least 12 segments to cover the next 6 hrs.
any pointers would be appreciated