Im new to homeasisstant and so far managed to connect some tapo plugs. But now i want to controll my custom made RGB Lights which i so far controll via Node-Red and MQTT. Idealy i would like to have a dashboard card which sends the RGB values to a helper topic, which i then can read in Node Red. But i have no idea how to do so, when configuring a helper entity as a value i can't use it in the light card
#Entitys for RGB Lights.
1 messages · Page 1 of 1 (latest)
I don't know about MQTT too much but I have Node-RED "integrated" with my dashboard board to control lights.
I have a switch node in NR that creates a switch entity in HA.
I then run it into a function that I wrote that basically figures out what the "incoming command" needs to do.
A get entities node the determines what lights need to be called.
A change node then moves some data around in the payload to get it ready for a call-service node.
Lastly, a call-service node uses the payload to actually do the work.
(I can export this flow if you want it.)
EDIT: I forgot that an update recently broke this. I'm working on it now and think I have the fix figured out.
The gist of the function used:```javascript
msg.topic = "Rule Handler"
for (const [key, value] of Object.entries(msg.payload)) {
var temp = (${key}: ${value});
}
const [key, value] = temp.split(': ');
node.status({text: key + " set to " + value});
if (key == "color_name") { msg.data = { "service":"turn_on","color_name": value }; }
if (key == "color_temp") { msg.data = { "service":"turn_on","color_temp": value }; }
if (key == "kelvin") { msg.data = { "service":"turn_on","kelvin": value }; }
if (key == "brightness_pct") { msg.data = { "service":"turn_on","brightness_pct": value }; }
if (key == "brightness") { msg.data = { "service":"turn_on","brightness": value }; }
if (key == "service") { msg.data = { "service": value }; }
return msg;```
That switch node creates the switch entity:
These are the buttons on my dashboard that run through NR. I have some brightness presets and color presets. I use custom:button-cards for these buttons but you should be able to use card you want since I send the commands with hold_actions which subsequently activates the switch.
The custom:button-cards are templated to cut down on the amount of repeated code and ensure uniform appearance. From the template, yaml hold_action: action: call-service service: nodered.trigger service_data: entity_id: switch.nodered_all_lights_to_rgb variables: var_color_name: null var_color_temp: null var_kelvin_value: null
RGB , kelvin, and brightness buttons have a different templates to ensure the appropriate data is being sent. An RGB button: yaml hold_action: service_data: message: color_name: '[[[ return variables.var_color_name ]]]'
From one of the buttons (in this case the red button): ```yaml
- type: custom:button-card
template: rgb_selector
variables:
var_color_name: red
var_entity_id: light.living_room_lights
styles:
card:
- background-color: rgba(255, 0, 0, 0.5)```
From the 100% button ( removed the yellow glow capability from this example for brevity):
- type: custom:button-card
template: brightness_selector
variables:
var_value: 100
var_entity_id: light.living_room_lights```
I have two other switch nodes in NR that act as "flow triggers."
On the dashboard:
And the cooresponding yaml to trigger one of the flows: yaml tap_action: action: call-service service: nodered.trigger service_data: entity_id: switch.nodered_goodnight target: {}
Wow thanks for the quick answer. But i would like to have a (sorry) "better looking" card. I think the Light card would do what i want but i dont know how to create a helper entity that the card can take.
That why I mentioned that you should be able to use any card that supports an action (which is pretty much all of them). The entity that you put in the card doesn't matter if you go the route that I described. Everything to make it work is contained within the action.
If you want a "better looking" card, the Light card is not the greatest choice. The only thing that it has going for it is the built-in brightness control but it lacks customizability. custom:button-cards and Mushroom cards are way better options.
I was going to use the mushroom light card, from what ive seen you can control RGB, color temp and brightness with it. My problems now are, that no existing entity fits in this card and the only entity the switch node creates is a switch entity (which the mushroom light card wont take)
The Mushroom Light card (really, all cards) is only going to be able to "send" the RGB, color temp, and brightness within HA. It will not be able to "directly" send that data to Node-RED. If you are trying to get a card to work natively with your flow in NR, it will not happen. That's why it doesn't matter what entity you put in the card; you're just putting anything there to make it happy. The tap_action is what is important to get the data into NR.
Now, with that said, it might be possible to create a templated light entity that can simulate a real light entity but the RGB, color_temp, and brightness data goes to NR. Something like that might be feasible. Would acutally be kind of cool if that could work but I don't know if it is possible.
jeah i was thinking about a dummy entity which you get the values of using the current state node in NR. But i cant find a way to get such a dummy entity
Where are the values currently stored? Like if I were to ask the brightness of the device, where would you find that?
Its currently stored on the device. but i could implement a way to get a feedback via mqtt.