Linking MagicHome lamp to Vera Via Node-red

go to device - advanced - parameters

set to this reload luup and refresh browser

leave your own devices id.

Ahh, ok. The switch looks completely different now, and the SetRGBColorURL is there. I added the url above to it.

I still don’t think the Node red code is working though. When I try to change it via the browser, the bulb doesn’t change. I think the node was written for the LED controller for the strips, not the bulb so the bulb parameters might be different. I thought I remember reading that in the MagicHome docs for the Vera plugin.

try adding a white value to the color payload
msg.payload.color = { "red":color[0], "green": color[1], "blue":color[2] ,"white":0}
in the function.

Nope, still nothing. Interesting thing. When I send ANY values from the browser, the bulb gets much brighter, then it won’t respond to an on/off command from the browser. I have to go the phone app and turn it off and on again before it will respond from the browser/node red again. I think the node was originally written for the LED controller and isn’t sending the proper commands for the bulb which puts it in a weird state.

I’m actually where I need to be. I can control it via the switch, and dim and change colors via Alexa, which is all I really need.

[Update]: I’ve tried several different things and I can’t get the color or the brightness to change on the bulb. I’m thinking the protocol must have changed with the bulbs and that’s why the MagicHome node and the MagicHome plugin aren’t working. The only way to figure out what the proper commands are to send the bulb for dimming and color change would be to do a packet capture from the app and try to reverse engineer the protocol.

I was able to get the Node red Hue Bridge to recognize the Virtual Switch on the Vera and I can control it using the same commands as a binary switch. It just won’t do any dimming.

So I just ran into a situation. I now have 2 bulbs configured. The only problem, how do I tell Node red which one to send the command to? You can configure multiple MagicHome nodes, each with a different IP, but how do you tell the Function which one to send it to? I imagine you can configure the inbound HTTP msg with a “device” but how does the function know which MagicHome node should get the output?

add an extra query parameter
http://ip:1880/rgb?power=on&lamp=lamp1
then after function add a switch node and filter with msg.req.query.lamp ==lamp1 or lamp2

Yeah, I was actually able to figure it out. I started my career as a programmer and it just took me a little bit to remember stuff. :slightly_smiling_face: The key was finding that you can configure multiple outputs to a Function. I just return the msg to the correct output and “null” to the others. If you want to see the Function, I can post it.

Re: The brightness/color functionality. Interesting thing. The 9W bulbs came in and they kind of worked with the MagicHome plugin that ceefin wrote. At least it would recognize them and communicate somewhat. I guess they use the old protocol. The operation was intermittent though and very slow, so I went back to the Virtual Switch and Node Red. I’m going to try the brightness/color thing again and see if the new bulbs respond to the commands listed in the MagicHome Node docs. Maybe I can get it to work.

Thanks for all your help!!

There is an update to virtual http, you can now specify multiple url’s one on each line. Update to 2.2 of plugin on github to get the functionality.

Also take a look at this magic home node.


Its was updated 2 months ago. The outputs when manually turning on lamp, are the same as what is need to input.

How do I load a plugin to the Vera off of github? I wasn’t sure how to do that.

I looked at that node, but there was even less documentation on it than the other one. It doesn’t show any of the objects needed to use it.

download the code, it comes zipped.
extract to a folder.
on browser goto controller apps- develope - luup files
Untick reload luup after upload.
click upload
select a file from the extracted location,
repeat till last file, before last file recheck reload luup after upload.
then refresh browser
you do not need to upload readme or license.

Once connect add a debug, then manually turn light off on colour change etc, the output structure messages should be same as required for input.

Ahh, ok. I thought that was how to do it, but it seemed very manual. Thought I was missing a command or something. Not sure if Multiple Actions is going to do anything for me though, but I’ll update it to 2.2.

Ok, I’ll take a look at that Magichome Node and see if I can can get anything out of it.

Thanks!

