Thank you, @sihui
The general online state of myopenhab.org was not what I meant.
I monitor this with {channel="network:servicedevice:myopenhab:online"}
What I was after is the state displayed in my myopenhab.org events:
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 http://api.openweathermap.org/data/2.5/weather?lat=...
That’s working fine.
I am not using the myopenhab.org 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 = 'https://myopenhab.org';
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->env_proxy();
$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 );
$formfiller->fill_form($agent->current_form);
$agent->submit();
$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?
EDIT:
After installing the MECHANIZE libs the script starts running, but ends with an error:
[09:45:59] openhabian@homer:/etc/openhab2/scripts$ perl -w MyOHCld_State.pl
Error GETing https://myopenhab.org/: Internal Server Error at MyOHCld_State.pl line 23.
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).
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.