OH3: HTTP-Binding RegExp / JS

I stopped mobile alerts for 3 hours but always get the error:


But ive I put it into browser I get the right answer:
image

At REST-API documentation they wrote:

API Rate Limits
Rate limiting is considered on a per sensor basis. Allowed are up to 3 calls for
a sensor within one minute. If more than 3 calls are made within one minute
further calls are blocked for 7 minutes.
If rate limiting is applied the server returns the HTTP response code “429 Too
Many Requests”.

My settings in OH 3 are these und didn’t change them and it works until wendsday:
image

Invalid call blocking
To prevent misuse, if more than 5 calls with invalid parameters are made from
the same ip address within 15 minutes, further calls from the same ip address
within the 15 minute time window will be blocked.
If invalid call blocking is applied the server returns the HTTP response code
“403 Forbidden”.

Problem solved!
I wrote an email to mobile alerts. I didn’t get an answer, but since friday 16-04-2021 12.00 everything works fine.

1 Like

In the past a friend of me made a small app for doing this. But suddenly it stopped working.
I tried to build the same solution with the HTTP-Binding and RegExp / JS on my Openhab3.
But, I always get now on the Request of the URL a 403 Forbidden.

My code looks like:

UID: http:url:MobileAlerts
label: MobileAlerts
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: http://measurements.mobile-alerts.eu/Home/SensorsOverview?phoneid=xxxxxxxx
  delay: 0
  stateMethod: GET
  refresh: 60
  commandMethod: GET
  timeout: 12000
  bufferSize: 2048
channels:
  - id: Windgeschwindigkeit
    channelTypeUID: http:number
    label: Windgeschw
    description: ""
    configuration:
      stateTransformation: JS:GetWind.js

Did it stop working before or after you moved to using OH3 and the OH3 binding?

What happens if you put your URL into a web browser?

It seems I found the route cause. The Request needs to have a user-agent information. I tried it with wget wget --user-agent=“Mozilla” https://measurements.mobile-alerts.eu/Home/SensorsOverview?phoneid=xxxxxxx and it works.
But I am too stupid to configure a headers information in the thing. Who can help me here?

You can’t change the user-agent

Oh. Thank’s for the information. Bad situation.
Does it work still on your setup? It looks like, there is now way to use it anyway.

I have the same behavior. It was working for a full year and suddenly stopped working since a week or so.
Can we perhaps change some settings in http.cfg to fix the issue?

For me it sounds like, there is now way to do this with the HTTP-Binding.
That’s why I tried it with EXEC and CURL.
https://community.openhab.org/t/re-oh3-http-binding-regexp-js/124348/2?u=roman_e

This is a clue it’s the other end that has changed, has become more picky about what user-agents it serves i.e. rejecting bots etc.

That’s interesting. I couldn’t open the link though; it seems to be broken.

I decided to use Exec and Curl too. Used -A option to indicate agent. Took me about 10 minutes to relink items. All seems to be working fine again. Thanks!

2 Likes

Hey,
I moved to a new appartement, stopped OH3 at my old appartement installed everything in my new appartement without changing anything an restated OH 3.

Everything works without Mobile Alerts.

The error at the log likes like this:

If I try directly inside browser with:
https://measurements.mobile-alerts.eu/Home/SensorsOverview?phoneid=XXXXXX

it works without any problems.

I`ve restarted OH 3 2 times.

Does anyone knows what to do?
Thanks, Ansgar

Hey,
can you show, how you get it work?
Link of Roman_E doesn`t work.
Thanks.

Sure, create a shell script like

getMobileAlertsHTML.sh:

#!/bin/bash
curl https://measurements.mobile-alerts.eu/Home/SensorsOverview?phoneid=XXXXXXXXX -A Mozilla

Then create a ‘Thing’ in OpenhabUI for ‘Exec’ binding as follows:

and that’s pretty much it. Your webpage data will now start coming in the output of this ‘Thing’. You can create channels, just like you would otherwise have done for using regular expressions to get the data.

1 Like

Hard to explain. Is there anything else in the logs? Can you enable TRACE logging, so we see what is actually send and received?

Thanks,
thing created and running:


But I can’t find where to create own channels:

At the old way it was no problem:

Apologies for the delay as I was busy.
It is similar. Here is my screenshot of how I added the channels.

Hey and thanks.
I have two problems:
At the log I found:


How can I fix it and where do I have to add it in which form to the whitelist?

To define the channels is now problem. But what is the right way?
Is it OK in this way:

The whitelist is located at /etc/openhab/misc/exec.whitelist . For examples see: Exec - Bindings | openHAB