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

http://status.openhab.org/check/359410

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> 
  {channel="logreader:reader:openhabcloud:lastCustomEvent"}

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"
when
	Channel "logreader:reader:openhabcloud:newCustomEvent" triggered
then
	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")
	}
end

!!! 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:

image
image

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.
3 Likes

Thanks!

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: