OH3 Color light bulb and Google Assistant

  • Platform information:
    • Hardware: Raspi4
    • OS: Openhabian
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version: OH 3.1

Hi There,

i have installed two Shelly Bulb duo. I want to expose them to Google Assistant but i dont get it to work.
I configured a new item group with the items described in documentation:



First of all the OH GUI did not suggest a Google tag named “lightPower”. So i used just the Light tag.

In Google there is only a light bulb with white spectrum visible but no color configuration.
image

I have also an internal group “all_lights” which is not exposed to google. To realize this i created two items for the shelly bulb.
But these items are not synchronized:

I think this is really complicated for just a color bulb…

I dont get it… Any help is very apreciated!

br

Anyone an idea?

There has been an update release so that also a separate Color item can be configured: Google Assistant | openHAB

Thus, I would suggest to replace the lightColorTemperature with lightColor.

The power item needs to have the lightPower metadata set.
As this might not be selectable yet with the UI, you have to manually assign it.

Only the group item should have the light metadata assigned.

@michikrug Nice one for clearing this up re assistant and “specialcolorlight”, do you know if there is a function within GA to invert the colour temperature function when taking it as a %?
Currently, by default GA 0%=COOL 100%=WARM the bulbs I have are the opposite 0%=WARM 100%=COOL. This makes more sense in my head as the warmer the colour temper the lower the number.
I wanted to see if this is something I can get GA to output before I go down the rabbit hole of converting in OH.
Thanks in advance!

Currently there is no option to do so.

Google internally always uses Kelvin for color temperatures, which also explains the percentage conversion you observed.
See Cloud-to-cloud  |  Google Home

I got it to run as follows:

  • Group with MetaData SpecialColorItem
  • Control member with MetaData lightPower
  • Color member (not color temperature) with MetraData lightColor (not lightColorTemperature)
  • Brightness member with MetaData ´lightBrightness´

Not all of them are selectable in the UI. You have to select a random one, and then switch to the Code tab and enter it manually.

In the doc, there is also a way described how you can add a pattern with sub-groups to control multiple lights at once.

Thanks for getting back @michikrug I’ve just been looking into this again and still think that surely it makes more logical sense to make the GA % scale lower=warmer higher=cooler as per the kelvin scale?
In the GA colour temperature range it states MinK 2000 for example which would be very warm and MaxK 9000 very cold
“colorTemperatureRange”: {
“temperatureMinK”: 2000,
“temperatureMaxK”: 9000
}

Hi and sorry for the super late reply.

I had a look and do not see an issue (currently) in changing the behavior towards what you requested.
I still wonder why it was implemented like this in the first place. There need to be some reason I will try to figure out.

Thanks for the reply @michikrug , it does seem a little odd, I have stopped trying to make a workaround for now. Hopefully, something will come to “light” in the future.

Cheers

Implementation done.

Will probably merge this right after and do a release.


It’s released. Feel free to try :slight_smile:

Hey there,

TLDR: Can someone send me a working example with using the colorUnit being set to percent?


I have a problem getting the color temperature to work. I got a channel for brightness, one for color and one for color temperature. The first two work as expected however I have problems getting the temperature to work.
The temperature item wants to recieve a number between 0 (cold) and 100 (warm). Thus I thought to use colorUnit=percent as seen below however than google doesn’t accept the item (it doesn’t show up in the home app)

Group     Licht_Badezimmer_Spiegellampe_Gruppe                "Spiegellampe"                                                                                           {ga="SpecialColorLight" [colorUnit="percent" , roomHint="Badezimmer"]}
Color     Licht_Badezimmer_Spiegellampe_Farbe                 "Farbe"                   <spiegel>        (Licht_System_Allem, Licht_Badezimmer_Spiegellampe_Gruppe)    {channel="zigbee:device:System_Zigbee_Coordinator:a4c1381e075a21a5:A4C1381E075A21A5_1_color", ga="lightColor"}
Number    Licht_Badezimmer_Spiegellampe_Farbtemperatur        "Farbtemperatur"          <spiegel>        (Licht_Badezimmer_Spiegellampe_Gruppe)                        {channel="zigbee:device:System_Zigbee_Coordinator:a4c1381e075a21a5:A4C1381E075A21A5_1_colortemperature", ga="lightColorTemperature"}
Dimmer    Licht_Badezimmer_Spiegellampe_Helligkeit            "Helligkeit [%d]"         <spiegel>        (Licht_Badezimmer_Spiegellampe_Gruppe)                        {channel="zigbee:device:System_Zigbee_Coordinator:a4c1381e075a21a5:A4C1381E075A21A5_1_color", ga="lightBrightness"}

If I add the colorTemperatureRange it always sends the value 100, no matter the temperature I choose in the app.

