zigbee2mqtt & zigbee USB for Hue bulbs

Posted on
Mon Jun 15, 2020 2:47 pm
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: zigbee2mqtt & zigbee USB for Hue bulbs

Nothing filtered.

Code: Select all
 MQTT Shims Debug                shimColor 1965234729: publish_topic: zigbee2mqtt/1965234729/set -> OFF
   MQTT Shims Debug                shimColor 1965234729: publish_topic: zigbee2mqtt/1965234729/set -> ON
   MQTT Shims Debug                shimColor 1965234729: publish_topic: zigbee2mqtt/1965234729/set -> {"state": "ON", "brightness": 255 }
   MQTT Shims Debug                shimColor 1965234729: publish_topic: zigbee2mqtt/1965234729/set -> {"state": "ON", "brightness": 128 }
   MQTT Shims Debug                shimColor 1965234729: publish_topic: zigbee2mqtt/1965234729/set -> {"state": "ON", "brightness": 255 }
   MQTT Shims Debug                shimColor 1965234729: actionColorVals: 'ActionProps : (dict)
     whiteTemperature : 1000 (integer)'
   MQTT Shims Debug                shimColor 1965234729: SetColorLevels, changing color temperature to: 1000.0
   MQTT Shims Debug                shimColor 1965234729: publish_topic: zigbee2mqtt/1965234729/set -> {"state":"ON","brightness":0,"color_temp":1000}
   MQTT Shims Debug                shimColor 1965234729: actionColorVals: 'ActionProps : (dict)
     whiteTemperature : 5000 (integer)'
   MQTT Shims Debug                shimColor 1965234729: SetColorLevels, changing color temperature to: 5000.0
   MQTT Shims Debug                shimColor 1965234729: publish_topic: zigbee2mqtt/1965234729/set -> {"state":"ON","brightness":0,"color_temp":200}
   MQTT Shims Debug                shimColor 1965234729: actionColorVals: 'ActionProps : (dict)
     blueLevel : 99.98398423194885 (real)
     greenLevel : 100 (real)
     redLevel : 99.98860955238342 (real)'
   MQTT Shims Debug                shimColor 1965234729: publish_topic: zigbee2mqtt/1965234729/set -> {"state":"ON","brightness":0,"color":{"r":255,"g":255,"b":255}}
   MQTT Shims Debug                shimColor 1965234729: actionColorVals: 'ActionProps : (dict)
     blueLevel : 3.847664967179298 (real)
     greenLevel : 0 (real)
     redLevel : 100 (real)'
   MQTT Shims Debug                shimColor 1965234729: publish_topic: zigbee2mqtt/1965234729/set -> {"state":"ON","brightness":0,"color":{"r":255,"g":0,"b":10}}
   MQTT Shims Debug                shimColor 1965234729: actionColorVals: 'ActionProps : (dict)
     blueLevel : 100 (real)
     greenLevel : 0 (real)
     redLevel : 0 (real)'
   MQTT Shims Debug                shimColor 1965234729: publish_topic: zigbee2mqtt/1965234729/set -> {"state":"ON","brightness":0,"color":{"r":0,"g":0,"b":255}}
   MQTT Shims Debug                shimColor 1965234729: actionColorVals: 'ActionProps : (dict)
     blueLevel : 0 (real)
     greenLevel : 100 (real)
     redLevel : 0 (real)'
   MQTT Shims Debug                shimColor 1965234729: publish_topic: zigbee2mqtt/1965234729/set -> {"state":"ON","brightness":0,"color":{"r":0,"g":255,"b":0}}


If I change the device state in MQTT directly, the device in Indigo does not update.

Interestingly the Send Status Request that shows on teh Dimmer device ( but not the colour device,) turns the device off. edit: due to the request being set not get in the template.
Attachments
Screenshot 2020-06-15 at 21.43.35.png
Screenshot 2020-06-15 at 21.43.35.png (168.72 KiB) Viewed 2867 times

Posted on
Mon Jun 15, 2020 2:54 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: zigbee2mqtt & zigbee USB for Hue bulbs

Ah. Looks like I made a bad assumption and coded this like the Lutron plugin, which gets an ack from the device with the new values as soon as it changes. So there, I update the device state based on the ack, not the command I sent.

I'll have a version with immediate update soon.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Jun 15, 2020 2:57 pm
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: zigbee2mqtt & zigbee USB for Hue bulbs

