Getting started with Node Red, light to specified brightness

Hi,

I´m quite new to HA and getting started with the Node Red, but I’m struggling with a setup that I thought would be super simple.

I want to turn on the light to a specified brightness with a click of a button.
I only managed to turn on the light, but as soon as I add the brightness to Data field, I get different kind of flickering and inconsistent behavior from the WiFi bulb I’m trying to control
I would appreciate if someone could point me in right direction.

Below is my call service node.

Silly question: Is it a dimmable light?

Yes it is, and it’s also RGB bulb. All the functions work through Lovelace

Make and model?

I assume you’ve tried it without the quotes around the 50 ?

I have a few LIFX bulbs as my first automations, and it took a little research and fiddling to get the parameters working correctly. I found the list of parameters further down the Call Service node to be incredibly helpful.

In another Call Service node, Data field is a JSON expression:

{
    "rgbw_color": [
        255,
        100,
        100,
        50
    ],
    "brightness_pct": 100,
    "transition": 10
}

Note that different brands and often different models will have different parameters. What works for my LIFX bulbs may be totally ignored by the bulbs you are using.

2 Likes

The make and model might be something that you never heard of it. The make is Inncap without specific model.
I live in China currently and moved to HA, since I noticed that I started to have quite a collection of Xiaomi compatible devices (ridiculously cheap here), but the automation function through Xiaomi’s app were very limited.
And the bulb is connected to HA via Xiaomi Miot HACS custom integration.
It communicates via cloud because I couldn’t get the local mode to work with that bulb, and currently it is the only one I have.
Could it be that the messages are sent to the bulb “too fast”, since it is controlled through cloud?
How can I first turn it on and then send the brightness command separately?

Thanks for the tip.
Is it possible to see the exact commands that HA sends, when I control the bulb through Lovelace?
This way I could check that what are the correct commands for this exact light bulb.

Try to open Developer Tools in HA and then make the service call there.
When it works, then switch to the YAML view and see the command parameters.

Rauten debugging lovelace is beyond my experience :frowning: … but surely if all the functions work correctly through Lovelace, that means the device is correctly installed in Home Assistant. And node-RED should be using Home Assistant and Home Assistant’s device profile for the Call Service node ?

Try changing this:

image

And then use { "brightness": 128 }

It might work if you just remove the " from 50. It’s a numeric value it wants, not a string

I haven’t used YAML config file at all, went directly to Node Red

YAML is used for many other things in HA, like call services and configure lovelace cards.
You make a service call in the developer tools, then it rights it as YAML in the background and by looking at that, then you can see the correct parameter names and how the values should be written, which can be used in NR.

Just tried, but same problem. The light just flickers and returns to the brightness it was set previously.

Ok, will check this out.

When you reply to someone’s question, please quote the question.

How do you know if the light is dimmable?

Hi, because I can adjust the brightness from the HA dashboard.

But you said it flickers. This would occur if the light is not dimmable. (But the LIFX bulbs should be dimmable).

This is the answer right here. If you can’t get the light to dim in an HA service call, the problem is with the bulb/HA. If you can get it to work from dev tools, the exact same call is what should be used in the call service node.

I have now messed around with the developer tools and the results are quite interesting. If I run the turn on service with the brightness function, I get the same results as before with my NR flow. But if I run it twice in a row, then it sets the light to the desired brightness.

Only problem is that the flickers (not on off, but between brightness’s) when running it this way and always starting with the brightness that was set when the bulb was turned off lats time.
I´m guessing that this has something to do with the fact that the bulb is controlled through cloud and not locally.

I also have one Sonoff B05 bulb which would be locally controlled, but for some reason the custom integration only allows me to turn on and off, not to adjust brightness or color. I’ve read that some people have the Sonoff custom integration working and some people have similar issues with the bulbs. Haven’t been able to figure out that what’s the reason.

Steve, i am the one with LIFX bulbs. Back in post #6 the OP Rauten stated

The make is Inncap without specific model.  ...  And the bulb is connected to HA via Xiaomi Miot HACS custom integration.

Rauten, I found local Australia websites selling the Inncap bulb, but there is no link to a User Manual. Importantly they state that it is designed to work with Xiaomi Home app.

I see there are 2 HA built-in Xiaomi integrations … and many in HACS ! This makes me think that maybe another integration might be better ?

The integration for my lights allows me to set “Brightness value”, “Brightness” and “White” in the HA Developer Tools > Services page. Clicking [Go to YAML mode] at the bottom of the page gives me

service: light.turn_on
data:
  white: 200
  brightness: 42
  brightness_pct: 51
target:
  device_id: 3ad35992484e1921a5b2f41ba6c6adeb

I do not understand why it allows me to simultaneously use 3 different parameters to set the same thing to different values :confused: The bulb agrees, because it doesn’t respond until I send it any one of the parameters.

You might try “brightness”: with a value from 0 (off) to 255 (maximun)