Fibaro last dim value?

Hi there!

First of all, thanks for reading : I’m new to Vera, but not to embedded programming (I’m a dev).

I’m trying to bind a virtual on/off switch value to switch on/off my Fibaro dimmer (FGD-211) using a single scene. I tried using Luup, but the dimmer only switch between 0 and 100% while I’d love the Fibaro could “remember” its last dim value (even physically set through the monostable switch):

local remote_id = 46
local dimmer_id = 64

local status = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", remote_id)
luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue=status }, dimmer_id)
return true

I tried reading the “LoadLevelStatus” first , but it only read “0” when switched off, and thus don’t work :

local remote_id = 46
local dimmer_id = 64

local status = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", remote_id)
local lightLevel = luup.variable_get("urn:upnp-org:serviceId:Dimming1", "LoadLevelStatus", dimmer_id)
if (status == "1") then
    luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = lightLevel}, dimmer_id)
else
    luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue=status }, dimmer_id)
end
return true

I’m sure there’s another mean to do what I want. Any hint?

If you turn the dimmer back on using SwitchPower1 SetTarget newTargetValue=1 it should come back on at the dim level it was at when it was turned off by a SwitchPower1 SetTarget newTargetValue=0 (or the local switch).

The problem comes when some action (scene or UI) turns it off by using the Off button on the Dimmer device UI. This sets the LoadLevelTarget to 0.

Thanks for the fast reply.

II just tried setting the dim value manually using the physical switch first, but unfortunately turning on the virtual switch will turn the dimmer to 100%…(using settarget)

Sorry, I don’t have a Fibaro dimmer to test but that isn’t what it is supposed to do. Check using (advanced) actions from scenes to see if SwitchPower1 SetTarget action works correctly from there.

I’ll try that. I’m sure it should work the way you think, since my fibaro dimmers returned to their previous state using my previous controller when turned on (a Zibase).

Using the UI, the behavior is the same : I set the dim to 50%, pressed off then on, and the dim is set to 100%…

Yes - that’s the standard behavior of the default DimmableLight UI. I may have a fix for that if you want to experiment. I modified the default UI for use with wireless-controlled LED lamps but it should also work with regular dimmers. I would need you to check if your device is using the normal device files:

Open up the device control box (click on wrench) and select Advanced tab. Check that device_type is urn:schemas-upnp-org:device:DimmableLight:1. Check that device_file is D_DimmableLight1.xml.

Both type and device are right. You mean the current behavior is standard on the Vera?

You mean the current behavior is standard on the Vera?
So it appears but I don't think many people control their lights through the UI.

OK, if you’re up for a test, upload the attached files to Vera using APPS, Develop Apps, Luup files, Choose Files. Select both files on two lines. At the bottom of the right-hand column, do not check Restart Luup after upload but click on Go. You should see Upload successful at the top of the right-hand column.

Now go back to the main UI screen (DEVICES) and open up your dimmer with the wrench. Select the Advanced tab and change device_file from D_DimmableLight1.xml to D_DimmableLightX1.xml - just insert an “X” before the “1”. Now close the device, click on Save/Reload and when that’s finished, reload/refresh your browser page. All being well, you will have a slightly better dimmer UI.

You can go back to the original by changing device_file back to D_DimmableLight1.xml and doing the Save/Reload and browser page reload.

Let me know if it helps.

Sorry for the late reply :wink:

I just tested your new implementation, but infortunately, the only thing that this json/xml file seem to do is to add a “min/max” button between the slider and the “on/off” buttons. Looking at the code can confirm that.

It seems that the current dimmer implemention just set the dim to 100% using setTarget. IMO, this is a VERA limitation since my Fibaro dimmers are able to remember their last dim value when using the wall button…

Should I go by writing my own dimmer implementation, or are we missing something?

are we missing something?
Maybe. If you click the [i]Off[/i] and [i]On[/i] buttons on the UI with my json, does the light go off and then come back on with the same dim level? That is what should happen.

Is there a file specified in impl_file under the Advanced tab?

When setting the dim using the UI (or the wall switch), the slider is correctly updated. But pressing the on button (with or without off before) on the UI (or my android phone) makes the dim go back to 100% :-\

The “impl_file” field is blank.

I didn’t know the default handling of a dimmer was that bad! :o I imagine it was written a long while back and nobody has been motivated to change it. I find it hard to believe, though. Switching on and off at the previous dim level seems a basic requirement of a dimmer. ??? It would be worth checking that the FGD configuration parameters are set correctly. The default values shown in the data sheet should be OK so check that your device is actually set that way.

You can access the configuration parameters through the device’s Device Options tab. Click add configuration settings, set the parameter number in the Variable box and set Data Size to monitor only. Then close the device and Save/Reload Vera and reload your browser page. You may have to do this a couple of times before the results show up.

As I mentioned earlier, I don’t have any actual dimmers in my system. I am using wireless-controlled LED lamps and I wrote the implementation code for these so they work as one would expect.

The corresponding parameter is right, moreover, when switching on/off the dimmer using the wall switch, the dimmer go back to whatever dim value it was set before ::slight_smile: So, not the dimmer fault. The setTarget just set the dim to 100%… :-\

Vera dimmer handling is really poor.

I tried to locate the implementation file without luck. Any hints?

It doesn’t have a specific implementation file - the handling is buried inside the main code, I believe. I don’t know how easy it would be to override the default actions with your own implementation. There must be a way but I have not (yet) had occasion to ferret out that part of the code.

Maybe one of the more experienced members knows where this stuff is located and can give some guidance.

ping Beta Testers ;D

Hi.

Not sure if I fully understand the issue, but I also have a Fibaro Dimmer and when I use the HomeWave app, it seems to recall the previous dimmer value when I turn it back on again.

(Not sure if that is a feature of the apps own code, but it does what i and i think you would expect it too.)

UPDATE- I have just tried th same thing on another MIOS iPhone app and that returns the light to 100% when I turn off and then back on a previously dimmed light

So, it’s just a VERA (un)feature… Where to ask for an improvement about that? This is ridiculous to have to set static dim values in scenes and/or luup! This is almost a deal killer… MCV, anyone?

Well, found this topic very late but seem to have the same issue.

If I turn on the light with the wall switch when I have had it turned off for a while, it will automatically turn on to 100%, whatever the last setting was before being turned off.

However, if I dim it down, using the wall switch, to lets say 20% and then turn it off again with the wall switch. If I then turn it on again shortly afterwards it still remembers the old state and turns on at 20%.

It also seems that this is not only a wall switch issue because the same happens if I control the light using Alexa.

It seems that Vera, or where ever the problem lies, forget the last state after a certain period of time.

This is such a annoying problem and I hope this could be resolved.