[SOLVED] Openhab2 not updating power status of sonoff on reboot

Tags: #<Tag:0x00007f616d93e358> #<Tag:0x00007f616d93e1a0> #<Tag:0x00007f616d93dd68>

Hi everyone. I am running openhab2 on raspberry-pi 3. I am struggling with openhab not updating the power status of sonoff basic on reboot. Is this normal? Please suggest. I have tried to get the switch status in logs, it says NULL.

That is pretty normal :grin:
Read a little bit about persistence and restoreOnStartup.
For your specific case I recommend using MapDB.

hey, many thanks for the quick reply. I found a simple cheat solution to this.

I created a rule that runs when “System started” and added this http command
sendHttpGetRequest(“http://192.168.0.xxx/cm?cmnd=power”)

here xxx is my sonoff ip.

And now openhab shows the sonoff power state correctly on reboot.

1 Like

Hi,
Could you share exactly your rule for this?

thank you

sorry, I am quite a newbie. Could someone explain exactly how to create a rule that updates the sonoff power status on reboot?

You need to puzzle both pieces (from the rules link and @akhilmagotra’s example) together:

rule "Speedtest init"
when
    System started
then
    createTimer(now.plusSeconds(30), [|
        if (Speedtest_Summary.state == NULL || Speedtest_Summary.state == "") Speedtest_Summary.postUpdate("unknown")
    ])
end
rule "update power"
when
    System started
then
    sendHttpGetRequest(“http://192.168.0.xxx/cm?cmnd=power”)
end

The sendHttpGetRequest syntax depends on the firmware you are using on your device.