Cleaning up after power outages

A have problems after power down:

  • My Tradfri shines at full power, because when power comes on the are at full power.

  • The connection to HomeMatic gets broken, because openhab is earlier up and runing as HomeMatic does

  • In order to fix this I have to fix Tradfri I have switch them off (setting to “0”

  • To fix the HomeMatic I have to restart openhab

Can someone h^give me a hint how I could do that with rules. The System started event unfortunately comes too early, at that time Tradfri binding is yet not running.

For the HomeMatic I would like to know how to initiate at least reloading of the binding.

Other issue I have is that the “System started” event seems to be fired also when refreshing the item file.

Is there any other reliable option to detect power/system outage and trigger the execution just at the right time.

The homematic issue can be solved by editing the openhab2.service file to make it depend on homematic before starting up. You will have to do some googling to find out how to do this, I don’t know it off the top of my head. But I think it is as simple as appending homematic.service in the After line under [Unit].

For the Tradfri problem, you can use persistence on all of your Tradfri bulbs and put them all in a Group:Dimmer Tradris a System started rule that resets them all back to what they were before OH went down.

rule "Reset Tradfri"
when
    System started
then
    Tradris.members.forEach[light | light.sendCommand(light.previousState)]
end

You can’t change that, it is operating as designed. But with the rule above that doesn’t matter because it will only set the lights to whatever dimming value they are already at.

HomeMatic is running on a different machine/appliance. I have to find if could look for the Bridge Thing being of state “Initializing”. btw how can I restart a binding out of a rule.

The stuff with TradFri is a great Idea to reset out the persistet values, but this does not work because the rule fires before binding is up.

I had this code (adressing group) which didnt work either:

rule "System starup initialization"
when
    System started 
then
    sendMail("me@gmx.ch", "Startup Detected-Possible Power Outage", "Startup Detected-Possible Power Outage")
    sendCommand(gTFWZLightTop, "0")
    sendCommand(gTFWZLightSpot, "0")
    sendCommand(gTFDRLightTop, "0")
    sendCommand(gTFDRLightSpot, "0")
end

You can issue an executeCommandLine to ssh into the console and issue the bundle restart command. To avoid embedding the password in the command you will have to add an ssh cert to the openhab user for the karaf console.

Are you certain that the rule is executing before the binding comes up? It might be the case that the commands are being sent to the hub too rapidly.

I watched the log output and it seems that Tradfri need some 3 minutes till it goes complete to “online” (each and every bulb one by one).

Its pity that these bulb do not store their last status.

I need help to find the thingUID of the Tradfri Gateway. This code might work then:

rule "Reset Tradfri on startup"
when
    Thing <thingUID> changed OFFLINE to ONLINE
then
    sendMail("me@gmx.ch", "Startup Detected-Possible Power Outage", "Startup Detected-Possible Power Outage")
    sendCommand(gTFWZLightTop,  "0")
    sendCommand(gTFWZLightSpot, "0")
    sendCommand(gTFDRLightTop, "0")
    sendCommand(gTFDRLightSpot, "0")
end```


2017-11-17 10:41:29.710 [hingStatusInfoChangedEvent] - ‘tradfri:gateway:gwb072bf27910b’ changed from OFFLINE (COMMUNICATION_ERROR) to ONLINE

The easiest way is to browse to the Thing in PaperUI under Configuration -> Things. Look at one of the channels. The Thing ID should be the Channel ID minus the stuff following the last :.

For example one of the channels for one of my Astro Things is astro:sun:home:rise#start so the Thing ID would be astro:sun:home.