more G-Labs products

Author Topic: Incoherent dimmer Level value when using web api  (Read 427 times)

March 05, 2017, 11:48:51 AM
Read 427 times

amselem

  • **
  • Information
  • Jr. Member
  • Posts: 25
 Hello,
When setting a zwave dimmer via web api I use an url like this (to set the dimmer at 25%):
/api/HomeAutomation.ZWave/3/Control.Level/25

But when querying this same value with this url
/api/HomeAutomation.HomeGenie/Config/Modules.ParameterGet/HomeAutomation.ZWave/3/Status.Level

The returned value is 0.25 instead of 25

I think this is incoherent, HG is multiplying/dividing by 100 somewhere.

I'm binding this value to slider of an external application (which I don't control) and the get/set operations doesn't work correctly.

March 06, 2017, 05:10:38 PM
Reply #1

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
I agree that this is a bit non-intuitive.  But, perhaps the reason is because the URL would be more complicated with a decimal value?  I don't know the reason why you HG would return 25 rather than 0.25 as HG actually uses 0-1 for level values in code.

March 06, 2017, 10:22:55 PM
Reply #2

Bounz

  • ***
  • Information
  • Full Member
  • Posts: 94
Hi, amselem.
That's because you are setting the value directly to ZWave device (range [0-100]) but are reading the value from HG's module properties (range [0-1]).
I suggest you use following API endpoints and read data directly from device:
  • /api/HomeAutomation.ZWave/3/SwitchMultilevel.Set/35
  • /api/HomeAutomation.ZWave/3/SwitchMultilevel.Get

March 06, 2017, 11:45:36 PM
Reply #3

amselem

  • **
  • Information
  • Jr. Member
  • Posts: 25
Thank you very much Bounz!
 You were right, I was Reading/Writing to different sources (Zwave device vs HG Module).

The api you suggested works as expected.

Regards