Restore bulb temperature after turned on

Hello,

I have a rule which runs every minute, computes color temperature based on time of day and sets it into Slider item, which on update sets color of all bulbs in certain group.

This works great for bulbs that are always powered on (only turned on or off from openhab), but I’d like to install bulbs in places like hall or toilet where they will be operated by regular wall switch (and thus powered off most of time).

The problem is that if I turn the bulb off (via wall switch so it’s not powered), change it’s temperature color and then power it on, the color update will be lost and the bulb will have whatever color was set when it turned off.

I’d like to set up rule that when this bulb turns on, it will update it’s color from computed value in Slider but can’t seem to find any way how to do this. When the bulb is turned on, I can see in events.log:

2019-03-20 22:14:21.206 [me.event.ThingUpdatedEvent] - Thing ‘zigbee:device:8ca79041:d0cf5efffef8d40d’ has been updated.
2019-03-20 22:14:22.046 [me.event.ThingUpdatedEvent] - Thing ‘zigbee:coordinator_cc2531:8ca79041’ has been updated.
2019-03-20 22:14:22.491 [me.event.ThingUpdatedEvent] - Thing ‘zigbee:device:8ca79041:d0cf5efffefa7c4d’ has been updated.
2019-03-20 22:14:22.701 [me.event.ThingUpdatedEvent] - Thing ‘zigbee:device:8ca79041:d0cf5efffefa85b3’ has been updated.

The bulb in question is the one “:…d0cf5efffef8d40d”. I tried to set up rule:

rule "Color sync"
when
     Thing "zigbee:device:8ca79041:d0cf5efffef8d40d" changed or 
     Thing "zigbee:device:8ca79041:d0cf5efffef8d40d" received update
then
    logInfo("test", "Bulb turned on")
end

But it never gets triggered. Is there any way how to do this? I don’t want to wait 1 minute until color update rule triggers, I’d like it to be as soon as the bulb is powered back on.

I’m using IKEA Tradfri bulbs connected with cc2531 zigbee stick, zigbee binding and OH 2.4.

Thanks for any suggestions.

Is there an Item connected with your bulb?

Yes, I have Item for color and level but these don’t receive any updates when bulb is turned back on.
Only if I set level dimmer manually to 0 and then turn the bulb off, then the level item will receive update when the bulb is turned back on, but after that no more updates are sent when I turn the bulb off and on again.

Okay, that is disappointing but seems to be a limitation of the gateway

Thing changed trigger is of no use to you - if the Thing says online when it isn’t, it will still be online when the bulb comes back and reports. No change occurs.

There isn’t any Thing-update-to-same-value trigger function, so far as I know.

EDIT - current docs suggest

Thing <thingUID> received update

is a valid trigger. I don’t know what OH version that arrived in.

You’re sure you don’t get an Item update at switch on, even if its to the same level?

I’m assuming there are no periodic status updates, which would allow you to use expire binding.

I think you are goosed here; if the gateway doesn’t make periodic reports nor does it report offlines, you’ve got no way to tell if a bulb is really offline or is just doing what it was last told to do.

You can usually tell by changing the version using the drop down in the upper right corner of the doc page. If it was introduced after the most recent release, the entry in the docs will disappear when you switch to 2.4.If it was introduced after 2.3, it will disappear when you switch to 2.3.

It’s still annoying that the default view of the docs is the most recent (i.e. the docs that go with the snapshots) instead of the most recent release.

I would strongly suggest to use a newer binding - 2.4 is pretty old and there are features to do what you want in 2.5.

When the bulb is powered back on, it sends a special message which is detected by the binding. The binding will poll the device to get its current state, and the item will be updated so you can detect it there.

Thanks for replies guys, I’ve tried adding “item changed” and “item received update” triggers to that rule but still nothig, turning the bulb off and on doesn’t trigger anything (but it produces those log messages so it must do something…).

Is 2.5 version stable enough for use? Seems like there’s just M1 released so far and no documentation yet. I’ve installed OH as .deb package from repo, can I just upgrade it with 2.5 M1 version while keeping all my configs?

You need to update your mirror list to add the milestone/beta/snapshots, and then you can install it from the repo.

Ok so I’ve updated to 2.5 M1, but besides from some errors in log (like in here) it’s still not working. Tried Thing changed/received update and Item changed/received update but still not getting any events. Do you have any more info on how it should work?

Any updates on this? I’ve recently updated to 2.5 M2 but still can’t get it wokring…