Greetings! Working on a project and I need a little help with an idea, or find out if it’s even possible. I have a Kasa LED light strip and I’d like to be able to change its color based on the value of a temperature sensor nearby. Any suggestions on where to begin would be greatly appreciated. Thanks!
You could create a rule and use the temperature changing as the Trigger, then you could have whatever conditional actions you want in the Flow.
You would most likely want to use an expression to perform whatever calculation/conversion from the temperature sensor value to your desired color, but you would have to share more details about exactly what you were hoping to accomplish (conditions / logics) for us to be able to provide more guidance.
Thanks @josh , I played around with it for a while and got close to my goal. The project is pretty cool, albeit not something anyone else is likely to be working on. It’s a wax cooking cabinet for snow skis. Essentially, I have a long insulated cabinet that can hold 6 pairs of skis. On one end it has a large fan, and on the bottom it has 2 crossflow fans that circulate air along a heating element. Nothing crazy, the box sits right around 125F for a 4 hour session to saturate the wax into the skis. It’s an old-school way of prepping skis that’s crazy effective, but not very common. I recently upgraded all the hardware, putting in better fans, sensors, and smart switches. Also added the light strip under the box for fun. I have the whole routine run through Sharptools, so everything turns on and off after set times. Also added a few fail-safes in case something goes wonky. The light strip was so it would look cool when it was running and you could tell what the internal temp was by the color.
All that being said, I’m still new to Sharptools so it took me a minute to figure out how to make it all work. I created a variable for the temp value and used a rule to refresh it every 3 minutes when the box is turned on. My brain was struggling on how to write the rule without adding an “If temp is between…” statement. I ended up adding a rule that used “If the temp is less than X, set color to Y” and started from 70F and went to 125F. Seems to be working perfect! I didn’t realize it would take the IF statements in order for some reason.
Now I have 2 other things I’m trying to do. I’d like to figure out how the Fade works, because I think it would look even cooler if it wasn’t just a static color. The Kasa app for the light switch has a whole bunch of effects you can do, so I didn’t know if there was a way to replicate something with the other options on Sharptools.
I’m also trying to figure out how to have a tile on the dashboard show a 4hr countdown after the process has started. I’ve been reading on all the variable expressions and time/date stuff but I haven’t made any progress yet.
Apologies for the long reply, haven’t been able to really sit at the computer for a while!
You should be able to do this part using the temperature as a Trigger for the rule. That way anytime the temperature changes, the value will get pushed over to SharpTools and the data would update in realtime.
That’s probably the most intuitive as you’re just getting started with things.
I suspect that you could do this with an expression – potentially inline within a device command, but I would need to better understand how you are mapping temperatures to colors.
I asked ChatGPT for a suggestion for adjusting the hue
of a light based on your range of 75-125F and it provided the following formula:
hue = 240 - ((T - 70) / (125 - 70)) × (240−0)
Where T
is the temperature and that would map to a hue
value between 240° (blue) and 0° (red)
Here’s the expression:
T = $context.event.value
hue = 240 - ((T - 70) / (125 - 70)) * (240 - 0)
hue = max(0, hue)
hue = min(240, hue)
The first line copies the temperature value that triggered the rule into a expression local variable called T
. The second line runs ChatGPTs calculations and the last two lines clamp the color temperature to the range of 0-240 so nothing is outside of that.
Here’s a quick page showing what that color range looks like: https://color-temperature-map.glitch.me/
You could then use the setHue()
command on your desired light with the $targetHue value that we calculated in a variable above.
Thanks for the tips! I tried switching the triggers so that the temperature sensor updating would change the color, but it only works once, right when I turn it on. It doesn’t seem to be triggering the color change as the sensor updates it’s value. I’ve actually struggled using the “…updates” trigger on other rules too. For example, I had a rule trigger when a door opened or closed and I tried using the “door contact status updates” and the “door contact status changes” triggers and neither of them would work. Ended up using both “door contact changes to open” and “door contact changes to closed” as triggers, which worked. Any thoughts on why the update wouldn’t be getting pushed to SharpTools?
Without seeing the rules and rule logs, it’s hard to tell.