When Hue lights turn on from a Rule, sometimes they turn on with brightness 1%

Hi Guys,

I’m running OpenHAB 3 on Windows 10 (previously with OpenHab 2 it was doing the same thing), and whenever the below Rule runs, sometimes (not all the time) the lights in question turn on at 1% brightness, even though it was previously On at 100% brightness. Is it because of my sendCommand syntax? Is that not what I should use for this? Previously the rule below, I had sendCommand(gOfficeLights, ON) but the issue was happening then, so I tried sendCommand(gOfficeLightsBrightness, 100), but still same issue. Any help appreciated. Thanks.

rule "Turn gOfficeLights ON In NightMode and Huawei_P30_Pro Is Home"
when
	Item NightMode changed from OFF to ON
then
	if (Presence_Huawei_P30_Pro.state == ON)
	{
	sendCommand(gOfficeLightsBrightness, 100)
	}
end

So actually you’re commanding a Group? How many members in that?

There’s only one light in that group.

This could be a case where the difference between sendCommand("ItemName", "command") and ItemName.sendCommand(command) makes a difference. As discussed in the docs, it is preferable to use the latter everywhere it’s possible to do so because it’s much better able to handle conversion between different types of commands. Do you get the same result when changing that?

What is happening in events.log and openhab.log?

Ok, thanks. I’ll give that a try.

I checked the logs a while back when it was happening, but can’t remember. Will keep an eye on it next time this happens.

This is what happened (with no code change yet) in the events.log:

2021-08-10 21:10:58.294 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Xiaomi_Mi_Motion_Sensor_5_Status' changed from OFF to ON
2021-08-10 21:10:58.294 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Xiaomi_Mi_Motion_Sensor_5_LastActivity' changed from 2021-08-10T18:26:23.542800500+1200 to 2021-08-10T21:10:58.291749700+1200
2021-08-10 21:10:58.298 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Brightness_Room_3_Light' received command 100
2021-08-10 21:10:58.301 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Brightness_Room_3_Light' predicted to become 100
2021-08-10 21:10:58.302 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Brightness_Room_3_Light' changed from 0 to 100

2021-08-10 21:11:07.228 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Toggle_Room_3_Light' changed from OFF to ON
2021-08-10 21:11:07.228 [INFO ] [hab.event.GroupItemStateChangedEvent] - Item 'gRoom3Lights' changed from OFF to ON through Toggle_Room_3_Light
2021-08-10 21:11:07.229 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Alert_Room_3_Light' changed from NONE to SELECT

2021-08-10 21:11:09.229 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Alert_Room_3_Light' changed from SELECT to NONE

2021-08-10 21:11:17.302 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Brightness_Room_3_Light' changed from 100 to 1

2021-08-10 21:14:00.142 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Xiaomi_Mi_Motion_Sensor_5_Status' changed from ON to OFF
2021-08-10 21:14:00.144 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Brightness_Room_3_Light' received command 0
2021-08-10 21:14:00.146 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Brightness_Room_3_Light' predicted to become 0
2021-08-10 21:14:00.146 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Brightness_Room_3_Light' changed from 1 to 0

2021-08-10 21:14:08.168 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Toggle_Room_3_Light' changed from ON to OFF
2021-08-10 21:14:08.168 [INFO ] [hab.event.GroupItemStateChangedEvent] - Item 'gRoom3Lights' changed from ON to OFF through Toggle_Room_3_Light
2021-08-10 21:14:08.168 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Alert_Room_3_Light' changed from NONE to SELECT

2021-08-10 21:14:10.168 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Alert_Room_3_Light' changed from SELECT to NONE

As you can see at 21:11:17 it says Item " ‘Brightness_Room_3_Light’ changed from 100 to 1" 10ms after turning on brightness to 100%.

Also, since OpenHAB3, I’ve noticed in my SiteMap, that my Hue light switch has a percentage next to the actual switch. So whenever I turn the switch on, it goes to 1% brightness.

The only channel I can link the switch to for the Hue app is the Brightness channel. Maybe there’s an issue with that somehow? Screenshots below:

Okay, they still turned on with 1% brightness. I swear it has something to do with the Toggle Switch above (how it is linked to the Brightness channel as there is no separate On/Off Switch channel for the Hue bulbs), in that every time you switch it on it says 1% (as per sitemap image above).

Here is the event.log when the issue happened again with the updated sendCommand syntax.

2021-08-11 00:01:12.500 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Xiaomi_Mi_Motion_Sensor_4_Status' changed from OFF to ON
2021-08-11 00:01:12.501 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Xiaomi_Mi_Motion_Sensor_4_LastActivity' changed from 2021-08-10T23:50:46.190445700+1200 to 2021-08-11T00:01:12.498665+1200

