Get values of Fibaro RGBW dimmer

Hi,

I’m trying to do the following with a Fibaro RGBW dimmer:

  • Save the currently set values of the R/G/B/W channels
  • Set a fixed color value
  • Load the saved values of the R/G/B/W channels

With the following code I’m able to set the values:

luup.call_action(“urn:upnp-org:serviceId:Dimming1”, “SetLoadLevelTarget”, {newLoadlevelTarget = “0”}, G_Wohnzimmer) – RGB Green

But If I’m trying to get the currently set value with the following code I get an error:

G_Wohnzimmer_save = luup.varible_get(“urn:upnp-org:serviceId:Dimming1”,“GetLoadLevelTarget”,{[“newLoadlevelTarget”] = LOADLEVEL},G_Wohnzimmer)

Some tip, what I have to change?

You are confusing actions with variable names, and jumbling the two concepts together. This will get the value of a variable:

G_Wohnzimmer_save = luup.variable_get( "urn:upnp-org:serviceId:Dimming", "LoadLevelTarget", G_Wohnzimmer )

The reason you don’t use variable_set directly to set the brightness of a lamp (or most other parameters) is that the variable is only storage to tell you state, changing it does not cause communication with the device. So, you use actions to make something happen on the device, and this as a side-effect causes variables to change to reflect what the action has done.

Hope this helps.

Edit: By the way, don’t waste time on the “Get” actions. They exist because they are part of the UPnP standard service definition, but that’s the hard way and not necessary on Vera except in a few rare cases.

Thanks a lot!

I’ve tried the following code to see if it works (in Test luup code):

R_Wohnzimmer_save = luup.variable_get( “urn:upnp-org:serviceId:Dimming”, “LoadLevelTarget”, R_Wohnzimmer )

luup.call_action(“urn:upnp-org:serviceId:Dimming1”, “SetLoadLevelTarget”, {newLoadlevelTarget = R_Wohnzimmer_save}, W_Wohnzimmer) – RGB White

That should read the value of the red channel and paste it to the white channel. Since I’m not at home, that’s the only way to check if it works. But the white channel is set to “0” even if the red channel is set to “3”. Is there any way to take a look at the variables? I’ve typed print(R_Wohnzimmer_save) and the code seem to work, but where can I see the output?

I think I’ve found out the right code (added tonumber and Dimming to Dimming1:

R_Wohnzimmer_save = tonumber((luup.variable_get( “urn:upnp-org:serviceId:Dimming1”, “LoadLevelTarget”, R_Wohnzimmer )))

Also without “tonumber” works:

R_Wohnzimmer_save = luup.variable_get( “urn:upnp-org:serviceId:Dimming1”, “LoadLevelTarget”, R_Wohnzimmer )

Right, that’s because the service ID is incorrect in your first example:

R_Wohnzimmer_save = luup.variable_get( “urn:upnp-org:serviceId:Dimming”, “LoadLevelTarget”, R_Wohnzimmer )

You were missing the “1” after “Dimming”. You fixed that in the last two attempts.