Page 5 of 8

Re: zigbee2mqtt & zigbee USB for Hue bulbs

PostPosted: Tue Jun 16, 2020 6:49 am
by FlyingDiver
Gah, I really didn't want to write my own color converter. Let me get back to you on this...

Re: zigbee2mqtt & zigbee USB for Hue bulbs

PostPosted: Tue Jun 16, 2020 6:55 am
by siclark
tbh I dont look at the indigo colour representation all that often, and as long as it sets the right colour that is the main thing.

However, if you do, can you share with C4W :) as HomekitBridge doesnt seem to apply colour consistently, there are colour issues there as well, even on zwave devices where changing colour in HKB results in wrong colour being applied ot the device (probably because of a conversion issue)

Re: zigbee2mqtt & zigbee USB for Hue bulbs

PostPosted: Wed Jun 17, 2020 2:43 pm
by FlyingDiver
I decided to take a different tack on this. The problem (to me, anyway) is that the Hue bulbs only work on XY color space coordinates. So zigbee2mqtt has it's own built-in RGB to XY converter. But it doesn't have an XY to RGB converter. So there's no way to actually get back what you sent it. So using the library I linked to earlier, I'm now doing that conversion both ways in the plugin. So at least it's a consistent implementation of the conversion(s).

To get that to work, I had to change the specification of the color space in the device configuration dialog. According to the documentation, you'll need to pick one of the three Gamuts which match different Hue devices. Here's the code he has to map from device type to Gamut:

Code: Select all
def get_light_gamut(modelId):
    if modelId in ('LST001', 'LLC010', 'LLC011', 'LLC012', 'LLC006', 'LLC007', 'LLC013'):
        return GamutA
    elif modelId in ('LCT001', 'LCT007', 'LCT002', 'LCT003', 'LLM001'):
        return GamutB
    elif modelId in ('LCT010', 'LCT014', 'LCT011', 'LLC020', 'LST002'):
        return GamutC
    else:
        raise ValueError
    return None


You also need to change the payload template for setting the color, since for those devices the plugin is sending XY coordinates rather than RGB coordinates.

Code: Select all
    color_space: HueA
    set_rgb_template: '{"state":"ON","brightness":{{brightness}},"color":{"x":{{x}},"y":{{y}}}}'


Pre-release here:
https://github.com/FlyingDiver/Indigo-S ... /tag/0.3.1

Try all three possible Gamuts to see if one maps better for each device. Keep in mind that the conversions are not always symmetrical, because if the input RGB values result in a color that cannot be rendered in the selected Gamut color space, the "closest" point in the color space will be selected. And that new color, converted back to RGB, will be what shows in Indigo.

Re: zigbee2mqtt & zigbee USB for Hue bulbs

PostPosted: Thu Jun 18, 2020 6:32 am
by siclark
Thanks Joe for that speedy turnaround.

I have had an initial play, and it works, and yes there are some differnces in each one. But not spent enough time on it yet. I am struggling a little with the setup of the network, so waiting for some new mains devices to boost it before I can really play around on each bulb bulb type to see impact. (short of taking each bulb out and moving to the room where my mac is as Touch doesnt do colour selection)

Has your zigbee stick arrived yet?

Re: zigbee2mqtt & zigbee USB for Hue bulbs

PostPosted: Thu Jun 18, 2020 7:18 am
by FlyingDiver
siclark wrote:
Has your zigbee stick arrived yet?


Yeah, I have it working on an rPi, but I have no Zigbee devices so can't test it with anything. Don't really want to spend a lot on devices that I have no specific need for.

Re: zigbee2mqtt & zigbee USB for Hue bulbs

PostPosted: Thu Jun 18, 2020 8:33 am
by siclark
FlyingDiver wrote:
siclark wrote:
Has your zigbee stick arrived yet?


Yeah, I have it working on an rPi, but I have no Zigbee devices so can't test it with anything. Don't really want to spend a lot on devices that I have no specific need for.


Fair enough. And one device, ie bulb, is not much use by itself unless its very close to theusb stick. The sensors are pretty nice.

