i currently have a yaml file from another person, and it has a bunch of elif commands to change the colour of a light based on prices of electricity.
but one thing i’d like to tidy up is that the fact the light “rainbows” through all colours when the price is very low. as the price is true for all rules, where there is an option for less than 100, and less than 50, and less than 20, and less than 10.
i hope to modify the sections so each is a range of possible numbers, to eliminate this effect.
here’s a sample of the file as it stands:
if current < 0 %}
[0, 0, 255]
{% elif current < 0.20 %}
[0, 255, 0]
{% elif current < 0.30 %}
[255, 247, 0]
{% elif current < 0.40 %}
[255, 165, 0]
{% elif current < 0.99 %}
[255, 0, 0]
{% else %}
[160, 32, 240]
{% endif %}
Note however I doubt this will fix your problem. Your original set of if statements would stop at the first true statement and would not “rainbow through all colours”. Sounds like you have some other issue.
the issue isnt bad, it’s just not perfect seeing the light flash through all possible options when the price is below 0c/kwh, and similar for each step up the ladder the price might be.
the overall automation has my RGB light on a solid colour, based on the same price/colour structure, and it also flashes a colour every 10 seconds to show what the forecast price will be in X minutes (currently set to 60).
it’s this flash through all colours that i’m trying to tidy up.
my lack of understanding about yaml’s syntax (or any other language) limits me in fully understanding the how and why of the complete script.
as i didnt write it i dont want to share the whole thing out of respect. which makes it harder for you to help me, i know.