We have moved at community.getvera.com

Author Topic: Fibaro last dim value?  (Read 4533 times)

Offline nono240

  • Sr. Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
Fibaro last dim value?
« on: April 27, 2013, 08:24:24 am »
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):

Code: [Select]
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 :

Code: [Select]
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?
« Last Edit: April 27, 2013, 08:26:39 am by nono240 »

Offline RexBeckett

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3891
  • Karma: +483/-12
Re: Fibaro last dim value?
« Reply #1 on: April 27, 2013, 09:02:13 am »
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.

Offline nono240

  • Sr. Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
Re: Fibaro last dim value?
« Reply #2 on: April 27, 2013, 09:25:56 am »
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)
« Last Edit: April 27, 2013, 09:27:36 am by nono240 »

Offline RexBeckett

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3891
  • Karma: +483/-12
Re: Fibaro last dim value?
« Reply #3 on: April 27, 2013, 09:50:16 am »
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.

Offline nono240

  • Sr. Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
Re: Fibaro last dim value?
« Reply #4 on: April 27, 2013, 10:03:46 am »
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%..



Offline RexBeckett

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3891
  • Karma: +483/-12
Re: Fibaro last dim value?
« Reply #5 on: April 27, 2013, 10:16:54 am »
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.

Offline nono240

  • Sr. Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
Re: Fibaro last dim value?
« Reply #6 on: April 27, 2013, 10:25:03 am »
Both type and device are right. You mean the current behavior is standard on the Vera?

Offline RexBeckett

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3891
  • Karma: +483/-12
Re: Fibaro last dim value?
« Reply #7 on: April 27, 2013, 10:52:02 am »
Quote
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.

Offline nono240

  • Sr. Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
Re: Fibaro last dim value?
« Reply #8 on: April 28, 2013, 03:12:48 am »
Sorry for the late reply  ;)

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?


Offline RexBeckett

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3891
  • Karma: +483/-12
Re: Fibaro last dim value?
« Reply #9 on: April 28, 2013, 04:15:23 am »
Quote
are we missing something?
Maybe. If you click the Off and On 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?

Offline nono240

  • Sr. Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
Re: Fibaro last dim value?
« Reply #10 on: April 28, 2013, 04:27:05 am »
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.

Offline RexBeckett

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3891
  • Karma: +483/-12
Re: Fibaro last dim value?
« Reply #11 on: April 28, 2013, 05:23:56 am »
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.

Offline nono240

  • Sr. Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
Re: Fibaro last dim value?
« Reply #12 on: April 28, 2013, 07:21:02 am »
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  ::) 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?

Offline RexBeckett

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3891
  • Karma: +483/-12
Re: Fibaro last dim value?
« Reply #13 on: April 28, 2013, 07:53:34 am »
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

Offline parkerc

  • Beta Testers
  • Sr. Hero Member
  • *****
  • Posts: 2479
  • Karma: +35/-48
  • Life Moves Pretty Fast....
Re: Fibaro last dim value?
« Reply #14 on: May 02, 2013, 04:29:47 pm »
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.)