you could turn on multiple wifi lights with one virtual switch or send a speech command when light turned on, etc. You can also add curl commands again one on each line

I don’t really have anything were I’d need to turn on multiple Magichome lights. If I did, I’d probably just create a Vera scene and handle it that way, but it’s good to know I could do it with Multiple Actions if I needed to though.

I was able to get everything I wanted working correctly. I did switch to this MagicHome node.

It’s a little newer and from what I can tell in the github docs and bug reports, it’s supposed to support bulbs. However, I’m still not able to set the color/dimming with the rgb node. I am able to turn it on and off and get the status with those nodes though. I think I’m not sending the data in the right format in the msg.payload and I’m not sure what I’m doing wrong. If you get a second to take a look at it, I’d appreciate any help.

I really don’t need to set the color via the Vera virtual device as I can set it with Alexa and the MagicHome skill, but it would be nice to learn what I’m doing wrong. Thanks!

I could not get magichome local working, i just get error when i open nodes.

What have you tried for colour input, are you sending rgb “255,0,0” or hex “#ffffff”?

Interesting. I’ve had no problem opening the bulbs with those nodes. It seems to discover them automatically and populates the drop down to select which node to communicate with. Once it’s set, I haven’t had to touch them.

The on/off node just needs true/false set in msg.payload, but the rgb node appears to be more complicated. It’s supposed to be some kind of object with the color/white parameters set but it doesn’t work for me.

Check out this bug report for the node. It lists some examples that are supposed to work, but I don’t think I’m creating the color object correctly in the msg.payload.

Here’s the node test flow I’ve been using.

[{"id":"a7ab8b72.c2b528","type":"debug","z":"e385bf6d.d09b7","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":930,"y":380,"wires":[]},{"id":"b54e950b.e7d808","type":"magic-home-status","z":"e385bf6d.d09b7","name":"","device":"192.168.1.196","x":550,"y":100,"wires":[["a7ab8b72.c2b528"]]},{"id":"2d2744e9.a22c3c","type":"magic-home-rgbcw","z":"e385bf6d.d09b7","name":"","device":"192.168.1.196","x":550,"y":480,"wires":[["a7ab8b72.c2b528"]]},{"id":"ebc8039c.974898","type":"inject","z":"e385bf6d.d09b7","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":260,"y":100,"wires":[["b54e950b.e7d808"]]},{"id":"46c88a85.83e6dc","type":"magic-home-on","z":"e385bf6d.d09b7","name":"","device":"192.168.1.196","x":570,"y":300,"wires":[["a7ab8b72.c2b528"]]},{"id":"716fdc0c.400eec","type":"inject","z":"e385bf6d.d09b7","name":"True","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":260,"y":300,"wires":[["46c88a85.83e6dc"]]},{"id":"f6dcbbe2.771bf8","type":"inject","z":"e385bf6d.d09b7","name":"False","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":260,"y":380,"wires":[["46c88a85.83e6dc"]]},{"id":"48f42207.aa03ec","type":"inject","z":"e385bf6d.d09b7","name":"Red","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"r\":0,\"g\":0,\"b\":0,\"ww\":255,\"cw\":0}","payloadType":"json","x":260,"y":480,"wires":[["a7ab8b72.c2b528","2d2744e9.a22c3c"]]}]

That git thread talks about setting

In that case you need to set apply_masks to true and use setColor and setWarmWhite/setWhites instead of setColorAndWhites, since bulbs can not set both at the same time.

Are there settings when configuring IP, also try only sending colour attributes no ww or cw

If you look at the commit notes, the author of the nodes implemented all that in the latest update to the code.

Ahh, ok. I’ll try it without the ww and cw parameters and see if it works that way.

Nope, still nothing. I send the msg.payload with an Inject node and nothing happens. After a few seconds, I get a “command timed out” message in the debug window.

Best Home Automation shopping experience. Shop at getvera!

© 2021 Ezlo Innovation, All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules