Mobile Alerts and openHAB 2

Hallo Ansgar
kannst Du mir auflisten, wie Du vorgegangen bist?
Ich kriege keine Temperatur oder Luftfeuchtigkeitsanzeige hin.

Besten Dank
Gruss
goair

[quote=“adb76, post:1, topic:21444”]
Als erstes musst Du das “ HTTP Binding ” und die “ RegEx Transformation ” service via the Paper UI installieren.
Dann musst Du in der “http.cfg” im Ordner “services” folgendes entragen:

mobileAlerts.url=http://measurements.mobile-alerts.eu/Home/SensorsOverview?phoneid=xxx
mobileAlerts.updateInterval=300000

Anschließend musst Du die Items wie in der Beschreibung oben erstellen:
Number MobileAlerts_AirQuality “Air Quality[%d ppm]” { http="<[mobileAlerts:300000:REGEX(.?([0-9]+) ppm.)]" }

String MobileAlerts_Outside_TemperatureString “Outside Temperature [%s]” { http="<[mobileAlerts:300000:REGEX(.?Temperature Outdoor.?\s.?(-[0-9]+,[0-9]+) C.*)]" }
Number MobileAlerts_Outside_Temperature “Outside Temperature [%.1f °C]”

String MobileAlerts_Indoor_TemperatureString “Indoor Temperature [%s]” { http="<[mobileAlerts:300000:REGEX(.?Temperature Indoor.?\s.?(-[0-9]+,[0-9]+) C.*)]" }
Number MobileAlerts_Indoor_Temperature “Indoor Temperature [%.1f °C]”

Number MobileAlerts_Indoor_Humidity “Indoor Humidity [%d %%]” (Raumklima, Wohnzimmer) {http="<[mobileAlerts:300000:REGEX(.?Humidity Indoor.?\s.?([0-9]+)%.)]"}

Nach dem Post von m4rk Mark vom Jul 18 weiter oben musst Du die jeweiligen *.js Dateien anlegen.

Nach ein paar Minuten sollten die Werte angezeigt werden.

Hi Ansgar
many thanks. now they will work fine!

regards
goair

Hi together
how can I set the value wind direction with the output in text?
example: north, northeast and so on ? everything else works, temperature, wind speed, rainfall,
humidity …

my winddirection.js:
(function(i) {
var re = new RegExp('SENSORID[\s\S]?Windrichtung[\s\S]?

([0-9]+.[0-9]+) ');
var out = i.match(re)[1];
return parseFloat(out);
})(input)

my .items:
String windrichtung “Windrichtung [%s]” { http="<[sensorCache:60000:JS(winddirection.js)]" }

my .sitemaps:
Default item=windrichtung icon=“wind”

Thank you very much

Hey Marco,
did you get exact resulte as 12,4° C or just 12,0° C?
I just get rounded results.
Regards, Ansgar

Hey Ansgar
i will get the right resulte.

regards

can you post your *.js file for temperature?
I use thies on:

(function(i) {
var re = new RegExp('SensorID[\\s\\S]*?Temperatur[\\s\\S]*?<h4>([0-9]+.[0-9]+) C');
var out = i.match(re)[1];
return parseFloat(out);

})(input)

//Badezimmer

(function(i) { var re = new RegExp('SENSORID[\\s\\S]*?Temperatur[\\s\\S]*?<h4>([0-9]+.[0-9]+) C'); var out = i.match(re)[1]; return parseFloat(out.replace(',', '.')); })(input)

Thanks,
after input tp replace ‘,’ by ‘.’ ist works exact!.:grinning:

you`re welcome!
Can you help me for the Windrichtung? they will give the name out, e.g. Norden, Ostnordost,…
regards

sorry, no. I didn’t have an mobile alerts with wind direction.

ok, thanks.

Did you try to do as Wassersensor?
Look here: Mobile Alerts and openHAB 2

Hi Ansgar
thank you for the tip!
I had try alot, my result now is:

rule "current wind text"
when
	Item windrichtung received update
then
	if (windrichtung == NULL)
		windrichtung.postUpdate("keine Info")
    else if (windrichtung == Südost)
		windrichtung.postUpdate("Südost")
	else if (windrichtung == Südwest)
		windrichtung.postUpdate("Südwest")
    else if (windrichtung == Südsüdwest)
		windrichtung.postUpdate("Südsüdwest")
	else if (windrichtung == Nord)
		windrichtung.postUpdate("Nord")
	else if (windrichtung == Nordost)
		windrichtung.postUpdate("Nordost")    
    else if (windrichtung == Nordnordost)
		windrichtung.postUpdate("Nordnordost")
	else if (windrichtung == Ost)
		windrichtung.postUpdate("Ost")
	else if (windrichtung == West)
		windrichtung.postUpdate("West")
	else if (windrichtung == Nordwest)
		windrichtung.postUpdate("Nordwest")
	else if (windrichtung == Süd)
		windrichtung.postUpdate("Süd")
    else if (windrichtung == Ostnordost)
		windrichtung.postUpdate("Ostnordost")
    else if (windrichtung == Ostsüdost)
		windrichtung.postUpdate("Ostsüdost")
    else if (windrichtung == Südsüdost)
		windrichtung.postUpdate("Südsüdost")
    else if (windrichtung == Westsüdwest)
		windrichtung.postUpdate("Westsüdwest")
    else if (windrichtung == Westnordwest)
		windrichtung.postUpdate("Westnordwest")
    else if (windrichtung == Nordnordwest)
		windrichtung.postUpdate("Nordnorwest") 
end

but all words with Umlaut ü doesnt work, they will show a S.
my Log file:

[WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'windrichtung.rules' has errors, therefore ignoring it: [7,31]: no viable alternative at input 'ü'

[7,32]: extraneous input 'dost' expecting ')'

[9,28]: no viable alternative at input 'ü'

[9,29]: extraneous input 'dwest' expecting ')'

[11,31]: no viable alternative at input 'ü'

[11,32]: missing ')' at 'ds'

[11,40]: mismatched input ')' expecting 'end'

any tip?

regards

For wind I prefer to use the Mobile-Alerts API call. This returns a wind direction number which is useful for plotting the wind direction over time. I find thats more useful than knowing the last wind direction because that can jump around quite a lot.

You can use map transform to turn the API number into text for an item as shown in the rule below or do it directly in Grafana with value mapping as shown in the image below

I use Influx and Grafana to show the results like this:

The wind driection numbers are 0 -16 and can be plotted to see the wind direction over time. ( 0 and 16 = North, 8 = South etc etc)

Wind speed

Using API is better than html cache for some things eg rain gauge. The API returns with the raw data. The web page is rounded data. If using rain data then the rounding errors add up and cause apparent discrepancies in the Openhab vs Mobile-Alerts app values eg calculaing the total rainfall

To use API call you need the exec binding and Thing like this
Thing exec:command:mobilealertsAPI "MobileAlerts API" [command="/home/openhabian/Mobile-Alerts_REST_API.sh", interval=300, timeout=15]

This points to a sh script file to run like this:
curl -d deviceids=yyyyy,zzzz -d phoneid=xxxxxxxxx https://www.data199.com/api/pv1/device/lastmeasurement

The result updates this item:
String MobileAlertsAPI "Mobile-Alerts API query" <text> { channel="exec:command:mobilealertsAPI:output" } // run every 5mins. See Thing

When the API item is updated I use a rule to extract the sensor data
eg

when
    Item MobileAlertsAPI changed
then

eg

// Wind direction
    val String newwinddirectionnumber = transform("JS", "getWindDirection_API.js", MobileAlertsAPI.state.toString)

    if (newwindgust != NULL) { //Check transform worked eg after battery change
            // Transform wind direction number to a compass bearing
        val String newwinddirection = transform("MAP","wind_direction.map" , newwinddirectionnumber)
            // Update only if changed
        val String previouswinddirection = MobileAlertsWeatherStationWindDirection.state.toString
        if (newwinddirection != previouswinddirection) {
            MobileAlertsWeatherStationWindDirection.sendCommand(newwinddirection)
            MobileAlertsWeatherStationWindDirectionNumber.sendCommand(newwinddirectionnumber)
            Thread::sleep(1000)
            logInfo("Mobile Alerts" , 'New Wind direction value = '+ newwinddirectionnumber)
            logInfo("Mobile Alerts" , 'New Wind direction = '+ MobileAlertsWeatherStationWindDirection.state)
        }
        else {
        logInfo("Mobile Alerts" , 'No change in wind direction. Previous = '+ previouswinddirection)
        }
    }

wind_direction.map

NULL = NULL
0.0 = N
1.0 = NNE
2.0 = NE
3.0 = ENE
4.0 = E
5.0 = ESE
6.0 = SE
7.0 = SSE
8.0 = S
9.0 = SSW
10.0 = SW
11.0 = WSW
12.0 = W
13.0 = WNW
14.0 = NW
15.0 = NNW
16.0 = N

Hi @Blonder01

Could you please let me know whitch hardware do you use?
Is it “Wetter-Set MA10050” from ELV with wind sensor (MA10660), rain meter (MA10650), thermo/hygro sensor (MA10200) and gateway (MA10000)?

Hi Selter,
I use:

  • Starterkit MA10001 with Gateway MA10000 und Sensor MA10100
  • TEMPERATUR- UND LUFTFEUCHTESENSOR MIT ZUSÄTZLICHEM WASSERDETEKTOR (MA10350)
  • REGENSENSOR (MA10650)
  • KONTAKTSENSOR (MA10800)

Thanks for the quick reply.

I’m especially interested in the “Regensensor” - works it reliable with your setup?

Hi Selter

the Regensensor will work fine!
use:
rainsensor.js:
(function(i) { var re = new RegExp('SENSOR-ID[\\s\\S]*?Regen[\\s\\S]*?<h4>([0-9]+.[0-9]+) mm'); var out = i.match(re)[1]; return parseFloat(out.replace(',', '.')); })(input)

.items File
Number rainsensor "Regen letzte 24h [%.1f mm]" { http="<[sensorCache:60000:JS(rainsensor.js)]" }

sitemap:
Default item=rainsensor icon="rain"

regards

Dear Mark

many thanks for your help.
I have two questions:
what comes in this file,
getWindDirection_API.js
and why I have this error:
`Fatal transport error: java.net.NoRouteToHostException: No route to host (Host unreachable)

2019-04-12 09:15:40.810 [ERROR] [ab.binding.http.internal.HttpBinding] - No response received from 'http://10.5.10.109:80/web/getcurrent’`

kind regards
Marco