Home kit sets Fibaro RGBW to wrong colour

designpeg
Posts: 2
Joined: Mon Oct 15, 2018 6:15 am

Home kit sets Fibaro RGBW to wrong colour

Post by designpeg »

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?
7rdr7
Posts: 200
Joined: Wed Aug 16, 2017 7:06 pm
Location: Gulfport, FL

Re: Home kit sets Fibaro RGBW to wrong colour

Post by 7rdr7 »

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)
siclark
Posts: 2356
Joined: Tue Jun 13, 2017 5:08 am
Location: UK

Re: Home kit sets Fibaro RGBW to wrong colour

Post by siclark »

I have the same problem with hue bulbs and it doesn’t seem to send colour temperature at all.
siclark
Posts: 2356
Joined: Tue Jun 13, 2017 5:08 am
Location: UK

Re: Home kit sets Fibaro RGBW to wrong colour

Post by siclark »

Also the colour temperature seems to send an RGB colour, rather than the temperature which is annoying for devices that dont support RGB.
srkinard
Posts: 320
Joined: Sun Apr 10, 2016 5:55 pm
Location: Austin, Texas

Re: Home kit sets Fibaro RGBW to wrong colour

Post by srkinard »

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)
srkinard
Posts: 320
Joined: Sun Apr 10, 2016 5:55 pm
Location: Austin, Texas

Re: Home kit sets Fibaro RGBW to wrong colour

Post by srkinard »

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
siclark
Posts: 2356
Joined: Tue Jun 13, 2017 5:08 am
Location: UK

Re: Home kit sets Fibaro RGBW to wrong colour

Post by siclark »

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
vtmikel
Posts: 717
Joined: Fri Aug 31, 2012 12:45 pm
Location: Boston, MA
Contact:

Re: Home kit sets Fibaro RGBW to wrong colour

Post by vtmikel »

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
srkinard
Posts: 320
Joined: Sun Apr 10, 2016 5:55 pm
Location: Austin, Texas

Re: Home kit sets Fibaro RGBW to wrong colour

Post by srkinard »

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
7rdr7
Posts: 200
Joined: Wed Aug 16, 2017 7:06 pm
Location: Gulfport, FL

Re: Home kit sets Fibaro RGBW to wrong colour

Post by 7rdr7 »

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).
7rdr7
Posts: 200
Joined: Wed Aug 16, 2017 7:06 pm
Location: Gulfport, FL

Re: Home kit sets Fibaro RGBW to wrong colour

Post by 7rdr7 »

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

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

Return to “HomeKit Bridge”