Detect HUE lamp power on

when i turn on my hue lamp e.g. with the app, i get a corresponding event in openHAB. If I disconnect the lamp with the switch from the power and switch on again, both are not recognized. Is this due to Hue itself or have I configured something wrong?
Greeting, Hendrik

Can you clarify what this sentence means?

I disconnected the lamp from the power grid using a normal wall switch. This should raise two events for e.g.

Item '...' changed from ON to OFF
Item '...' changed from OFF to ON

but i can’t see anything about this in the openHAB log.

A Hue lamp must remain powered on. If not, it is not reachable (can’t communicate).

That is clear as far as it goes. However, I am interested in the event that the lamp is back online. After this event, I could e.g. adjust the brightness automatically.

I had a rule for a hue Thing going ONLINE and one for it going OFFLINE, as I had a HUE bulb in my bedroom connected to a physical switch and somewhere high in my bedroom a HUE gradient lightstrip, powered from a wall socket. I wanted to have the lightstrip follow the ON/OFF behavior from the bulb.

So I had the rule as follows for when the bulb got disconnected:

rule "Bedroom ledstrip reacts to OFFLINE status Bedroom bulb"
		Thing "hue:0210:powercabinet:Bedroom_bulb" changed to OFFLINE or Item Hue_bedroombulb_switch changed to OFF

Item Hue_bedroombulb_switch is connected to the switch channel of Thing hue:0210:powercabinet:Bedroom_bulb and Item Hue_bedroom_switch is the switch channel of the grouped bedroom lights. So when the bulb Thing goes offline it sends an OFF command to all bedroom lights.

Similarly there is the rule when the bulb comes back online again:

rule "Bedroom ledstrip reacts to ONLINE status Bedroom bulb"
		Thing "hue:0210:powercabinet:Bedroom_bulb" changed to ONLINE or Item Hue_bedroombulb_switch changed to ON

For you the second case can be used. So when you detect that the lamp Thing is back online, you set the brightness for an Item linked to the brightness channel. However, be aware that the ONLINE detection will not be immediate, so your rule will fire up to tens of seconds after the bulb actually received power again, but that can also be only a few seconds.

Best solution to keep it always powered on:
Hue wall switch module
I finally went that way. Also because the bedroom bulb was slightly at the max range of my hue system, causing the bulb sometimes to be undetected (and OFFLINE) for a little while and when it came back online causing the bedroom lights to go on. My wife thought I was playing with the lights while I was at work and she in bed :joy: I also added an additional hue bulb in between to extend the max range.

General comments;

Never rely on Thing status as an accurate guide to some associated device’s status. Think of it more as talking about the pathway to the device.

For an example, an imaginary “ping Thing” for a remote “server X”.
If the network is accessible to openHAB and working, this Thing is ONLINE. It’s been configured sensibly, and we are able to perform the “ping” action.
Is server X actually working? No idea, we can’t tell unless we ping it.

If we do switch server X off, maybe later the bindng will try to ping it (depending how we configured the Thing). Maybe the binding is smart enough to change the Thing status to OFFLINE if the ping is completely unsuccessful. But the binding does not have to do that.

In the Hue context here, Thing ONLINE is really telling us the config is good, the hub is ready, and is not really about the bulb.
I don’t know how the binding detects error - maybe if an attempt to send a command fails, or maybe if a periodic report from the bulb is missing.
Either way, there’s no instant response - the bulb itself can’t tell you there’s a problem, you’ve just killed it.

As @rossko57 covers well, this is the problem with bulbs and why many of us prefer automating with switches/dimmers. Thing states aren’t reliable indicators (as @Chiuaua79 found).

Of course, switches/dimmers require more work to install, and can be extremely dangerous if you don’t know your way around an electrical box.

If you can’t or won’t install switches/dimmers, then the best solution is to pair the bulb with a remote control that you use instead of the on-wall switch. Philips makes some, but I don’t have any experience with them.

I think bulbs are best used only when you can’t install switches/dimmers or you want the light to change colour.

I have a bulb (actually a ceiling light) that can change colour, and it’s also controlled by an in-wall switch. This enables me to reliably automate the ON/OFF state using the switch. Whenever the switch turns on, openHAB can wait for the bulb to connect to WiFi and then send a command to it to change colours/brightness.