Philips Hue CLIP 2 API v2 Discussion Thread

I tested this, when i send the ON command to the color-xy-only channel it just sends 100 to that channel, the light is still off and when I give the Brightness a value greater than 0, it didn’t receive the color command I send earlier when the light was off / brightness 0.

As I have said several times already YOU CANNOT SEND AN ON COMMAND TO THE ‘color-xy-only’ CHANNEL – read the channel name it says COLOR XY ONLY!!

To summarise…

  • color channel accepts HSBType (to change color and brightness), PercentType (to change brightness), or OnOffType (to switch on or off)
  • color-xy-only channel accepts HSBType (to change color - the ‘B’ part is ignored) ONLY
  • dimming-only channel accepts PercentType (to change brightness) ONLY
  • on-off-only channel accepts OnOffType (to switch on or off) ONLY
  • color-temperature channel accepts PercentType (to change the color temperature)

If you want to turn on the lamp at a given color temperature you must send TWO (or ev. three) commands…

  1. Send OnOffType.ON to on-off-only channel
  2. Send PercentType value to color-temperature channel
  3. (ev. send PercentType value to dimming-only channel)
1 Like

Didn’t want to make you angry :wink: I didn’t read your last post correct, I read the color-yx-only in stead of on-off-only. That’s why I tested it, I thought it was odd to though. My bad, sorry! People make mistakes luckily, it makes us people :wink:

Thanks for the clarification, so I have to create a second item per light for the on-off channel to be able to use the color-temperature with API v2. Perfect sollution for me! But I didn’t got that from the documentation, my bad, I could have done this, but never got the idea to use the ON/OFF channel. To me it sounded like a channel just to turn ON and OFF the light.

I will try this and it sounds like it’s gonna work.

I really didn’t want to get on your nerves, i’m super glad you take so much time to give us this great binding! Thnx for the help and all the work :slight_smile:

1 Like

I tried this, and it works, the error is gone. But sending ON to those channels, does turn the lights on at around 1%. Maybe i’m still doing something wrong here but i’m not sure where to look anymore.

Maybe i’m not clear enough, so i’ll try again explaining my problem:

In the morning, when all the lights are off and we are sleeping, I want to set the kitchen light temperature color to value 35% but the lights has to stay OFF (brightness 0%). When I walk into the kitchen, the lights go on to a certain brightness with the light color temperature of 35%.

With API 1, this was no problem. I used this from Openhab 2.3 till couple of monts ago. I just send value 35% to the Color-temperature channel and the light changed to that value but the brightness remained at 0%.

With API 2 we have to use the on-off-only channel to be able to set a color temperature for the lights, but when we do, the lights go on. That’s strange and unnessarary in my opinion.

Offcourse, I can send the ON command → light brightness goes to 1% → set the color temperature → and send an OFF command. But that causes lights to go ON and OFF at certain times when I set the color temperature and this feels a bit dumb.

As i’m seeing it, API 2 does not support setting a color value or temperature value to a light which is switched OFF or am I wrong with this? I tested this with the Philips Hue Ambient lights and also the Philips Hue ledstrip but they both go ON at 1% after send the ON command.

Try it. AFAIK the color temp command should work but will produce the following entry in the log; and then a later on-off command should probably take over the new value.

Command ... succeeded with errors: device (light) is "soft off", command ... may not have effect

Hi
I am not sure if this is an OH issue or a Binding issue?

I have a Color Spot with a color channel linked. When I try and set the “H”, the UI requires a reload. I do not see anything in the logs (only for “H”, “S” and “B” produce log entries.
Hue Color
Also only getting the tiny circle to adjust the values (should this not be a slider?)

Items defined as:

label: Hue color spot 7 Color
type: Color
category: ""
groupNames: []
groupType: None
function: null
tags:
 - Control
 - Light

Logs:

11:58:13.926 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Hue_color_spot_7_Color' received command 260,100,73
11:58:13.927 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'Hue_color_spot_7_Color' predicted to become 260,100,73
11:58:13.927 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Hue_color_spot_7_Color' changed from 260.845,100,100 to 260,100,73
11:58:13.998 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Hue_color_spot_7_Color' changed from 260,100,73 to 260.845,100,73.12
11:58:13.999 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Hue_color_spot_7_Brightness' changed from 100 to 73.12
11:58:13.999 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Hue_color_spot_7_Last_Updated' changed from 2023-10-13T11:57:44.570339500+0200 to 2023-10-13T11:58:13.998670400+0200
11:58:13.999 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Hue_color_spot_7_Color' changed from 260.845,100,73.12 to 260.802,100,73.12
11:58:14.127 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Hue_color_spot_7_Color' received command 260,100,100
11:58:14.128 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'Hue_color_spot_7_Color' predicted to become 260,100,100
11:58:14.128 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Hue_color_spot_7_Color' changed from 260.802,100,73.12 to 260,100,100
11:58:15.010 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Hue_color_spot_7_Color' changed from 260,100,100 to 260.802,100,100
11:58:15.010 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Hue_color_spot_7_Brightness' changed from 73.12 to 100
11:58:15.010 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Hue_color_spot_7_Last_Updated' changed from 2023-10-13T11:58:13.998670400+0200 to 2023-10-13T11:58:15.009657700+0200
11:58:15.011 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Hue_color_spot_7_Color' changed from 260.802,100,100 to 260.845,100,100
11:58:15.011 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Hue_color_spot_7_Last_Updated' changed from 2023-10-13T11:58:15.009657700+0200 to 2023-10-13T11:58:15.010659100+0200
11:58:16.129 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Hue_color_spot_7_Color' received command 260,100,100
11:58:16.129 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'Hue_color_spot_7_Color' predicted to become 260,100,100
11:58:16.130 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Hue_color_spot_7_Color' changed from 260.845,100,100 to 260,100,100
11:58:17.450 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Hue_color_spot_7_Color' received command 260,68,100
11:58:17.451 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'Hue_color_spot_7_Color' predicted to become 260,68,100
11:58:17.451 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Hue_color_spot_7_Color' changed from 260,100,100 to 260,68,100
11:58:17.510 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Hue_color_spot_7_Color' changed from 260,68,100 to 260.009,68.02800,100
11:58:17.510 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Hue_color_spot_7_Last_Updated' changed from 2023-10-13T11:58:15.010659100+0200 to 2023-10-13T11:58:17.509619200+0200
11:58:17.651 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Hue_color_spot_7_Color' received command 260,35,100
11:58:17.652 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'Hue_color_spot_7_Color' predicted to become 260,35,100
11:58:17.652 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Hue_color_spot_7_Color' changed from 260.009,68.02800,100 to 260,35,100
11:58:17.858 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Hue_color_spot_7_Color' received command 260,2,100
11:58:17.858 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'Hue_color_spot_7_Color' predicted to become 260,2,100
11:58:17.858 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Hue_color_spot_7_Color' changed from 260,35,100 to 260,2,100
11:58:18.059 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Hue_color_spot_7_Color' received command 260,0,100
11:58:18.059 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'Hue_color_spot_7_Color' predicted to become 260,0,100
11:58:18.059 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Hue_color_spot_7_Color' changed from 260,2,100 to 260,0,100
11:58:18.522 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Hue_color_spot_7_Color' changed from 260,0,100 to 221.539,0.01300,100
11:58:18.523 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Hue_color_spot_7_Last_Updated' changed from 2023-10-13T11:58:17.509619200+0200 to 2023-10-13T11:58:18.522355400+0200

THING Config:

UID: hue:device:513878a587:fb032c0c-4187-4f93-9bab-3ae1c3dc5567
label: Hue color spot 7
thingTypeUID: hue:device
configuration:
  resourceId: fb032c0c-4187-4f93-9bab-3ae1c3dc5567
bridgeUID: hue:bridge-api2:513878a587
channels:
  - id: color
    channelTypeUID: system:color
    label: Color
    description: Controls the color of the light
    configuration: {}
  - id: color-temperature
    channelTypeUID: system:color-temperature
    label: Color Temperature
    description: Controls the color temperature of the light from 0 (cold) to 100 (warm)
    configuration: {}
  - id: alert
    channelTypeUID: hue:alert-v2
    label: Alert
    description: Activate the alert for the light.
    configuration: {}
  - id: last-updated
    channelTypeUID: hue:last-updated-v2
    label: Last Updated
    description: The date and time when the thing was last updated.
    configuration: {}
  - id: dynamics
    channelTypeUID: hue:dynamics
    label: Dynamics
    description: The duration (ms) of dynamic transitions between light or scene states.
    configuration: {}
  - id: color-temperature-abs
    channelTypeUID: system:color-temperature-abs
    label: Color Temperature
    description: Controls the color temperature of the light in Kelvin
    configuration: {}
  - id: color-xy-only
    channelTypeUID: hue:advanced-color
    label: Color XY Only
    description: Set the color xy parameter of the light without changing other
      state parameters.
    configuration: {}
  - id: dimming-only
    channelTypeUID: hue:advanced-brightness
    label: Dimming Only
    description: Set the dimming parameter of the light without changing other state
      parameters.
    configuration: {}
  - id: on-off-only
    channelTypeUID: hue:advanced-power
    label: On/Off Only
    description: Set the on/off parameter of the light without changing other state
      parameters.
    configuration: {}

My lights seem to revert to the last state prior to being turned off. So the chnages made while powered off are “lost”.

Color Temp ON OFF ON

IMHO it is a UI issue. The UI should send one single HSBType value to the binding that contains all three H, S, B elements in one go. But from your video it looks like it is (trying to) send first the H, then the S, and then the B as separate HSBType values. And if any of the intermediate values are out of range (H 0…359 / S 0…100 / B 0…100) then the overall chain of changes will (must) fail.

That is not unexpected.

Could that be as a result of the way I have been adjusting?
My concern currently is that changing the “H” value breaks the communications between UI and OH.
Next would be the size of the sliders that are shown.

EDIT: Also, the scroll bars only show once an item is linked to a valid color channel?

From what I could understand that is what @djpsycho82 is trying to do.
Preset the required color_temp and then turn on the lamp when he is ready - rather than turn on lamp and then adjust the color temp.

I tried this, with several methods (color-xy-only / color-temperature) but it only changes with brightness above 0, when the error occurs the settings isn’t picked up by the light.

@Mark_VG describes that the changes are lost after [OnOff_Only changes] does not happen in my setup. The light temperature stays the same regardless it’s on / off or any brightness value. I’m monitoring this with the items in openhab (text based/log) but also the hue app, the hue app follows exactly the light changes made with openhab.

The behaviour on my own system is as follows…

  • color-temperature commands are ignored if the lamp is off
  • color-temperature commands are executed if the lamp is on
  • color-temperature values are persisted if the lamp is toggled on=>off=>on

Notes:

  1. The color-xy-only channel behaves as above too.
  2. i.e. color-temperature behaves as color-temperature-**ONLY**.
  3. By contrast HSB commands to color channel do not behave as above.

So it’s behaving different than in API 1 unfortunately :frowning:

For my own setup I have to think what to do, or going back to API 1 (much slower and no scene control, which i don’t use at the moment.) Or accept that my lights are going on/off when there are situation changes in my house.

Do you knwo if API v1 is deprecated? Or is API v2 just an extra control layer for Hue?

This is definitely an OH Main UI issue. It works fine if you send the command via a color picker control or via a sitemap color picker or via a rule. Your Main UI video is new to me (as I hardly ever use Main UI for such things) but I can confirm that I now do see the same on my own system. From my past recollection, the color controls used to look different – more like three sliders. Therefore I think this is a new bug introduced in a recent OH version. => So instead of continuing to discuss it here, I would advise to open a new thread under the Main UI topic so that OH Main UI maintainers will respond.

EDIT: I see the same bug both on Chrome and Edge browsers…

1 Like

Thanks, have opened a new thread as suggested.

I understand your issue, and am thinking if there is any way to resolve it via changes in the binding, however so far I have no ideas.

I can only suggest two possible work arounds (neither of which is perfect)…

  1. Implement a dummy item not linked to any channel to store your “preset” color temperature, and implement a rule that triggers when a lamp turns on and sends the preset color temperature to that lamp.
  2. In your rule that changes the color temperature, if the lamp is off, send a brightness n% value to the color channel, so it will be on (and can therefore accept the color temperature value), but nevertheless be very dim. Select n% from the lamp’s dimmingRange property (see screenshot below).

EDIT: You could even try a variant of 2. as follows: In your rule issue the following commands rapidly in sequence: a) if the lamp is off, send Percent n% to color channel, send color-temperature value, send OFF to color channel, or b) if the lamp is on, just send color-temperature value. :slight_smile:

