it’s supposed to make all my lights’ color temperature warmer, but it just stopped working randomly. I didn’t install an update or changed hardware.
Upon running the action in the script I get the following error:
Error running action
Error rendering data template: TypeError: unsupported operand type(s) for -: ‘NoneType’ and ‘int’
how do I fix that?
By the way, it started working again after I changed the color temp of one of my lights that had a numeric value instead of “null” as their attribute for color_temp_kelvin. This cause the attribute for my all-lights-entity to become a numeric value instead of “null”.
I still need a proper fix for when it reoccurs though.
So what I’d need to do to test your theory is to crank the color temperature up all the way and go beyond the max value with my script, right?
I tried that and didn’t get the error from that.
Another thought I had was that maybe since my “all-lights-entity” contains some lights that simply don’t have a color temperature, it might cause this bug. I have no idea though.
Anyway, I can’t replicate the issue right now.
In order to do that, I tried using my script after restarting HA and then again after manually changing the brightness of a light that doesn’t have a color temperature but that didn’t do the trick.
What are you referring to with your “no”? Perhaps I misphrased this: When I said “crank the color temperature up all the way and go beyond the max value” I meant lowering as much as possible. I was saying the opposite because the Lovelace slider for color temperature is actually turned upwards to lower the color temperature so I was mixing that up.
Secondly, the lowest possible color_temp_kelvin value for all of my lights that have that value is 2702, so I wonder if it’s even possible to cause the value to go below 0.
I tried that out by just subtracting 500 with my script so many times that it would reach 0 if it wouldn’t stop at the 2702 limit but that didn’t cause any errors.
I actually noticed that most of my lights go significantly warmer than 2702 kelvin but that they wouldn’t do that when using the script, since it uses a group entity that only respects the highest min_color_temp_kelvin of all the lights that are in that group. Not sure how this is related to the error. Anyway, to fix that, I split the lights into several groups. Although I find that bit impractical, considering I now also have to split lovelace sliders.
After splitting the lights up and playing around with them for a bit, I randomly started getting the issue + error just on my hallway lights, even though they were at a very high colortemp.
After turning my lights off and on again, the issue disappeared and didn’t reoccur even when I subtracted 500 kelvin from my hallway lights via my script so often that it should go below 0 if there was no limit.
So, I don’t think a negative number is the issue here.
Obviously, color_temp_kelvin becomes null for your group in some circumstances.
Difficult to give you a general response, it can depends on the type of lights in the group. It seems to be mostly null for me.
It makes sure that is a number, and not null so it works in the math statement. If it’s null or something else that is not a number, it plugs in the number 2700.
As long as you set the 2700 to a number >= to what you are from it subtracting, the statement should not error.