Group     Licht_Badezimmer_Spiegellampe_Gruppe                "Spiegellampe"                                                                                           {ga="SpecialColorLight" [colorUnit="percent", colorTemperatureRange="0,100", roomHint="Badezimmer"]}

If I switch the colorUnit to kelvin and set my available range (2500K-6500) google uses the item however it send number between 2500 and 6500 to my item which it can’t convert since it wants a percentage.
I certainly could build a rule which maps a number in 0-100 from 2500-6500, however I thought this should work without, right?

Could you please set the temperature range in kelvin.
So “2500,6500” instead of “0,100” (which obviously does not make much sense as everything below 500 kelvin is probably just pure red).

For the first part of your question… If using percent for the temperature, you always have to set a range. Otherwise, the system can not calculate what e.g. 20% are in kelvin.
This is why the device did not appear in the configuration shown.

This makes sense…^^ That has fixed it, so the combo with percent and setting the temperature range solved it.
Now I understand why the PR is needed, running into the same issue now. Thanks!

@michikrug Can you tell me how? Is there a .jar somewhere to download (didn’t find any in the github releases) or how can I update the integration. I wasn’t able to find any information on how to do this.

Thanks for your help!

There is nothing to do for you.
There is a piece of code running in the web that is called by Google Assistant and the openHAB connection, which is updated automatically on every release.

So if you still are facing an issue, please again share your setup and observed behaviour, so that I can do another round of investigation.
At least I thought I fixed the issue you saw.

Awesome nice one @michikrug, I’ll give it a go when I can!

I thought I was^^. I just tested it again and the following happens:

  • If I tell google with “hey google, …” to turn the lamp to warm white it does so
  • If I use the Home app to set the lamp to warm white it gets set to cold white.

I don’t know/don’t think this is something you can fix but a bug in googles software.

Thanks. I may test a similar scenario too. Let’s see…

I have exactly copied our item code (without the channels ofc.) into my system and synced with GA.
Everything works as expected.

Telling GA to turn to warm white ends up in 12.5 on the Farbtemperatur item
Telling to turn to cold white results in 37.5

Same is reflected in the Google Home app.
Selecting the most warm color → 0 is sent to the Farbtemperatur item
Selecting the most cold one → 87.5 is sent

Could you share what your items are receiving in the mentioned cases?

EDIT: I still have to mention I run and use a slightly different version of the GA integration and not the official one

Interesting. This is the following behaviour I observe:

  1. My items

    Group     Licht_Badezimmer_Spiegellampe_Gruppe                "Spiegellampe"                                                                                            {ga="SpecialColorLight" [colorUnit="percent", colorTemperatureRange="2500,6500", roomHint="Badezimmer"]}
    Color     Licht_Badezimmer_Spiegellampe_Farbe                 "Farbe"                     <spiegel>        (Licht_System_Alle, Licht_Badezimmer_Spiegellampe_Gruppe)    {channel="hue:0210:Licht_System_HueBridge:Licht_Badezimmer_Spiegellampe:color", ga="lightColor"}
    Dimmer    Licht_Badezimmer_Spiegellampe_Farbtemperatur        "Farbtemperatur [%d %%]"    <spiegel>        (Licht_Badezimmer_Spiegellampe_Gruppe)                       {channel="hue:0210:Licht_System_HueBridge:Licht_Badezimmer_Spiegellampe:color_temperature", ga="lightColorTemperature"}
    Dimmer    Licht_Badezimmer_Spiegellampe_Helligkeit            "Helligkeit [%d %%]"        <spiegel>        (Licht_Badezimmer_Spiegellampe_Gruppe)                       {channel="hue:0210:Licht_System_HueBridge:Licht_Badezimmer_Spiegellampe:color", ga="lightBrightness"}
    
  2. So the Item Licht_Badezimmer_Spiegellampe_Farbtemperatur uses 0 for cold white and 100 for warm white

  3. Sending via voice

    1. “Set Spiegellampe to warm white”: Item 'Licht_Badezimmer_Spiegellampe_Farbtemperatur' received command 12.5
    2. “Set Spiegellampe to cold white”: Item 'Licht_Badezimmer_Spiegellampe_Farbtemperatur' received command 37.5
  4. Sending via Home app:

    1. Select the warmest white (top left): Item 'Licht_Badezimmer_Spiegellampe_Farbtemperatur' received command 0
    2. Select the coldest white (bottom right): Item 'Licht_Badezimmer_Spiegellampe_Farbtemperatur' received command 87.5

So:

  • 3.1: Is mixed up (receives 12.5, should receive 100)
  • 3.2: Works but could be colder (receives 37.5, should receive 0)
  • 4.1: Is mixed up: (receives 0, should receive 100)
  • 4.2: Is mixed up: (receives 87.5, should receive 0)

While doing this I wonder why the received values have the ranges [12.5,37.5] and [0,87] and not [0,100]