This is how it looks in MQTT explorer. You can see the set payload, and then payload the bulb reports back (using the xy notation, in the device name topic payload.

Screenshot 2020-06-15 at 21.56.17.png
Screenshot 2020-06-15 at 21.56.17.png (42.33 KiB) Viewed 2862 times

Posted on
Mon Jun 15, 2020 3:10 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: zigbee2mqtt & zigbee USB for Hue bulbs

siclark wrote:
This is how it looks in MQTT explorer. You can see the set payload, and then payload the bulb reports back (using the xy notation, in the device name topic payload.

Screenshot 2020-06-15 at 21.56.17.png


Hmmm. But the log isn't showing any of the reports coming back, which would update the device. So there's a problem with the topic subscription or the trigger.

Enabling debug logging on the Connector plugin might shed some light.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Jun 15, 2020 4:12 pm
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: zigbee2mqtt & zigbee USB for Hue bulbs

Ok, so I hadnt added the Topic Subscription to match this.

I now have zigbee2mqtt/1965234729/# as a subscribed Topic in my connector.

You had said not to bother with Trigger, and my mistake for not realising this is how it updated.

I have added a trigger and now see it appearing in the log.

Code: Select all
   MQTT Shims Debug                shimColor 1965234729: publish_topic: zigbee2mqtt/1965234729/set -> {"state": "ON", "brightness": 255 }
   Trigger                         shimColor 1965234729 Trigger

   MQTT Shims Debug                shimColor 1965234729: actionColorVals: 'ActionProps : (dict)
     whiteTemperature : 5604 (integer)'
   MQTT Shims Debug                shimColor 1965234729: SetColorLevels, changing color temperature to: 5604.0
   MQTT Shims Debug                shimColor 1965234729: publish_topic: zigbee2mqtt/1965234729/set -> {"state":"ON","brightness":0,"color_temp":178}
   Trigger                         shimColor 1965234729 Trigger

   MQTT Shims Debug                shimColor 1965234729: publish_topic: zigbee2mqtt/1965234729/set -> {"state": "ON", "brightness": 250 }
   Trigger                         shimColor 1965234729 Trigger

   MQTT Shims Debug                shimColor 1965234729: publish_topic: zigbee2mqtt/1965234729/set -> off
   Trigger                         shimColor 1965234729 Trigger

   MQTT Shims Debug                shimColor 1965234729: publish_topic: zigbee2mqtt/1965234729/set -> on
   Trigger                         shimColor 1965234729 Trigger



Its late here so have to call it a night. Hope this helps.

Posted on
Mon Jun 15, 2020 4:35 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: zigbee2mqtt & zigbee USB for Hue bulbs

The subscription should be 'zigbee2mqtt/#" and the trigger should be:

Code: Select all
    match_list: '["Match: zigbee2mqtt", "Any: ", "End: "]'

Otherwise you'll need a subscription and trigger for every device, which would not be optimal.

I'm looking into why it's not sending the brightness value on color_temp change.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Jun 15, 2020 4:53 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: zigbee2mqtt & zigbee USB for Hue bulbs

You should be seeing lines like this if the trigger is working and the message types in the device and the trigger match:

Code: Select all
   Trigger                         zigbee2mqtt
   MQTT Shims Debug                received notification of MQTT message type zigbee2mqtt from Synology Docker Broker
   MQTT Shims Debug                Zigbee Color Device: processMessages: 'zigbee2mqtt' zigbee2mqtt/893456234 -> {"state":"ON","brightness":255}

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Tue Jun 16, 2020 1:31 am
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: zigbee2mqtt & zigbee USB for Hue bulbs

Morning... not sure what was going on with the trigger, but have set it up like my other shim devices. as zigbee2mqtt/{group}/{uniqueid} and its now working. So I have zigbee2mqtt/HueBulb/Simon

But I am getting an error on setting one of the states.


Code: Select all
st_seen': u'2020-06-16T07:27:59.475Z'}, state = ON, value = 254
   MQTT Shims Debug                shimColor 1965234729: Updating brightnessLevel to 100
   MQTT Shims Debug                shimColor 1965234729: Updating color temperature to {u'y': 0.328207178425535, u'x': 0.318294697156752}
   MQTT Shims Debug                shimColor 1965234729: Updating states: [{'value': 98, 'key': 'redLevel'}, {'value': 99, 'key': 'greenLevel'}, {'value': 100, 'key': 'blueLevel'}]
   MQTT Shims Debug                shimColor 1965234729: Updating color temperature to 6211
   MQTT Shims Error                Error in plugin execution runConcurrentThread:

Traceback (most recent call last):
  File "plugin.py", line 112, in runConcurrentThread
  File "plugin.py", line 137, in processMessages
  File "plugin.py", line 472, in update
TypeError: state value type must be bool, int, real, or string

   MQTT Shims Error                plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)
   Trigger                         shimColor 1965234729 Trigger
   MQTT Shims Debug                received notification of MQTT message type ##HueBulb## from MQTT local broker
   Z-Wave                          received "Hall-Lamp-socket" power load to 0.6 W
   Trigger                         MQTT Aqara Temp
   MQTT Shims Debug                received notification of MQTT message type ##AqaraTemp## from MQTT local broker
   Trigger                         MQTT Aqara Temp
   MQTT Shims Debug                received notification of MQTT message type ##AqaraTemp## from MQTT local broker
   Trigger                         MQTT Aqara Temp
   MQTT Shims Debug                received notification of MQTT message type ##AqaraTemp## from MQTT local broker
   MQTT Shims Debug                shimColor 1965234729: processMessages: '##HueBulb##' zigbee2mqtt/HueBulb/Simon -> {"state":"ON","brightness":254,"color":{"x":0.318294697156752,"y":0.328207178425535},"color_temp":161,"linkquality":39,"last_seen":"2020-06-16T07:28:03.413Z"}
   MQTT Shims Debug                shimColor 1965234729: state = ON
   MQTT Shims Debug                shimColor 1965234729: shimColor, state_key = state, value_key = brightness, data = {u'color_temp': 161, u'linkquality': 39, u'brightness': 254, u'color': {u'y': 0.328207178425535, u'x': 0.318294697156752}, u'state': u'ON', u'last_seen': u'2020-06-16T07:28:03.413Z'}, state = ON, value = 254
   MQTT Shims Debug                shimColor 1965234729: Updating brightnessLevel to 100
   MQTT Shims Debug                shimColor 1965234729: Updating color temperature to {u'y': 0.328207178425535, u'x': 0.318294697156752}
   MQTT Shims Debug                shimColor 1965234729: Updating states: [{'value': 98, 'key': 'redLevel'}, {'value': 99, 'key': 'greenLevel'}, {'value': 100, 'key': 'blueLevel'}]
   MQTT Shims Debug                shimColor 1965234729: Updating color temperature to 6211
   MQTT Shims Error                Error in plugin execution runConcurrentThread:

Traceback (most recent call last):
  File "plugin.py", line 112, in runConcurrentThread
  File "plugin.py", line 137, in processMessages
  File "plugin.py", line 472, in update
TypeError: state value type must be bool, int, real, or string

   MQTT Shims Error                plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)
   MQTT Shims Debug                shimColor 1965234729: publish_topic: zigbee2mqtt/HueBulb/Simon/set -> on
   Trigger                         shimColor 1965234729 Trigger
   MQTT Shims Debug                received notification of MQTT message type ##HueBulb## from MQTT local broker
   Z-Wave                          received "Hall-Lamp-socket" power load to 7.0 W
   MQTT Shims Debug                shimColor 1965234729: processMessages: '##HueBulb##' zigbee2mqtt/HueBulb/Simon -> {"state":"ON","brightness":254,"color":{"x":0.299563662382277,"y":0.3094524825683},"color_temp":132,"linkquality":39,"last_seen":"2020-06-16T07:28:03.456Z"}
   MQTT Shims Debug                shimColor 1965234729: state = ON
   MQTT Shims Debug                shimColor 1965234729: shimColor, state_key = state, value_key = brightness, data = {u'color_temp': 132, u'linkquality': 39, u'brightness': 254, u'color': {u'y': 0.3094524825683, u'x': 0.299563662382277}, u'state': u'ON', u'last_seen': u'2020-06-16T07:28:03.456Z'}, state = ON, value = 254
   MQTT Shims Debug                shimColor 1965234729: Updating brightnessLevel to 100
   MQTT Shims Debug                shimColor 1965234729: Updating color temperature to {u'y': 0.3094524825683, u'x': 0.299563662382277}
   MQTT Shims Debug                shimColor 1965234729: Updating states: [{'value': 90, 'key': 'redLevel'}, {'value': 92, 'key': 'greenLevel'}, {'value': 100, 'key': 'blueLevel'}]
   MQTT Shims Debug                shimColor 1965234729: Updating color temperature to 7576
   MQTT Shims Error                Error in plugin execution runConcurrentThread:

Traceback (most recent call last):
  File "plugin.py", line 112, in runConcurrentThread
  File "plugin.py", line 137, in processMessages
  File "plugin.py", line 472, in update
TypeError: state value type must be bool, int, real, or string

   MQTT Shims Error                plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)
   MQTT Shims Debug                shimColor 1965234729: processMessages: '##HueBulb##' zigbee2mqtt/HueBulb/Simon -> {"state":"ON","brightness":254,"color":{"x":0.299563662382277,"y":0.3094524825683},"color_temp":132,"linkquality":39,"last_seen":"2020-06-16T07:28:07.078Z"}
   MQTT Shims Debug                shimColor 1965234729: state = ON
   MQTT Shims Debug                shimColor 1965234729: shimColor, state_key = state, value_key = brightness, data = {u'color_temp': 132, u'linkquality': 39, u'brightness': 254, u'color': {u'y': 0.3094524825683, u'x': 0.299563662382277}, u'state': u'ON', u'last_seen': u'2020-06-16T07:28:07.078Z'}, state = ON, value = 254
   MQTT Shims Debug                shimColor 1965234729: Updating brightnessLevel to 100
   MQTT Shims Debug                shimColor 1965234729: Updating color temperature to {u'y': 0.3094524825683, u'x': 0.299563662382277}
   MQTT Shims Debug                shimColor 1965234729: Updating states: [{'value': 90, 'key': 'redLevel'}, {'value': 92, 'key': 'greenLevel'}, {'value': 100, 'key': 'blueLevel'}]
   MQTT Shims Debug                shimColor 1965234729: Updating color temperature to 7576
   MQTT Shims Error                Error in plugin execution runConcurrentThread:

Traceback (most recent call last):
  File "plugin.py", line 112, in runConcurrentThread
  File "plugin.py", line 137, in processMessages
  File "plugin.py", line 472, in update
TypeError: state value type must be bool, int, real, or string

   MQTT Shims Error                plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)



Simon.

Posted on
Tue Jun 16, 2020 2:41 am
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: zigbee2mqtt & zigbee USB for Hue bulbs

Tried publishing messages direct to zigbee2mqtt/HueBulbs/Simon and seeing impact on the Shims trigger. state, brightness and color_temp all worked fine. The problem is on the color array for rgb. If I publish

Code: Select all
{
  "state": "ON",
  "brightness": 250,
  "r": "97",
  "g": "255",
  "b": "68"
}


It works and correctly updates the shims device in Indigo to the right colour.

However with the rgb values nested within "color" it doesnt work.

Posted on
Tue Jun 16, 2020 3:31 am
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: zigbee2mqtt & zigbee USB for Hue bulbs

A colour device with RGB turned off is working correctly, however whilst the state custom property is updating correctly in Indigo, the On State is not, so the device icon is not reflecting the correct state.

Brightness is working ok.

Posted on
Tue Jun 16, 2020 5:54 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: zigbee2mqtt & zigbee USB for Hue bulbs

Let's deal with one thing at a time. The config screen shot you posted showed that the multi-states key field was empty. Please confirm that's still true. The Line 472 error is from trying to process that option. If it's empty and you're getting the error, turn on "detailed debug logging" briefly until you get that error, then turn it off again. You should get another line in the log with "update, new states_list:". I need to see that line.

Make sure you are NOT publishing the MQTT Shim devices the same way (in the MQTT Connector plugin) that you were publishing your dummy devices (using the Example plugin). I don't think this "native" method can co-exist with your node-red filter method. For testing, it would be best if you disabled the other system temporarily.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Tue Jun 16, 2020 6:17 am
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: zigbee2mqtt & zigbee USB for Hue bulbs

Morning. Sorry, my mistake. . I enable multi-states with a . to see the full reply. I have removed that and no more errors

Indeed, I have created new devices in indigo, so these arent getting published, and have renamed the devices in zigbee2mqtt so its only the shims method being applied and to make doubly sure I have disable that connector.

I think there is an issue with the colour conversion.

For instance when I publish via MQTT Tool
Code: Select all
{
  "state": "ON",
  "brightness": 255,
  "color": {
    "r": "0",
    "g": "255",
    "b": "0"
  }
}


I get this back
Code: Select all
{"state":"ON","brightness":254,"color":{"x":0.1724,"y":0.7468},"color_temp":154,"linkquality":39,"last_seen":"2020-06-16T12:10:50.857Z"}
.

but Indigo reports it as 92,100,26. which is a yellow. Similarly pure red gets reported as an orange, 100,27,0, and pure blue as 33,0,100.

Posted on
Tue Jun 16, 2020 6:36 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: zigbee2mqtt & zigbee USB for Hue bulbs

Hmm. I know nothing about XY color spaces, so I'm not sure what's going on. Most of the stuff I see online refers to XYZ color space, not XY.

But just so I have some data to test with, can you confirm that sending the RGB commands from Indigo actually does control the bulb properly? And post a chart of the results for multiple colors? Like:

Code: Select all
Sent: 0, 255, 0 (green)
Received: 0.1724, 0.7468
Updated: 92, 100, 26 (yellow)

Sent: 0, 0, 255 (blue)
Received: ??
Updated: 33, 0, 100

Sent: 255, 0, 0 (red)
Received: ??
Updated: 100, 27, 0

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Tue Jun 16, 2020 6:40 am
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: zigbee2mqtt & zigbee USB for Hue bulbs

Sent: 0, 255, 0 (green)
Received: 0.1724, 0.7468
Updated: 92, 100, 26 (yellow)

Sent: 0, 0, 255 (blue)
Received: 0.1355, 0.0399
Updated: 33, 0, 100

Sent: 255, 0, 0 (red)
Received: 0.7006, 0.2993
Updated: 100, 27, 0

Posted on
Tue Jun 16, 2020 6:44 am
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: zigbee2mqtt & zigbee USB for Hue bulbs

This might help, its how zigbee2mqtt converts from RGB to XY to send to the bulb!

https://github.com/Koenkk/zigbee2mqtt/issues/272

edit: better, function the other way

https://github.com/Koenkk/zigbee2mqtt/issues/3497

Code: Select all
function xy2rgb(x, y, brightness){
   //Set to maximum brightness if no custom value was given (Not the slick ECMAScript 6 way for compatibility reasons)
   if (brightness === undefined) {
      brightness = 254;
   }

   var z = 1.0 - x - y;
   var Y = (brightness / 254).toFixed(2);
   var X = (Y / y) * x;
   var Z = (Y / y) * z;

   //Convert to RGB using Wide RGB D65 conversion
   var red    =  X * 1.656492 - Y * 0.354851 - Z * 0.255038;
   var green    = -X * 0.707196 + Y * 1.655397 + Z * 0.036152;
   var blue    =  X * 0.051713 - Y * 0.121364 + Z * 1.011530;

   //If red, green or blue is larger than 1.0 set it back to the maximum of 1.0
   if (red > blue && red > green && red > 1.0) {

      green = green / red;
      blue = blue / red;
      red = 1.0;
   }
   else if (green > blue && green > red && green > 1.0) {

      red = red / green;
      blue = blue / green;
      green = 1.0;
   }
   else if (blue > red && blue > green && blue > 1.0) {

      red = red / blue;
      green = green / blue;
      blue = 1.0;
   }

   //Reverse gamma correction
   red    = red <= 0.0031308 ? 12.92 * red : (1.0 + 0.055) * Math.pow(red, (1.0 / 2.4)) - 0.055;
   green    = green <= 0.0031308 ? 12.92 * green : (1.0 + 0.055) * Math.pow(green, (1.0 / 2.4)) - 0.055;
   blue    = blue <= 0.0031308 ? 12.92 * blue : (1.0 + 0.055) * Math.pow(blue, (1.0 / 2.4)) - 0.055;


   //Convert normalized decimal to decimal
   red    = Math.round(red * 255);
   green    = Math.round(green * 255);
   blue    = Math.round(blue * 255);

   if (isNaN(red))
      red = 0;

   if (isNaN(green))
      green = 0;

   if (isNaN(blue))
      blue = 0;

   return {
        r: red,
        g: green,
        b: blue,
    };
}

Who is online

Users browsing this forum: No registered users and 1 guest