My MySensors RGBW plug in has an init problem
-
Thx @hek
I'm not sure what you mean by incorporate it in the MySensors plug in, but i did make a pull-request to vosmont.
I hope he can help me with fixing the initialize issue, for some reason the MySensor plug in does not start when the RGBcontroller is configured as slave. I took me quite some time figuring this out but no luck.
-
I have a vague memory of trying setting up a VariableContainer(plugin) as child-device in MySensors way back. But it didn't work either. I don't think a plugin in Vera can delegate commands to child devices (the build in devices is the exception).
That's why I think you have to move the parts needed from vosmont's device into the MySensors plugin. The GUI/descriptor files can of course be reused.
@akbooer might have some more insight to the Vera mysteries.
-
Happy to help. I've played a bit with @vosmont's RGB plugin when getting it to run under openLuup. It would be best if he could add a new device as part of the standard plugin - it does have some very specific code for different manufacturers. I guess I need to take a closer look at the workflow in the OP and try and understand what is needed and what is not working.
-
@akbooer that would be really great if you could help.
What i see is that Vera calls the initialized (startup) function of the child devices though the parent device. So in this specific case the RGBController lua startup function is called with the lul_device id of the MySensors device and the startup function of the child plugin is NOT called.
So i modified the RGB controller startup function (L_RGBController1.lua) with a check if it was called for a child or for itself as parent.
function startup (lul_device) log("startup", "Start plugin '" .. PLUGIN_NAME .. "' (v" .. PLUGIN_VERSION .. ")") -- Update static JSON file if updateStaticJSONFile(lul_device, PLUGIN_NAME .. "1") then warning("startup", "'device_json' has been updated : reload LUUP engine") luup.reload() return false, "Reload LUUP engine" end -- Init if luup.devices[lul_device].device_type == "urn:schemas-upnp-org:device:RGBController:1" then log("startup", "Found RGB master #" .. lul_device) initPluginInstance(lul_device) -- ... and now my watch begins (setting changes) luup.variable_watch("initPluginInstance", SID.RGB_CONTROLLER, "DeviceType", lul_device) luup.variable_watch("onDebugValueIsUpdated", SID.RGB_CONTROLLER, "Debug", lul_device) else -- Look for a child RGB device, which need to start up for child_id, v in pairs(luup.devices) do -- if I am the parent device of a child RGBController start it up if v.device_num_parent == lul_device and v.device_type == "urn:schemas-upnp-org:device:RGBController:1" then log("startup", "Found RGB child #" .. child_id) initPluginInstance(child_id) -- ... and now my watch begins (setting changes) luup.variable_watch("initPluginInstance", SID.RGB_CONTROLLER, "DeviceType", child_id) luup.variable_watch("onDebugValueIsUpdated", SID.RGB_CONTROLLER, "Debug", child_id) end end end if (luup.version_major >= 7) then luup.set_failure(0, lul_device) end return true endThis does NOT do the trick, i think the MySensors device is not ready (initialized) at the moment the RGB child start up is called. I even copied all action implementations (with dummy debug log) from the I_RGBController1.xml to I_Arduino1.xml so the "no implementation errors" where all gone.
Maybe the L_Arduino.lua needs to be adapted so that the RGB-startup function is called when MySensors is ready or implement a delayed startup for child devices in L_RGBController1.lua
I'm not sure...
-
Just to start again from the beginning, you are trying to get the RGBW Controller plugin to work with MySensors RGBW devices. What I don't know is how MySensors presents an RGBW device - I am assuming you get a node with 4 child dimmers, but perhaps not? This is what a native Vera multi-colour dimmer typically does (eg. Fibaro.)
One problem I foresee is that the MySensors plugin is parent to all the MySensors devices, be they actual nodes or individual sensors, so you don't get the same logical grouping with one Vera RGBW device controlling its separate R G B W children (which is what, I think, @vosmont's controller requires.)
-
@akbooer: No, since version 1.5 MySensors supports RGB and RGBW devices and in L_Arduino.lua these devices are created with D_RGBController1.xml. This is also the definition file name of vosmont's RGB-controller (coincident or not?).
So one child is presented of type RGB or RGBW showing the vosmont's RGB color-wheel, the code i did write for the RGB-controller directly control's the RGB MyS device with MyS message's.
luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {variableId = "RGBW", value = formerColor, radioId = pluginParams.rgbRadioId}, pluginParams.rgbArduinoId)This part of the code is working.
You are right an alternative could be, represent 3 or 4 dimmers and configure vosmont RGB module so it controls these 3 or 4 dimmers like Fibaro. But i do like the idea of having only one tile with the color wheel.
-
@BartE OK, so the device D_RGBController1.xml is actually a child of the Arduino plugin, which handles (with your changes) the action call you showed. The problem, then is that @vosmont's plugin does not recognise this device as one it can control? Or is it that you are expecting, somehow, the colour wheel to work directly with the MYSensor plugin?
Sorry to be so dim about this, but I'd hate to be chasing up the wrong tree.
-
@akbooer the second option, i expect the color wheel to work directly with the MySensor plugin/Arduino. Like some other supported RGB devices.
To do so i've created a new type of device in vosmont's plugin called "MYS-RGBW", this one you can select in the RGBcontroller and as work around one has to set the MySensor plugin id and the radio id of the RGB device. But when it is created as child device this information should be known to the plugin.
So the problem is NOT controlling the device, but having the RGBController to startup correctly as child.
-
@akbooer the second option, i expect the color wheel to work directly with the MySensor plugin/Arduino. Like some other supported RGB devices.
To do so i've created a new type of device in vosmont's plugin called "MYS-RGBW", this one you can select in the RGBcontroller and as work around one has to set the MySensor plugin id and the radio id of the RGB device. But when it is created as child device this information should be known to the plugin.
So the problem is NOT controlling the device, but having the RGBController to startup correctly as child.
@BartE said:
So the problem is NOT controlling the device, but having the RGBController to startup correctly as child.
OK, here's my confusion: you can't have the Arduino plugin AND the RGBW Controller plugin both controlling the RGBW device. By definition, it is a child of the Arduino plugin and all functionality for that child device has to be provided by the parent. Are there, perhaps, some actions defined in the services or implementation file which are not, in fact, implemented by your additional code in the Arduino plugin?