Function node light questions

Would need some help. I have a lamp I try to be able to change color and brightness.

If I write {"brightness": 150} in the data field, it changes brightness, but how do you write such in function node has tried to read me to this but does not get wiser.

Also tried chanche node but even there I did not get it to work.

Hi,

It is good to see you are playing with Node-Red.

Have a read of some of the threads on how to share nodes:

How to share

If I write {"brightness": 150} in the data filed

I'm guessing that is the node for the bulb?

Could you maybe say what this node is called?

How confident are you to do basic things in Node-Red?

eg:

Drag an inject node into the EDIT area.
Also a change node.

Connect the two together and connect the output of the change node to the input of the node that controls the bulb.

Open the change node and set it like this:

Now, duplicate the inject and change node and connect the change node's output to the bulb's input (this will be two connections going in).

Edit the second change node with a different value.
Make it very different to the first one. It won't be very good to have values like: 150, 151.
Try 50 and 200.

Deploy the flow.

Press one of the inject node button (the little tab on the left of the node.)

See if the bulb changes brightness.

If it doesn't don't panic.

Repeat it with the other inject node.

This is because the bulb may be already at that value.

So pressing the second inject node will (should) change the bulb's brightness.

1 Like

Tell us the full name of that node please (probably node-red-contrib-something). Without that we cannot know exactly what you have to do.

Have tested a few different chanche node but get none to work. If I check debug, it seems to send my value on britness like something else.

[{"id":"e5f36ec.bf4639","type":"tab","label":"Flow 17","disabled":false,"info":""},{"id":"4ada4ecd.9704f","type":"api-call-service","z":"e5f36ec.bf4639","name":"","server":"b2b8610a.26012","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.ikea_of_sweden_tradfri_bulb_e14_cws_opal_600lm_6c97befe_level_light_color_on_off","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":630,"y":440,"wires":[[]]},{"id":"fab8737c.7f99a","type":"inject","z":"e5f36ec.bf4639","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":440,"wires":[["4ada4ecd.9704f"]]},{"id":"ec6d42b8.31e0c","type":"debug","z":"e5f36ec.bf4639","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":830,"y":160,"wires":[]},{"id":"cdcf79b6.66b6c8","type":"debug","z":"e5f36ec.bf4639","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":850,"y":420,"wires":[]},{"id":"d71cdbed.a6c328","type":"api-call-service","z":"e5f36ec.bf4639","name":"","server":"b2b8610a.26012","version":1,"debugenabled":true,"service_domain":"light","service":"turn_on","entityId":"light.ikea_of_sweden_tradfri_bulb_e14_cws_opal_600lm_6c97befe_level_light_color_on_off","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":650,"y":240,"wires":[[]]},{"id":"5de1068f.077208","type":"inject","z":"e5f36ec.bf4639","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":240,"wires":[["fce6da4.33bf228"]]},{"id":"76d5a3f8.d9a23c","type":"api-call-service","z":"e5f36ec.bf4639","name":"","server":"b2b8610a.26012","version":1,"debugenabled":true,"service_domain":"light","service":"turn_on","entityId":"light.ikea_of_sweden_tradfri_bulb_e14_cws_opal_600lm_6c97befe_level_light_color_on_off","data":"{\"brightness\":10}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":590,"y":160,"wires":[["ec6d42b8.31e0c"]]},{"id":"6abb2a83.b479b4","type":"inject","z":"e5f36ec.bf4639","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":160,"wires":[["76d5a3f8.d9a23c"]]},{"id":"b57d62f.674b1a","type":"comment","z":"e5f36ec.bf4639","name":"working britness","info":"","x":320,"y":160,"wires":[]},{"id":"9126ebe2.032888","type":"function","z":"e5f36ec.bf4639","name":"","func":"msg.payload={\n    \n\"data.brightness\":250,\n\n};\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":380,"y":360,"wires":[["cdcf79b6.66b6c8","d71cdbed.a6c328"]]},{"id":"4f492fab.2175c","type":"change","z":"e5f36ec.bf4639","name":"","rules":[{"t":"set","p":"data.brightness","pt":"msg","to":"255","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":300,"wires":[["d71cdbed.a6c328","ff90fe85.8877d"]]},{"id":"fce6da4.33bf228","type":"change","z":"e5f36ec.bf4639","name":"","rules":[{"t":"set","p":"brightness","pt":"msg","to":"200","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":240,"wires":[["d71cdbed.a6c328","b4d95759.304a58"]]},{"id":"f0e6c8d3.b089a8","type":"inject","z":"e5f36ec.bf4639","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":300,"wires":[["4f492fab.2175c"]]},{"id":"a422dc83.3e7d4","type":"inject","z":"e5f36ec.bf4639","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":360,"wires":[["9126ebe2.032888"]]},{"id":"ff90fe85.8877d","type":"debug","z":"e5f36ec.bf4639","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":830,"y":360,"wires":[]},{"id":"b4d95759.304a58","type":"debug","z":"e5f36ec.bf4639","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":830,"y":300,"wires":[]},{"id":"b2b8610a.26012","type":"server","z":"","name":"Home Assistant BOR","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

[edited to format correctly with ``` on a seperate line before and ``` on a line after the paste ]

Please see this post for how to share your flow, and try again. The flow you posted is not importable. However, as I said before, we need to know the name of the node you are using (node-red-contrib-something problable), assuming you are using a contrib node, so we can look it up to see what format it needs the data to be in.

You need to edit the debug nodes.

Then you will see what the payloads are.

By default the debug node only shows msg.payload, as that is usually what is used/needed.

As you (we) are using msg.brightness it won't be shown.

Now:
You say that isn't working.
Ok. Not sure why, but all we can do is try.

I don't have those nodes installed and am not going to only to help you.

Can you take a screen shot of what you are doing at this stage?
I am missing something in what you said, and a screen shot may save a lot of time.

Without knowing which node he is using we don't know where the brightness should be in the message.

Thank you for the help I took some pictures, If I turn on the lamp with the help of the first picture and I get this information in debug node.

But when I run it true the chanche node, I get this in the debug

this is the chanche node

Have also tried to write data.brightness in the chanche node.
Does not seem like the lamp takes into account what I send into it.
I try with big chanche in tje numbers so i will se if it chanche.

Ah, Home Assistant, you should have said (and put it in the title). I don't know anything about HA.

Just a quick thing:

Usually just to the right of the F12 key there is a button on the keyboard called: "Print screen"
Pressing this takes a screen shot - usually. Depending on which O/S you are running.

These pictures then can be added to the post by drag and drop or by clicking on the "attach" button at the top which looks like a big up pointing arrow.

I'm torn between what I should do.

How much computer work experience do you have?
A lot; pretty good; some; not too bad; learning.

What O/S do you run (more for the screen shot problem)

How much experience do you have with Node-Red?
(as above)

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