2021-08-11 00:01:12.509 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Brightness_Bathroom_Light' received command 100
2021-08-11 00:01:12.511 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Brightness_Bathroom_Light' predicted to become 0

2021-08-11 00:01:19.516 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Toggle_Bathroom_Light' changed from OFF to ON
2021-08-11 00:01:19.517 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Brightness_Bathroom_Light' changed from 0 to 100
2021-08-11 00:01:19.517 [INFO ] [hab.event.GroupItemStateChangedEvent] - Item 'gBathroomLights' changed from OFF to ON through Toggle_Bathroom_Light

You understand that you don’t need a Switch Item at all? You can send ON/OFF commands to a Dimmer type Item. You can put a Switch widget on a sitemap with a Dimmer type Item.

Switch Item removed for the Hue bulbs but issue still happening. Seems like the PredictedEvent also says it is predicted to be 0 for some reason…

2021-08-11 00:53:11.262 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Xiaomi_Mi_Motion_Sensor_5_Status' changed from OFF to ON
2021-08-11 00:53:11.263 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Xiaomi_Mi_Motion_Sensor_5_LastActivity' changed from 2021-08-11T00:23:03.604868400+1200 to 2021-08-11T00:53:11.260984900+1200
2021-08-11 00:53:11.352 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Brightness_Room_3_Light' received command 100
2021-08-11 00:53:11.359 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Brightness_Room_3_Light' predicted to become 0

2021-08-11 00:53:15.599 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Brightness_Room_3_Light' changed from 0 to 100
2021-08-11 00:53:15.599 [INFO ] [hab.event.GroupItemStateChangedEvent] - Item 'gRoom3Lights' changed from OFF to ON through Brightness_Room_3_Light
2021-08-11 00:53:15.600 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Alert_Room_3_Light' changed from NONE to SELECT

2021-08-11 00:53:25.651 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Brightness_Room_3_Light' changed from 100 to 1

Turned the Group Switch on for the light, and still it changes from 100 to 1 brightness…

2021-08-11 00:58:44.873 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'gRoom3Lights' received command ON
2021-08-11 00:58:44.874 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Brightness_Room_3_Light' received command ON
2021-08-11 00:58:44.875 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Brightness_Room_3_Light' predicted to become ON
2021-08-11 00:58:44.880 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Brightness_Room_3_Light' changed from 0 to 100
2021-08-11 00:58:44.880 [INFO ] [hab.event.GroupItemStateChangedEvent] - Item 'gRoom3Lights' changed from OFF to ON through Brightness_Room_3_Light
2021-08-11 00:58:47.299 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Brightness_Room_3_Light' changed from 100 to 1

Generally means that the channel is broken in some way. Maybe you didn’t unlink the old Switch Item before deleting it, so there’s a dangling link still.

So, that’s good. Some seconds after command, Hue device reports it’s done as asked, 100%

Twenty seconds later, Hue makes a new report, 1%. Who did that? Feels like some external factor here.

The thing is, I never see the light go to 100%. As soon as I walk into room, the xiaomi sensor detects me and at the same time the light goes to 1%. All within 1 second. Not 20 seconds apart. The logging seems delayed for changing from 100 to 1.

The binding will be using messages as they arrive from whoever, to generate the state updates. (An incapacitated autoupdate is actually useful here, allows you to see ‘real’ updates.)
So you’d want to be looking at the outward configuration. We don’t know anything about your setup.

what does this mean

[8852:14988:2022-1-24 17:53:15.599] Main Start
[8852:14988:2022-1-24 17:53:15.599] Command line:“C:\Users\jkegley\Downloads\Zoom_cm_ds_mjAl2BR1beQLOMIr1IujfGCTkEJ7Z5N7D-tbB@kxSScOdrA8r2vfyR_k848a548700c45772_.exe” Instance:0xEB0000 Show State:1
[8852:14988:2022-1-24 17:53:15.671] C:
[8852:14988:2022-1-24 17:53:15.685] Main End
[6252:6844:2022-1-24 17:53:19.849] Main Start
[6252:6844:2022-1-24 17:53:19.849] Command line:“C:\Users\jkegley\Downloads\Zoom_cm_ds_mjAl2BR1beQLOMIr1IujfGCTkEJ7Z5N7D-tbB@kxSScOdrA8r2vfyR_k848a548700c45772_.exe” Instance:0xEB0000 Show State:1
[6252:6844:2022-1-24 17:53:19.937] C:
[6252:6844:2022-1-24 17:53:19.963] Main End