Extra thanks in that case in that this dev wont benefit you at all.

Re: zigbee2mqtt & zigbee USB for Hue bulbs

PostPosted: Thu Jun 18, 2020 9:24 am
by FlyingDiver
siclark wrote:
Extra thanks in that case in that this dev wont benefit you at all.


I have one remote location currently using an rPi and Wyze sensors, but I'd like to add a water sensor and maybe some others there. I might switch it to Z-wave or Zigbee. Still unlikely to use any color devices there. It's a vehicle storage condo, so pretty basic. One really big garage door, one personnel door. One overhead light circuit, for which I installed a TP-Link switch.

Re: zigbee2mqtt & zigbee USB for Hue bulbs

PostPosted: Tue Jun 30, 2020 3:32 pm
by siclark
Hi Joe. Life has overtaken me the last week so not has much change to Look at this.

I’ve changed my actions to use the mqtt connector to publish a message so I can set brightness and colour at the same time, rather than 2 actions.
Generally it’s working ok, the main issue still is that the indigo On State is not being updated when a device is turned off using only the state command.
This doesn’t update the brightness level and in think that’s needed in indigo for the On State to update. At least it goes to off if I set brightness to 0
I’m wondering can I make the off command also send the brightness:0 command?

Thanks

Re: zigbee2mqtt & zigbee USB for Hue bulbs

PostPosted: Tue Jun 30, 2020 3:42 pm
by FlyingDiver
I get confused easily. Can you show me the messages going both ways? Commands and status updates? Doesn't have to be from the connector, MQTT Explorer is fine.

Re: zigbee2mqtt & zigbee USB for Hue bulbs

PostPosted: Tue Jun 30, 2020 3:48 pm
by siclark
Setting brightness to zero does this

Set
Code: Select all
{"state": "ON", "brightness": 0 }
Returns
Code: Select all
{"state":"OFF","brightness":0,"color":{"x":0.380438429420364,"y":0.376746069841299},"color_temp":250,"linkquality":39,"last_seen":"2020-06-30T21:43:02.219Z"}


Turning off though
Set
OFF

Returns

Code: Select all
{"state":"OFF","brightness":79,"color":{"x":0.380438429420364,"y":0.376746069841299},"color_temp":250,"linkquality":39,"last_seen":"2020-06-30T21:43:27.295Z"}

Ie the bulb says it’s off but still has non zero brightness.


Does this help?

Re: zigbee2mqtt & zigbee USB for Hue bulbs

PostPosted: Tue Jun 30, 2020 3:52 pm
by FlyingDiver
Now I need to see how you have the Shim device configured.

Re: zigbee2mqtt & zigbee USB for Hue bulbs

PostPosted: Tue Jun 30, 2020 3:53 pm
by siclark
That will have to be tomorrow as not at my Mac at the moment.
Thanks

Re: zigbee2mqtt & zigbee USB for Hue bulbs

PostPosted: Tue Jun 30, 2020 3:54 pm
by FlyingDiver
Is it the same as you previously posted in this thread?

Re: zigbee2mqtt & zigbee USB for Hue bulbs

PostPosted: Tue Jun 30, 2020 3:59 pm
by FlyingDiver
Hmm. I just looked at the code. For dimmer and color devices, I currently just go by the brightness value (if it's in the payload). I guess that's not the right logic. I'll have to think about that.

Re: zigbee2mqtt & zigbee USB for Hue bulbs

PostPosted: Fri Jul 03, 2020 6:31 am
by siclark
Thanks Joe,

I am finally getting back to these. Looking at the Aqara wireless switches to control the light bulbs. They work great for on/off, and dimming zwave bulbs, but the MQTT color device which is the bulb doesnt appear to support Brighten/Dim By or Start Brightening/Dimming. which I would love be able to use with the hold / release commands from the Aqara wireless switches.

Is that an easy change?

I think at that point, we have a great alternative for zigbee bulbs as well as all the zigbee sensors that work well already.

Thanks