Display Myopenhab cloud connection status

Due to the last myopenhab-cloud problem:

I was wondering if there is any chance to get the cloud connection status displayed within a sitemap or to trigger a mail notification from within a rule?

The easiest way to display it on a sitemap would be use the Webview element to display http://status.openhab.org/check/359410.

Thanks for your answer but as we saw today, the output of


is not reliable… So I was thinking if there is the other way round - to check if the OH cloud-connector is online…

Ah, I misunderstood. You’re looking for your OH server to somehow indicate whether or not it’s able to connect to the openHAB cloud. I was reading you the other way around.

Yes right! Yesterday the web-status-page showed everything ok but the openhab-cloud-connector got disconnected… As I can see the status-messages in the logfile, I was wondering, if it’s possible to get the status into an item…

Did you find a solution or an idea to check the myopenhab.org and personal server status in it?

You should be able to query the status page openHAB Cloud - Events (myopenhab.org) from inside a rule using your myopenhab credentials, then parse the contents. Eventually even using the HTTP binding.

To get the online status you may check if this script works: Myopenhab connection state - #12 by Wolfgang_S

After a hint from Ritch, I am now using the logreader-binding to see when cloud gets disconnected. That fits my needs as I wanted to know when the cloud connection gets interrupted (no matter if it‘s a local or a remote problem)

can you share your config please ? (logging strings you check against)

Sure! I am just in the migration phase to OH3.1 but I guess it will work the same way like in OH2.5.

So first of all I created a logreader thing:

And as Custom Patterns I used this string (please note the pipe-sign between the 2 strings):

Disconnected from the openHAB Cloud service|Connected to the openHAB Cloud service

I also increased the Refresh Rate from 1000 to 10000 milliseconds as this should be enough and events less than 10 seconds shouldn’t create panic.

Basically you need only 2 items - one for the custom event string and the other one is just a virtual switch to display the connection status:

String   LogReaderLastCustomEvent   "Last custom event [%s]"   <error> 

Switch   OpenHAB_CLOUD_connected   "OH Cloud Connected [%s]"   <network>

And a simple rule which triggers after a custom event string appeared:

rule "LogReader OpenHAB-Cloud"
	Channel "logreader:reader:openhabcloud:newCustomEvent" triggered
	if (LogReaderLastCustomEvent.toString.contains("Disconnected from")) {
		postUpdate(OpenHAB_CLOUD_connected, OFF)
		LineMessage.sendCommand ("Openhab Cloud disconnected")
	if (LogReaderLastCustomEvent.toString.contains("Connected to")) {
		postUpdate(OpenHAB_CLOUD_connected, ON)
		LineMessage.sendCommand ("Openhab Cloud connected")

!!! Please take care to NOT log the LogReaderLastCustomEvent-String with logInfo - you would run into an endless loop (trust me, I know “somebody” who did this :smiley:) !!!

Finally a small item in the sitemap:

Text item=OpenHAB_CLOUD_connected valuecolor=[=="OFF"="red",=="ON"="green"]

Here is the result:


A side note:

  • I used LineMessage which delivers a notification to my mobile as it doesn’t make sense to try sending a push notification to the Openhab mobile app via the Openhab-Cloud when it’s offline. As I am in the lucky situation of having a triple wan redundancy, I should be able to send out the notification anytime (as long as Murphy doesn’t hit me :slight_smile:). Of course you can use any other messaging tool like WhatsApp, PushSafer, PushBullet, PushOver, etc. or using a local gsm modem to send a sms.


This got my attention: how do you send to WhatsApp from within OH ?

I think I shot myself in my leg :slight_smile: I am not using Whatsapp at all - instead I’m using the Line Messenger which is offering an official API and I’m able to even send pictures… I just wrote a wrapper-shell-script around and run this with executeCommandLine but I just found this:

Hi @Flip ,
thanks for the script. I am trying to implement this also to control OpenHAB cloud Connection. In my case, I am using Telegram and ask to Reboot computer is connection is lost.
But I have a question and an issue.
The issue is that the rule doesn’t work for me. The logreader are actually reading from log and “detecting” the line when I have an Connection / Disconnection, but the rule doesn’t fire. I have changed the conditions in rule to:

LogReaderLastCustomEvent.state.toString.contains("Disconnected from")

Adding the “state”, as the item is a object, not the string itself (haven’t tested yet, as the event hasn’t fired again).

But, the most worring issue: In a period of 5 minutes, I have 4 events in the log, in this sequence: Disconnected, Connected, Disconnected and finally Connected… but… the Cloud is really disconnected. So I think that reading the log is not a valid solution, as it really doesn’t reflect the real connection state.

Anybody has this issue too?

Thanks in advance.

Can you post the whole rule? On my side it‘s still working very well. About the 4 entries every 5 minutes - are you sure you are not logging LogReaderLastCustomEvent too?

I have arranged the Rule (was a mistake in my trigger name).
Now the rule is working, and detecting “last entry on log”, all is working correctly… but the problem (I have to test more) is that the log not reflect really the connection to the cloud, as last Connected to Cloud and really it doesn’t connected always.

My actually rule is:

rule "LogReader OpenHAB-Cloud"
	Channel "logreader:reader:openhablog:newCustomEvent" triggered
    val telegramAction = getActions("telegram","telegram:telegramBot:Telegram_Bot")

	if (LogReaderLastCustomEvent.state.toString.contains("Disconnected from")) {
        telegramAction.sendTelegram("Perdua de la connexió amb OH Cloud")
        telegramAction.sendTelegramQuery("Vols reiniciar OpenHAB?", "ReiniciarCloud", "Si", "No")
	if (LogReaderLastCustomEvent.state.toString.contains("Connected to")) {
        telegramAction.sendTelegram("Connectat amb OH Cloud")

I am now trying to restart the bundle using (I am on Windows), the client.bat script. It doesn’t work because I don’t know how to pass the password to the script. If I execute from console, it asks me the password.

Edited: Only have pass the parameter -p to the client.bat, so it solved!

There is some bug on Opencloud Connector from last OH version (3.4.1), because is all day reporting Disconnections / Connections to the cloud on Log, and sometimes it really doesn’t reflect the connection status really.

Yesterday, a little example, all day was doing this:

Today seems to be more stable at now.

As the logreader is not reporting to me a valid solution, as much times it is reporting online when really are offline, I have built a rule to check connection using the web as the Python script, but only using DSL rule. Is not difficult. At now is working, but maybe needs some little extra debug. It test connection every 5 minutes and also have a switch to fire the rule:

rule "Comprovat conexio Cloud"
	Item checkCloudStatus received command ON or
    Time cron "0 0/5 * ? * * *"
	logInfo("Comprovant Cloud...", "Consultant conexió a myopenhab")
    val telegramAction = getActions("telegram","telegram:telegramBot:Telegram_Bot")

    val headers = newHashMap("user-agent" -> "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:98.0) Gecko/20100101 Firefox/98.0")
	val output = sendHttpGetRequest("https://myopenhab.org/login", headers, 5000)
    //logInfo("Restposta Login...", output)
    var hash = transform("REGEX", ".*name=\"_csrf\" value=\"(.*?)\".*", output)
    if (hash === null) return;

    logInfo("Valor Hash...", hash)
    val outlogin = sendHttpPostRequest("https://myopenhab.org/login?username=XXXXXXXXXX&password=YYYYYYYYYY&_csrf=" + hash)
    //logInfo("Login Result...", outlogin)
    //<a href="/events?source=openhab" title="Since ">Online</a>
    var onlinestatus = transform("REGEX", ".*<a href=\"/events\\?source=openhab\" title=\"Since \">(.*?)</a>.*", outlogin)
    if (onlinestatus === null) return;

    logInfo("Onlinestatus...", onlinestatus)
    if (onlinestatus == "Online") {
        if(OpenHAB_CLOUD_connected.state != ON) {
            telegramAction.sendTelegram("Connectat amb OH Cloud")
    } else {
        if(OpenHAB_CLOUD_connected.state == ON) {
            telegramAction.sendTelegram("Perdua de la connexió amb OH Cloud")
            telegramAction.sendTelegramQuery("Vols reiniciar Cloud Bundle?", "ReiniciarCloud", "Si", "No")

I borrowed from @Flip’s posts (and a few others) to write this tutorial.

1 Like