Linking MagicHome lamp to Vera Via Node-red

Interesting idea. So I installed Reactor and created a sensor. I set it up to trip when the Bedroom Lamp is on. I then activated the RF9500 to turn on the lamp. The device state in Vera didn’t change, and consequently the sensor didn’t trip. It’s like the module isn’t sending the status change back to the Vera. I tried it with the other module in the Family room and that didn’t work either. I even went into the device and changed the polling time to 1 second and that didn’t do anything either. It shouldn’t have been necessary though. I thought z-wave devices are supposed to report any status change back to their controllers? :slightly_frowning_face:

[Update]: After doing some reading, it seems the GE 45602’s don’t support “instant status”. i.e. They don’t report their status to z-wave when they change. So this isn’t going to work either. I added the Vera itself to the same Direct Association group on the RF9500, but I don’t know what to test for in Reactor to determine if it’s getting the message and changing anything. I might be able to get it to work if I could figure out how to do that.

So far, I’ve been able to create a Node red Flow to turn the MagicHome bulb on and off via an HTTP request. I have it set so that if you access the url http://nodeRedIP:1880/on or http://nodeRedIP:1880/off it will send the appropriate command to the bulb. Everything seems to be working . Next step would be to get the HTTP Virtual Switch on the Vera to send the appropriate commands to Node Red.

I read through the documentation on the Virtual Switch and I’m afraid it’s beyond me. Going to need some help with that. Wondering if it would be better to have the virtual switch send directly to the bulb. That might not be possible though without something in the middle to format the message.

what node-red node are you using to turn the lamp on?

Have you installed the virtual http plugin?
Probably a good idea to start a new thread as this is going of subject.

I installed the node-red-contrib-magichome-controller node. It has an output node that takes the IP of the bulb and uses msg.payload.power to send the on/off command. Yes, I’ve installed the HTTP Virtual Device plug in.

Ok, Do you want to start the new thread or should I?

I will move this to a new thread

Great. Please post a link to it. I found this thread via a Google search. Thanks!

Paste your flow. so we are on same page.

In the virtualrgb set power on and off url’s to
http://noderedip:1880/%s

Here’s my current test flow.

[{"id":"16c8ef71.1b10d1","type":"http in","z":"7fc9f1ed.bd7e38","name":"","url":"/on","method":"get","upload":false,"swaggerDoc":"","x":420,"y":160,"wires":[["10361b91.782d7c","f4fd1825.94025"]]},{"id":"9c8b79.b31f4488","type":"MagicHome","z":"7fc9f1ed.bd7e38","name":"","server":"538cdc71.4044ec","x":770,"y":600,"wires":[[]]},{"id":"3271551f.55984a","type":"http in","z":"7fc9f1ed.bd7e38","name":"","url":"/off","method":"get","upload":false,"swaggerDoc":"","x":410,"y":380,"wires":[["10361b91.782d7c","f4fd1825.94025"]]},{"id":"f4fd1825.94025","type":"http response","z":"7fc9f1ed.bd7e38","name":"","statusCode":"","headers":{},"x":710,"y":280,"wires":[]},{"id":"10361b91.782d7c","type":"function","z":"7fc9f1ed.bd7e38","name":"","func":"msg.payload.power = msg.req.url.replace('/','')\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":660,"y":400,"wires":[["9c8b79.b31f4488"]]},{"id":"538cdc71.4044ec","type":"MagicHome-config","name":"Test","host":"192.168.1.74","interval":10}]

please put it in backticks as this site mutates " and causes syntax errors the backticks prevent that

```
code
```

I meant edit previous as this will get messy very quickly, using 3 backticks and export in compact mode, that way the code is colour coded and errors can be spotted. Also it makes it easier to copy and paste if we don’t have to scroll the page to select.

Not sure what you mean by 3 backticks? Three at the beginning and 3 at the end of the code? I edited the previous and did that. LMK if that’s not correct. It’s exported in compact mode.

like below
```
code
```

Ok, now I’ve got it. Done.

Ok the url would be
http://ip:1880/rgb?power=on or off

[{"id":"362322ea.e159ee","type":"function","z":"8d22ae29.7df6d","name":"","func":"msg.payload.power = msg.req.query.power\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":570,"y":3220,"wires":[["5ace73e5.86f81c"]]},{"id":"edb81eda.e95a7","type":"http in","z":"8d22ae29.7df6d","name":"","url":"/rgb","method":"get","upload":false,"swaggerDoc":"","x":330,"y":3220,"wires":[["b0ba8300.2e92b8","362322ea.e159ee"]]},{"id":"b0ba8300.2e92b8","type":"http response","z":"8d22ae29.7df6d","name":"","statusCode":"","headers":{},"x":670,"y":3100,"wires":[]},{"id":"5ace73e5.86f81c","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":760,"y":3240,"wires":[]}]

this means only one http in node

Nice. That works. I added the configured MagicHome node and the light turns on and off.

set virtualrgb device power on and off url’s to
http://ip:1880/rgb?power=%s

Yep, I did that and it works!!! Now the switch turns the bulb on and off!! Sweet!

Interesting thing. The RF9500 must be direct associated to some device to get the 0 and 255 scenes to show up. If it’s not, it stays at 0 and only the LastSceneTime value changes. I plugged the lamp directly into the wall, and left the module alone. The bulb is being controlled by the Virtual Switch which is toggled by Reactor. It’s working just like I’d hoped!

The next thing is to get it to react to Alexa. So I can say things like “set the bedroom lamp to 50%” or “set the bedroom lamp to blue”. For that it doesn’t have to go through the Vera, but if it could, that might be better and it can use the Alexa Node red code that you already developed. I didn’t see any variables in the Virtual Switch that looks like they had anything to do with RGB, but maybe I missed it.

have you tried adding the virtual rgb to vera alexa skill, just to test.
edit/ scratch that. this should work with my alexa vera node-red integration flow

ok try this
the url for SetRGBColorURL in virtual rgb is
http://ip:1880/rgb?color=%s
or in browser color=255,0,0

[{"id":"362322ea.e159ee","type":"function","z":"8d22ae29.7df6d","name":"","func":"if(msg.req.query.power){\n    msg.payload.power = msg.req.query.power;\n}else if (msg.req.query.color){\n    let color = msg.req.query.color.split(\",\")\n    msg.payload.color = { \"red\":color[0], \"green\": color[1], \"blue\":color[2] }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":470,"y":3220,"wires":[["5ace73e5.86f81c"]]},{"id":"edb81eda.e95a7","type":"http in","z":"8d22ae29.7df6d","name":"","url":"/rgb","method":"get","upload":false,"swaggerDoc":"","x":230,"y":3220,"wires":[["b0ba8300.2e92b8","362322ea.e159ee"]]},{"id":"b0ba8300.2e92b8","type":"http response","z":"8d22ae29.7df6d","name":"","statusCode":"","headers":{},"x":570,"y":3100,"wires":[]},{"id":"5ace73e5.86f81c","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":660,"y":3240,"wires":[]}]

How do I get the Virtual RGB Switch for Vera? I installed the HTTP Virtual Switch from the store and there doesn’t seem to be SetRGBColorURL variable in it.

I added the MagicHome Alexa skill and it seems to control the bulb with no issues. Including dimming and color changes. It’s using their cloud system, but that’s ok.

Also, I tried the new function, but it doesn’t seem to be working. The color doesn’t change when sent to the MagicHome output node