Mulitple Devices in Plugin

Hi -
I’m trying my hand at writting my first plugin, but need some help. I have a single device working properly, however when I have mulitple devices and do something on one device, the same action occurs on the other. If someone can provide some quidance for me, that would be great.

Plugin attached. Many Thanks.

RGB_Controller.plugin (4.2 KB)

Are they all failing or is it just Level/Brightness?

I see your URL is incorrect for Level. You are passing in device.DeviceType where you should be using device.Id. That one definitely is not going to work as you expect it will. Your other calls look good.

I would also recommend adding some console.log calls to your onChangeRequest method. They will help you troubleshoot.

Thanks, Bill…I will do some work as you recommended. I had the console.logs in there, but took them out once I got things working…I’ll add back in. One more question: When I add a device, a box pops up asking for device info, but it’s empty. My thoughts were that by putting the params in the onSynchronizeDevices() function, a new device would be populated with those values. The other thing is that if I do Synchronize Devices…a new device is create with all the info in it. I’m probably not understanding the process. Thanks, man.

The 2 are completely unrelated. Right-clicking and selecting “Add Device” is a manual process & you have to type all of the required data. Right-clicking & selecting “Synchronize Devices” calls your “onSyncronizeDevices” function which is an automated process to generate new device objects.

Makes complete sense to me now. Thanks. So, when I’m running HR on my Android device, if I go away from the app then resume, my color wheel value changes to white (center of color wheel). Is there a way to remedy this. I’ve attached the current version of the plugin in case you need to have a look at it.

Thanks again for your help.

RGB_Controller.plugin (6.4 KB)

Device states reset when you resume the app. You need to look at the value you are assigning to the attribute in your onPoll function. You probably aren’t assigning it the correct value there.

I don’t know. The error might not even be where you think it is. Could be something else entirely. You can try wrapping those calls in a try-catch to verify.

Perhaps the more important question, Vera already has a service for color control that’s supported by Home Remote. You may not even need this custom plugin. Does your device not support the service urn:micasaverde-com:serviceId:Color1?
http://wiki.micasaverde.com/index.php/Luup_UPnP_Variables_and_Actions#Color1

Here’s the thing…On Vera, I’m using the Fibaro RGB Controller V2. When installed on Vera, the Fibaro creates separate devices for State, Dim, Red, Green, Blue & White channels. There is a way on Vera to merge them into one device, but that only works for Fibaro RGB Controller V1. So, the only option for me is to utilize a plugin called RGB Controller which utilizes the following services:

urn:upnp-org:serviceId:RGBController1
urn:upnp-org:serviceId:SwitchPower1
urn:micasaverde-com:serviceId:HaDevice1

This plugin, however, does not have a Dim function builit in.

What my plugin is attempting to do is manage this problem. What I’ve done is make a plugin with 2 Vera device #'s per HR plugin device. To accomplish this, the Id property of each device looks like 466:455 where the 1st number is for the State & Color device and the 2nd is for the Dim device. At the top of onChangeRequest and onPoll, I take the device.Id and parse it out to create the 2 devices with:

DeviceSwitchLevel = device.Id.slice(-3);
DeviceColor = device.Id.substring(0, 3);

I then have to manage those 2 devices throughout the code to get everything working. I know it’s convoluted, but hope it makes sense. If there’s another way, I’m open to it. I didn’t want to ask you to incorporate support for this into the software…you probably have more important things to work on. Thanks.