Myopenhab connection state


I recently had issues of Alexa not beeing able to connect to OH through
So I would like to monitor the connection state.
What’s the easiest way to “read” the state out of

I tried the URL above with http binding and Basic authentication, but still asks for authentication.

Is there an easy way to get ONLINE / OFFLINE state of to my OH instance at home?

Thank you, @sihui
The general online state of was not what I meant.
I monitor this with {channel="network:servicedevice:myopenhab:online"}

What I was after is the state displayed in my events:

So the actual connection state between and my raspberry pi with OH.

Okay :slight_smile:
Did you also try the base64-encoding?

No I didn’t - thanks.
But instead I tried it with curl:
curl -u "username:password"

In this case it should work anyway right?
But I get:
Found. Redirecting to /login

I am only using cURL to send commands to my electric car, no idea how this may work for reading stuff.

Thanks fior your help.
I usually use curl quite a bit.
for instance the query the temperature at the location of my car to trigger the heater if needed:
curl -s
That’s working fine.

1 Like

Almost the same here :slight_smile: (Renault ZOE)

1 Like

By the way, when trigegring a switch I use nowadays the http binding instead of curl:
{http=">[ON:GET:}] >[OFF:GET:http:...

Yeah, I was thinking about that, too. But I will wait for the http2 binding to not have double the work :slight_smile:

right - almost forgot.
I am desperately waiting for it either :slight_smile:

I am not using the cloud but the local cloud so it cold be that the following script needs to be adapted to work with the public cloud. At least I used /events?source=openhab to test it with the local cloud.

!/usr/bin/perl -w
use strict;
use WWW::Mechanize;
use WWW::Mechanize::FormFiller;
use URI::URL;

my $BASEURL     = '';
my $USER        = 'YourUserAccountHere';
my $PASSWORD    = 'YourPasswordHere';

my $LOGINURL    = $BASEURL . '/login';
my $ONLINEURL   = $BASEURL . '/events?source=openhab';

my $agent = WWW::Mechanize->new( autocheck => 1 );
my $formfiller = WWW::Mechanize::FormFiller->new();

$agent->get( $LOGINURL );
$agent->form_number(1) if $agent->forms and scalar @{$agent->forms};
$formfiller->add_filler( 'username' => Fixed => $USER );
$formfiller->add_filler( 'password' => Fixed => $PASSWORD );

$agent->get( $ONLINEURL );

my $status = $agent->content();
my @status = split ("\n", $status);
@status    = grep( /events\?source=openhab/, @status );
$status[0] =~ s#</a>.*##;
$status[0] =~ s#.*>##;

print( $status[0], "\n" );

Thanks, @Wolfgang_S
I will give it a try.
Just out of curiosity - what is the “local” cloud you are referring too?

After installing the MECHANIZE libs the script starts running, but ends with an error:

[09:45:59] openhabian@homer:/etc/openhab2/scripts$ perl -w
Error GETing Internal Server Error at line 23.

I assume @Wolfgang_S is running his own instance of the openhab Cloud

You can connect to your own cloud instance so you are not running on “” instance

Ah, thanks.
For me personally I just need connectivity from outside (and Alexa).
So a local cloud would not make sense to my case, because you would need to open ports then (unless I missed something).

IMO I think that is a perfectly acceptable choice. I have limited items that I control through the myopenhab cloud.

the online cloud, I assume?

Yes that one :slight_smile:

Me too - just the ones to Alexa.
And I have created a switch to disconnect Alexa, when I am not at home to prevent her messing up my appartment :wink:

looks like there is a difference between public and local/private cloud.
Submitting the form then returns an error.

Could you enter the following line:

print( $agent->content() );

before the row that contains $agent->submit();
This then should print out the content of the login page.
You may sent a message with that content to my address.
Please make sure that your password is not in that file ( just in case that is printed out, too ).

You also could follow the instructions in this Linux Magazin article ( in german )

That’s the way how I constructed the basics of that script.

In case you prefer to read an english article here is one

In case you need further assistance please let me know.