Hue Light Set Level Level Value

Please use template to report bugs and problems. Post here your questions when not sure where else to post
Only for bugs in the Domoticz application! other problems go in different subforums!
Forum rules
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.

Use the following template when posting here:

Version: xxxx
Platform: xxxx
Plugin/Hardware: xxxx
Description:
.....

If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly

If you are replying, please do not quote images/code from the first post

Please mark your topic as Solved when the problem is solved.
Post Reply
rwblinn
Posts: 13
Joined: Wednesday 10 June 2015 21:36
Target OS: Raspberry Pi
Domoticz version:
Contact:

Hue Light Set Level Level Value

Post by rwblinn » Friday 15 June 2018 14:31

Version: 3.9634
Platform: Raspberry Pi
Plugin/Hardware: Hue
Description:
There is a mismatch in setting the Level of a Huelight (lighning2 type) via URL JSON/API and the Widget.

Working on a Hue Light Synchronizer (using B4J) to set the level of a Domoticz Hue Widget using URL JSON/API.

Code: Select all

http://Raspberry-Pi-IP:8080/json.htm?type=command&param=switchlight&idx=NN&switchcmd=Set%20Level&level=LL
Because could not find information which value range to use to set the level LL, logged the MQTT JSON string, when changing a level using the widget, i.e. set to 53%

Code: Select all

{   "Battery" : 255,   "Level" : 53,   "RSSI" : 12,   "description" : "",   "dtype" : "Lighting 2",   "id" : "0000001",   "idx" : 68,   "name" : "Hue white lamp 1",   "nvalue" : 2,   "stype" : "AC",   "svalue1" : "8",   "switchType" : "Dimmer",   "unit" : 1}
The log showed Level: 53.

Using 53 in the URL JSON/API resulted in Level set of 100% in the widget - which was not expected?

Code: Select all

http://Raspberry-Pi-IP:8080/json.htm?type=command&param=switchlight&idx=68&switchcmd=Set%20Level&level=53
Explored the source PhilipsHue.cpp and found formula:

Code: Select all

LCmd = "Set Level";
float fvalue = (254.0f / 15.0f)*float(pSen->LIGHTING2.level);
if (fvalue > 254.0f)
	fvalue = 254.0f;
	svalue = round(fvalue);
}
Based on the formula, setting the Level, using URL JSON/API, works in a range between 0 - 15 corresponding to a logged Level MQTT JSON of:

Code: Select all

(level = %) 1 = 6, 2 = 13, 3 = 20, 4 = 26, 5 = 33, 6 = 40, 7 = 46, 8 = 53, 9 = 60, 10 = 66, 11 = 73, 12 = 80, 13 = 86, 14 = 93, 15 = 100
Example:

Code: Select all

http://Raspberry-Pi-IP:8080/json.htm?type=command&param=switchlight&idx=68&switchcmd=Set%20Level&level=8
Sets the displayed level in the widget to 53%.
Note:
When moving the slider, the level is set according previous table, i.e. it is not possible to set a value of 44%, but either 40% (6) or 46% (7).

For the syncronizer, need to use the table to set the level.

Question
Are there plans to sync the level settign between URL JSON/API and the widget?
Domoticz v3.4834, Raspberry Pi 1 B+/2 B/3, RFXtrx433e USB, 2* Somfy RTS, 6* TFA TS34C

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests