HUE MQTT output format

Others (MiLight, Hue, Toon etc...)

Moderator: leecollings

Post Reply
Gravityz
Posts: 583
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

HUE MQTT output format

Post 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
}
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: HUE MQTT output format

Post 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.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Gravityz
Posts: 583
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: HUE MQTT output format

Post 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
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: HUE MQTT output format

Post 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
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Gravityz
Posts: 583
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: HUE MQTT output format

Post 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
Gravityz
Posts: 583
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: HUE MQTT output format

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest