Home kit sets Fibaro RGBW to wrong colour

Posted on
Wed Nov 06, 2019 8:17 am
designpeg offline
Posts: 2
Joined: Oct 15, 2018

Home kit sets Fibaro RGBW to wrong colour

Has anyone got any advice on getting Fibaro RGBW module to set the correct colour with homekit?

My module works perfectly in Indigo, and appears as an rgbw device in Homekit on my phone, but when I set a colour it sets a totally different colour - normally always either blue, or a shade of white. I can see it the log that arg out of range error occurs when trying to set the colour.

Anyone got a solution or workaround?

Posted on
Tue Apr 28, 2020 6:22 am
7rdr7 offline
Posts: 163
Joined: Aug 16, 2017
Location: Washington DC Metro

Re: Home kit sets Fibaro RGBW to wrong colour

I may have a similar issue. I installed Inovelli RGBW bulbs, which are supported by Indigo, and added them to Homekit Bridge. I can turn the bulbs on/off, and dim, but the color palettes in the Home app do not function. It appears that the bulb wants a setting of 1-100, and the app is pushing higher values. That said, no matter what color that I select from the Home app, the color of the bulb does not change. I can only set the color from the Indigo client interface. Anyone seeing anything similar?

Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Z-Wave received "Main Pump" energy total to 252.659 kWh
Trigger Control Page Pump Power Cumulative
Z-Wave Error chr() arg not in range(256)
Trigger Armed Instant Variable Off
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Trigger Occupancy - Main Floor Motion Detectors
Action Group Set Main Floor Occupancy ON
Virtual Devices sent "Main Floor Occupancy" on
Z-Wave sent "Living Room Bulb" set brightness to 73
Z-Wave sent "Living Room Bulb" set brightness to 86
Z-Wave sent "Living Room Bulb" set brightness to 54
Z-Wave sent "Living Room Bulb" set brightness to 52
Z-Wave sent "Living Room Bulb" set brightness to 51
Z-Wave sent "Living Room Bulb" set brightness to 44
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Trigger Armed Instant Variable Off
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)
Z-Wave Error chr() arg not in range(256)

Posted on
Fri Jun 12, 2020 12:20 pm
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: Home kit sets Fibaro RGBW to wrong colour

I have the same problem with hue bulbs and it doesn’t seem to send colour temperature at all.

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

Re: Home kit sets Fibaro RGBW to wrong colour

Also the colour temperature seems to send an RGB colour, rather than the temperature which is annoying for devices that dont support RGB.

Posted on
Sun Jul 12, 2020 9:58 pm
srkinard offline
Posts: 320
Joined: Apr 10, 2016
Location: Austin, Texas

Re: Home kit sets Fibaro RGBW to wrong colour

Same here...there seems to be an issue with how Indigo+HomeKit Bridge handles the way HomeKit sends color commands

Here's a look at the log from when I was randomly playing with the color wheel in the Home app for macOS....every once and a while a color might work a little bit, but then fail additional changes.
Code: Select all
   Z-Wave Error                    chr() arg not in range(256)
   Z-Wave Error                    chr() arg not in range(256)
   Z-Wave Error                    chr() arg not in range(256)
   Z-Wave Error                    chr() arg not in range(256)
   Z-Wave Error                    chr() arg not in range(256)
   Z-Wave Error                    chr() arg not in range(256)
   Z-Wave Error                    chr() arg not in range(256)
   Z-Wave                          sent "012 - Composite" set brightness to 5
   Z-Wave                          sent "012 - Composite" set brightness to 0
   Z-Wave                          sent "012 - Composite" off
   Z-Wave                          received "012 - Red" status update is off
   Z-Wave                          received "012 - Green" status update is off
   Z-Wave                          received "012 - Blue" status update is off
   Z-Wave                          received "012 - White" status update is off
   Z-Wave Error                    chr() arg not in range(256)
   Z-Wave                          sent "012 - Composite" set color to 0 0 0, --
   Z-Wave                          sent "012 - Composite" set color to 0 0 0, --
   Z-Wave                          sent "012 - Composite" set brightness to 8
   Z-Wave                          sent "012 - Composite" on
   Z-Wave                          received "012 - Red" status update brightness 1
   Z-Wave                          received "012 - Green" status update brightness 2
   Z-Wave                          received "012 - Blue" status update brightness 1
   Z-Wave                          received "012 - Composite" status update brightness 2
   Z-Wave                          sent "012 - Composite" set brightness to 9
   Z-Wave                          received "012 - Red" status update brightness 3
   Z-Wave                          received "012 - Green" status update brightness 9
   Z-Wave                          sent "012 - Composite" set brightness to 10
   Z-Wave                          received "012 - Blue" status update brightness 3
   Z-Wave                          received "012 - Composite" status update brightness 9
   Z-Wave                          received "012 - Red" status update brightness 4
   Z-Wave                          received "012 - Green" status update brightness 10
   Z-Wave                          received "012 - Blue" status update brightness 4
   Z-Wave                          received "012 - Composite" status update brightness 10
   Z-Wave                          sent "012 - Composite" set color to 24 24 26, --
   Z-Wave                          received "012 - Red" status update brightness 24
   Z-Wave                          received "012 - Green" status update brightness 24
   Z-Wave                          received "012 - Blue" status update brightness 25
   Z-Wave                          received "012 - Composite" status update brightness 25
   Z-Wave                          received "012 - Composite" power load to 8.2 W
   Z-Wave                          sent "012 - Composite" set color to 33 64 30, --
   Z-Wave                          sent "012 - Composite" set color to 21 64 20, --
   Z-Wave                          sent "012 - Composite" set color to 31 64 31, --
   Z-Wave                          received "012 - Red" status update brightness 30
   Z-Wave                          received "012 - Green" status update brightness 64
   Z-Wave                          received "012 - Blue" status update brightness 31
   Z-Wave                          received "012 - Composite" status update brightness 64
   Z-Wave Error                    chr() arg not in range(256)
   Z-Wave Error                    chr() arg not in range(256)
   Z-Wave Error                    chr() arg not in range(256)
   Z-Wave Error                    chr() arg not in range(256)
   Z-Wave Error                    chr() arg not in range(256)
   Z-Wave Error                    chr() arg not in range(256)
   Z-Wave Error                    chr() arg not in range(256)
   Z-Wave Error                    chr() arg not in range(256)
   Z-Wave Error                    chr() arg not in range(256)
   Z-Wave                          received "012 - Composite" power load to 14.7 W
   Z-Wave Error                    chr() arg not in range(256)
   Z-Wave Error                    chr() arg not in range(256)
   Z-Wave Error                    chr() arg not in range(256)

Posted on
Sat Aug 15, 2020 5:57 pm
srkinard offline
Posts: 320
Joined: Apr 10, 2016
Location: Austin, Texas

Re: Home kit sets Fibaro RGBW to wrong colour

I've been poking around the guts of the plugin and noticed at least one thing.
C4W had put in some indigo.server.log output in the color processing part of homekit.py and commented them out (probably for release.)
I uncommented them and got a slightly better idea of what it was doing...I'm certainly no real programmer and have the simplest grasp on Python.

It looks like the plugin is getting values from the HomeKit app (in my case, the Home app on my phone or Mac.) that get processed as HSV in some cases, and some he has formatted as HST...with Temperature not Value...not sure what this exactly means.

One of the functions calls the python colorsys library to convert HSV to RGB...here's the code as it is in the plugin:
Code: Select all
            r, g, b = colorsys.hsv_to_rgb(h, s, v)
            r, g, b = [x*255.0 for x in r, g, b]

Now, here's the output from the logging I uncommented as I tried a color that gave the chr() arg not in range(256) error...
Code: Select all
   HomeKit Bridge                  Converting H: 0.616666666667 | S: 0.2 | V: 0.41
   HomeKit Bridge                  R: 83.64 | G: 89.913 | B: 104.55
   Z-Wave Error                    chr() arg not in range(256)

So, if you look at the RGB values returned by the code above, you see B is 104.55. These three RGB numbers would work in a 0-255 scale and should give the correct color, but Indigo wants a percent value for the RGB values...and 104.55 exceeds that, hence the error. The output of the raw HSVtoRGB before the *255 part is:
Code: Select all
>>> import colorsys
>>> colorsys.hsv_to_rgb(0.616666666667, 0.2, 0.41)
(0.328, 0.352599999999836, 0.41)

I modified the code to multiply by 100 not by 255, since the HSVtoRGG process outputs a value from 0.0 to 1.0, so technically it's already covered from the 0-255 scale to 0-100, just cut down to 1/100th.
Code: Select all
            r, g, b = colorsys.hsv_to_rgb(h, s, v)
            r, g, b = [x*100.0 for x in r, g, b]

Using this, the same input as before now gives the following RGB values
    R = 20.0899999999
    G = 13.12
    B = 41.0

So Indigo doesn't choke on these values since they won't exceed 100 now, and the colors match pretty close.

NOW...the part I'm banging my head against the wall on...

Sometimes it doesn't say "Adding Saturation to service" or "Adding Hue to service" as seen in this successful log set:
Code: Select all
   HomeKit Bridge                  Adding Saturation to service
   HomeKit Bridge                  H: -1 | S: 20.0 | T: -1
   HomeKit Bridge                  Adding Hue to service
   HomeKit Bridge                  H: 222.0 | S: 20.0 | T: -1
   HomeKit Bridge                  Setting color for 012 - Composite

It instead will say
Code: Select all
   HomeKit Bridge                  Adding ColorTemperature to service
   HomeKit Bridge                  H: -1 | S: -1 | T: 3125.0
   Z-Wave Error                    chr() arg not in range(256)

So it's trying to use a color temperature instead...and there's a bit of code for handling that, but something in there is not converting to usable RGB values. Here's the code block for this:
Code: Select all
         if hkservice.colortemperature != -1:
            # Color temps are completely independant of color (at least when using a Hue bulb integrated from the Hue app in Home it is, it can be white to orange
            kelvin = 1000000 / value # Convert mireds to Kelvin for the conversion
            r, g, b = calcs.convert_K_to_RGB(kelvin) # Convert Kelvin to RGB
            
            indigo.dimmer.setColorLevels (devId, redLevel=r, greenLevel=g, blueLevel=b)

This is where I spew long strings of profanity at Python, because I have tried every way of putting in the logs the RGB values EXACTLY the same way as in the other section, but ANY changes in this block will give an Invalid Syntax error and break the plugin loading.
Code: Select all
            indigo.server.log (u'R: {} | G: {} | B: {}'.format(r,g,b))

That's exactly the same line that works perfectly fine in the other parts of this to log the R G and B values...but if I try to put it (or ANY perfectly valid python code) anywhere in that block, it breaks.

Really disliking Python right now...I thought PowerShell was a pain in the butt...seriously...I cannot for the life of me figure out how/where it's breaking syntax or indentation...I get this
Code: Select all
   HomeKit Bridge Error            Error in plugin execution InitializeMain:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "plugin.py", line 82, in __init__
  File "/Library/Application Support/Perceptive Automation/Indigo 7.4/Plugins/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/lib/eps.py", line 130, in loadLibs
SyntaxError: ('invalid syntax', ('/Library/Application Support/Perceptive Automation/Indigo 7.4/Plugins/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/lib/homekit.py', 2892, 22, "                indigo.server.log (u'R: {} | G: {} | B: {}'.format(r,g,b))\n"))


If anyone who is better at this than me has any ideas how to see what the RGB values are when the if hkservice.colortemperature != -1: block calls the indigo.dimmer.setColorLevels (devId, redLevel=r, greenLevel=g, blueLevel=b) command after doing the Kelvin conversion call...

My head hurts...

Thanks
Ross

Posted on
Sun Aug 16, 2020 12:10 pm
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: Home kit sets Fibaro RGBW to wrong colour

Wish I could offer something more then good work but my python skills are less than yours.
But this is great detective work. Hopefully will lead to a fix soon

Posted on
Tue Sep 22, 2020 1:57 pm
vtmikel offline
Posts: 628
Joined: Aug 31, 2012
Location: Boston, MA

Re: Home kit sets Fibaro RGBW to wrong colour

I am also experiencing this with my RGBW device.

As it turns out, my device takes HSV format for it's input, so I've written logic to covert Indigo's RGBW to HSV, which works fine in Indigo as a native device. When I add that device to HomeKit, it's not working because it's sending my device HSV. My device plugin is then trying to convert the HSV (which it thinks is RGB) to HSV again.

Here's my code:
Code: Select all
                redLevel = round(float(float(actionColorVals['redLevel'])/100), 2)
                greenLevel = round(float(float(actionColorVals['greenLevel'])/100), 2)
                blueLevel = round(float(float(actionColorVals['blueLevel'])/100), 2)

                convert_hsv = colorsys.rgb_to_hsv(redLevel, greenLevel, blueLevel)

                payload = {'action': 'setColor',
                    'H': round(convert_hsv[0] * 360),
                    'S': round(convert_hsv[1] * 100),
                    'V': round(convert_hsv[2] * 100)
                }


C4W is there an opportunity to do the HSV to RGB conversion within HomeKit Bridge? If not each device will need a HSV->RGB adapter.

Mike

Posted on
Tue Sep 22, 2020 2:00 pm
srkinard offline
Posts: 320
Joined: Apr 10, 2016
Location: Austin, Texas

Re: Home kit sets Fibaro RGBW to wrong colour

Doesn't look like C4W has logged in since Jan...hopefully all is well and he's just busy.

Last visited:
Tue Jan 21, 2020 5:54 pm

Posted on
Tue Dec 29, 2020 10:32 am
7rdr7 offline
Posts: 163
Joined: Aug 16, 2017
Location: Washington DC Metro

Re: Home kit sets Fibaro RGBW to wrong colour

Having a similar issue with HomeKit Bridge using the Inovelli and Qubino RGB devices. Is anyone taking over the support of HKB? (far beyond my skillset).

Posted on
Tue Dec 29, 2020 12:35 pm
7rdr7 offline
Posts: 163
Joined: Aug 16, 2017
Location: Washington DC Metro

Re: Home kit sets Fibaro RGBW to wrong colour

Well, I guess we really do need someone to take over....

https://github.com/Colorado4Wheeler/Hom ... 0ac18f4865

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest