Use Global Variable or Device Value as a Value in Another Device?

Short version:

I'd like to use the outdoor temperature to set the color of a bulb. I'm creating a rule for the temperature change of a (virtual) weather device. I'd like to use the temperature value to be the bulb color. The color only allows integers between 0 and 360 (which for RGB I don't understand yet, but not the point). How can I use something other than a static integer in a color value, or any field like that for that matter?

Thank you!

M.

Hi, and welcome to Hubitat.

In brief, you can't. You can't pull another devices value into a device. You have to use an app to do that. Device drivers talk to devices and publish events that app subscribe to. So, I'm not quite understanding how you are going to set color based on the temp number with a direct correlation to the hue.

The easiest thing to do to accomplish this is to use Rule Machine to set the color based on the range that the current temp falls into. However, this is going to require a lot of conditional actions. If you're not familiar with how those work, I would familiarize yourself with that before attempting a complicated rule like this.

In brief, you can't. You can't pull another devices value into a device.

Oh.

You have to use an app to do that.

Oh!

So, I'm not quite understanding how you are going to set color based on the temp number with a direct correlation to the hue.

I don't either! I was walking through rough building the thought when I kinda hit the wall of "You can't share variables".

It does look like going a custom app route might be my simplest answer. I just found the public Hubitat Github repo with a few examples of using input from a device to do a calculation on it and display the output (averageTemp.groovy). I suppose it should be possible to extend that idea to set a bulb instead of just displaying a number.

Take a look at these 2 threads. They might help. If I understand what you are trying to do, you want a value of temperature that ranges from X to Y to change the color value of a RGB bulb from A to B. In the 2nd thread, @adamkempenich's app changes a dimmer value of a virtual dimmer to a Color Temperature of a CT bulb and you are trying to convert a temperature value to a RGB Color. If you are also trying to incorporate Hue & Saturation, that gets complicated. Take a look, his app might be helpful.

Any chance you are using Node Red on a Raspberry Pi (or similar) in combination with Hubitat? If you were, then a relatively simple flow could do that for you.

1 Like

My code could be pretty easily modified to reflect an actual temperature to H/S/L or CT :slight_smile:

@matt.palermo — let me know if you’d like something like that.

Uh Oh bringing in the BIG GUNS!!!! hahaha.

1 Like

Although I don't use that app you created, it did inspire me to create it as a Node Red flow so thank you. I now have CT Dimmer Controller tiles for all 3 groups of my CT Bulbs on Dashboards that work great.

image

My code could be pretty easily modified to reflect an actual temperature to H/S/L or CT

Well... I certainly won't turn you down, but at the same time I'd like to learn it as well. I wish the example apps in Hubitat's Github repo were a little more general and not oddly specific things. I have your "Circadian Daylight" installed actually, but it doesn't make for that great of a "learning example" since it's sooooooooooo looooooooooong. :smiley:

If you find yourself bored and your fingers just start typing something that fits my brain fart idea, yes absolutely I'll use it and/or at the absolute least use it as a study guide to understand how it works...

In the mean time, I'm going to read through the threads that @stephen_nutt suggested and in combination with the dev docs see what I can cobble together. I'm certainly no stranger to "scripting", nor even new to groovy (for basic Jenkinsfile use, anyway). I can pick it up. I've no doubt in that. I'm just trying to fine "simpler" examples to gleen off of to learn.

Thank you!
M.

Take a look at these 2 threads. They might help.

Thanks, man!

If I understand what you are trying to do, you want a value of temperature that ranges from X to Y to change the color value of a RGB bulb from A to B

Yes, that's the nutshell version.

I do 100% get that a 40°F integer can't directly translate to a color value suitable for a bulb. There's a whole "What does 40 mean in RGB?" translation that would have to be figured out as well. I'm totally on board with that.

I just need to get a temperature device's number into a bulb's hue first... :smiley:

I'll read through the threads (and other replies) and see what I can learn!

M.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.