Yes it is. Philips / Signify has announced that it will be phased out – albeit they have not announced a fixed date. Their newly introduced Matter support is built entirely on API v2 and therefore all future development is focussed on that API.

1 Like

Allright, good to know! Thanks for the info.

So I will stick with API 2 and think of a way to change the color of the lights. Most easy way for me is building it in the rule where I control my lights, I already use proxy items to save certain values like the color-temperature. Best way is after turning on the lights, send the color value to the lights. It takes a little while for the lights to change, but so it is. There are greater problems in the world :wink:

Below is the rule for all my rooms to load scenes I saved into an item into JSON string, afterwards it’s able to save it as a “state” to load that scene when the house is in a specific state according to some items. It’s growing bit by bit, but OH4 is fast enough to execute it luckily. I think it can manage some color changes but it takes a while for me to rebuild it.

rule "2 - load scene"
when
    Item LoadScene changed // string with input: "Woonkamer, Avond Verlichting evt.[,save/forceload/manualm, fade]"
then
    LoadScene.postUpdate("")
    SceneActive.postUpdate(ON)
    if (newState === NULL || newState == ""){
        LoadScene.postUpdate("")
        return;
    }

    if (intFlapDetect > 5){
        FlapDetect.postUpdate(ON)
        logInfo("mr_autoscenes", "Loadscene : FLAPPING Detect! LoadScene gestopt! --> " + LoadScene.state.toString())
        sendSmartHomeNotify.postUpdate("Loadscene : FLAPPING Detect! LoadScene gestopt!" + LoadScene.state.toString())
        return;
    } else {
        intFlapDetect = intFlapDetect + 1
    }

    val String strNewState = newState.toString
    var hueLightAction = getActions("hue","hue:device:wkbridge:Thing_Slaapkamerkastspot1")
    var Long FadeSpeed = 1000
    var Boolean blnSaveState = false
    var Boolean blnSkipLoad = true
    var Boolean blnFade = false


    if (strNewState.contains(",") == false || strNewState.split(",").length() < 2){
        logError("mr_autoscene", "LoadScene heeft verkeerde waardes, functie afgebroken. Verwacht: 'Ruimte','Scenenaam' maar ontvangen --> [" + strNewState + "]")
        sendSmartHomeNotify.postUpdate("LoadScene heeft verkeerde waardes, functie afgebroken. Verwacht: 'Ruimte','Scenenaam' maar ontvangen --> [" + strNewState + "]")
        LoadScene.postUpdate("")
        return;
    }

    if (strNewState.split(",").length() == 3){
        if (strNewState.split(",").get(2).trim == "forceload"){
            blnSkipLoad = false
            blnSaveState = false            
        }

        if (strNewState.split(",").get(2).trim == "manual" || strNewState.split(",").get(2).trim == "save"){
            blnSkipLoad = false
            blnSaveState = true
        }
    }

    if (strNewState.split(",").length() == 4){
        if (strNewState.split(",").get(2).trim == "fade"){
            blnFade = true
            FadeSpeed = new DecimalType(strNewState.split(",").get(3).trim).longValue * 1000
        }
    }
        
    val String strRoom = strNewState.split(",").get(0).trim
    val String strSceneName = strNewState.split(",").get(1).trim
    val String strAction = ""
    val String jsonString = ScriptServiceUtil.getItemRegistry.getItem(strRoom + "_scenes").state.toString
    var Boolean blnSceneFound = false

    if (strSceneName == ScriptServiceUtil.getItemRegistry.getItem(strRoom + "_scene").state.toString().toLowerCase() && blnSkipLoad == true){
        logInfo("mr_autoscene", "Inladen van scene: " + strSceneName + " afgebroken, huidige scene is gelijk.")
    } else {
        if (jsonString == "NULL" || jsonString == "" || jsonString.contains('{"Scenes":[{') == false){
            logError("mr_autoscene", "LoadScene afgebroken! Item: [" + strRoom + "_scenes] is NULL, Leeg of lijkt geen geldige JSON.")
            sendSmartHomeNotify.postUpdate("LoadScene afgebroken! Item: [" + strRoom + "_scenes] is NULL, Leeg of lijkt geen geldige JSON.")
            LoadScene.postUpdate("")
            return;
        }

        if (jsonString.split("Scenes").length() > 2){
            logError("mr_autoscene", "LoadScene afgebroken door fatale fout! Scenes van item: [" + strRoom + "_scenes] zijn corrupt!")
            sendSmartHomeNotify.postUpdate("LoadScene afgebroken door fatale fout! Scenes van item: [" + strRoom + "_scenes] zijn corrupt!")
            LoadScene.postUpdate("")
            return;
        }

        val int intSceneCount = Integer.parseInt(transform("JSONPATH", "$[*].length()", jsonString)) - 1

        for (var i=0; i<=intSceneCount; i++){
            if (transform("JSONPATH", "$.Scenes[" + i + "].Naam", jsonString).toString.toUpperCase() == strSceneName.toUpperCase()){
                var String strJson = transform("JSONPATH", "$.Scenes[" + i + "]",jsonString)
                var pairs = strJson.replace("{", "").replace("}", "").split(", ")
                var pairLength = pairs.length()

                for (var x=1 ; x < pairLength; x++){
                    var String lamp = pairs.get(x).split("=").get(0)
                    var String value = pairs.get(x).split("=").get(1)

                    if (blnFade == true){
                        try{
                            logInfo("Autoscene", "---------- Fading begint --------------")
                            hueLightAction = getActions("hue","hue:device:wkbridge:Thing_" + lamp)

                            if (value.contains(",")){
                                hueLightAction.dynamicCommand("color", new HSBType(value), FadeSpeed)
                            } else {
                                hueLightAction.dynamicCommand("brightness", new PercentType(new DecimalType(value).intValue), FadeSpeed)
                            }

                            
                        } catch (Exception e) {
                            sendCommand(lamp, value)
                        }
                    } else {
                        sendCommand(lamp, value)
                    }
                }

                blnSceneFound = true
            }
        }

        if (blnSceneFound == false){
            logWarn("mr_autoscene", "LoadScene heeft geen scene gevonden. Gegevens ontvangen --> [" + strNewState + "]")
            sendSmartHomeNotify.postUpdate("LoadScene heeft geen scene gevonden. Gegevens ontvangen --> [" + strNewState + "]")
        }

        postUpdate(strRoom + "_current_scene",strSceneName)
        postUpdate(strRoom + "_scene",strSceneName)
    }
    
    if (blnSaveState == true){
        logInfo("AutoScenes", "SaveState wordt gestart")
        sendCommand(SaveState, strRoom)
    }
end

uh, took some time but it could have been this easy:

sudo apt reinstall openhab openhab-addons

this did the job, api v2 bridge is online!

thanks @AndrewFG and @Mark_VG for being patient with me! :blush:

1 Like

You could even try issuing a ‘dynamics’ command immediately before the ‘color-temperature’ command; that way, the lamp would come on immediately with whatever c-t it had previously had, and then gently fade to the new preset c-t value; which would probably be less jarring to people in the room.

1 Like