Page 1 of 1

HUE MQTT output format

Posted: Thursday 05 December 2019 18:08
by Gravityz
Hello,

i noticed that MQTT sends the hue light status as format

Code: Select all

{
   "Battery" : 255,
   "Color" : {
      "b" : 58,
      "cw" : 0,
      "g" : 175,
      "m" : 3,
      "r" : 254,
      "t" : 0,
      "ww" : 0
   },
   "Level" : 40,
   "RSSI" : 12,
   "description" : "",
   "dtype" : "Color Switch",
   "id" : "00000005",
   "idx" : 15,
   "name" : "LampachterTV",
   "nvalue" : 1,
   "stype" : "RGBWW",
   "svalue1" : "40",
   "switchType" : "Dimmer",
   "unit" : 1
}
however when sending a command to domoticz you have several options

Code: Select all

{"command": "setcolbrightnessvalue", "idx": 2450, "hue": 274, "brightness": 40, "iswhite": false }
{"command": "setcolbrightnessvalue", "idx": 2450, "hex": "RRGGBB", "brightness": 100, "iswhite": false }
{"command": "setcolbrightnessvalue", "idx": 2450, "color": {"m":3,"t":0,"r":0,"g":0,"b":50,"cw":0,"ww":0}, "brightness": 40}

is there a way to change the mqtt output format to let's say hue so that instead of sending the m,t,r,g,b,cw and cw it sends out the hue and brightness status

so basically something like this

Code: Select all

{
   "Battery" : 255,
   "hue" : 274,
   "Level" : 40,
   "RSSI" : 12,
   "description" : "",
   "dtype" : "Color Switch",
   "id" : "00000005",
   "idx" : 15,
   "name" : "LampachterTV",
   "nvalue" : 1,
   "stype" : "RGBWW",
   "svalue1" : "40",
   "switchType" : "Dimmer",
   "unit" : 1
}

Re: HUE MQTT output format

Posted: Thursday 05 December 2019 20:14
by waaren
Gravityz wrote: Thursday 05 December 2019 18:08 i noticed that MQTT sends the hue light status ...
is there a way to change the mqtt output format to let's say hue so that instead of sending the m,t,r,g,b,cw and cw it sends out the hue and brightness status ?
Hue is not an attribute in a domoticz device. It is a calculated value. The standard MQTT messages do not contain calculated- or any other type of derived attributes.
It would be possible to send whatever you like to whatever topic you like, using a script.

Re: HUE MQTT output format

Posted: Thursday 05 December 2019 21:12
by Gravityz
ok clear.

i thought maybe the output could be changed by using a variable since sending commands to domoticz with different standards (RGB, HUE, HEX) is also accepted.

i am already working on translating the R,G,B value to H,S,V values +using the brightness. the cw,m,t,ww values do not seem to matter

Re: HUE MQTT output format

Posted: Thursday 05 December 2019 21:49
by waaren
Gravityz wrote: Thursday 05 December 2019 21:12 i am already working on translating the R,G,B value to H,S,V values +using the brightness. the cw,m,t,ww values do not seem to matter
Maybe this site (dutch) will help

Re: HUE MQTT output format

Posted: Friday 06 December 2019 14:23
by Gravityz
thanks.

i found something even better

there is a node in node-red which can load npm modules
found this one
https://www.npmjs.com/package/color-convert

now i have 1 function which translates the MQTT message from domoticz to a hue oriented MQTT message


one problem however.

colors going out of domoticz through MQTT can not be replicated 100% when send back in. REALLY STRANGE.

when you send this back in the color is not the same

Code: Select all

{"command": "setcolbrightnessvalue", "idx": 11, "color": {"m":3,"t":0,"r":254,"g":171,"b":71,"cw":0,"ww":0}, "brightness": 65}
the same goes for the hex command
eg when you ask for the lightstatus, write al the RGB and brightness values down and send that exact data back to domoticz the light changes color slightly

eg, what is send out is through MQTT is not a 100% match of the light color
i think this has something to do with the fact that saturation is missing from the start

Re: HUE MQTT output format

Posted: Sunday 08 December 2019 12:03
by Gravityz
i solved this problem by using the hue api to get the light status

domoticz triggers node-red script. instead of using the hue numbers from MQTT i make a http request to the hue api and get the exact light states.
The same when changing a light bulb from Google. i use a http put request to put in the correct info.

works like a charm. i discovered something which initially looked like a bug in your MQTT script(but is not)
i however found the cause

all the hue lights, scenes and groups get imported into domoticz
i only tagged the lights i needed with MQTTSyncTrigger
now it seems that you can trigger any hue light without triggering a hue group EXCEPT for the light with the highest id.
apparently hue has a very simple logic and figurs the light group needs to switch on in case a light with the highest id is switched on.
so the MQTT message was not send by the script but was send by domoticz because the group switched on

anyway solved that by filtering out id's higher then 5 so i know for sure i only get the hue lights.