Mobile Alerts and openHAB 2

Hi Stefan,

I also have:

MA10100 Temperature sensor
MA10001 Temperature probe
MA10421 Temperature/Humidity station

I have them all in Openhab and charted with Grafana using either web page caching or API call and then using Regex to extract the relevant data. With the API you also get the low battery information and loss of connection.

I wish they did a barometer but they dont so now I am building one from RPi and sensor :slight_smile:

editā€¦ Update I did build my barometer and it works great. Stepper motors drive the dials for pressure and rate of change. No need to tap this barometer to see which way its going :slight_smile: It sends data via MQTT to Openhab and then on to Influx and Grafana. In the meantime Mobile Alerts updated the app to accomodate a barometer. I have not yet seen it for sale.

Hey Mark,

sounds nice.

I havenā€™t checked the battery messages by now.
My last state of information was that the rest API only works on pro devices and not for the non pros?

Would you mind of sharing your sensor ids with me for testing purposes?

Hi folks,

i've read and reread all post, but i don't get into it...
I have multiple MA-Sensors. I got one Sensor working - the first in the list by using


`sensorCache.url=http://measurements.mobile-alerts.eu/Home/SensorsOverview?phoneid=xxx
sensorCache.updateInterval=60000`

But i donā€™t get the way to implement all the other sensors from the listā€¦
Can anyone provide me a step by step tutorial for getting all Temp/Hum sensors to work?
(actually i donā€™t now where to put all the above listet codeingsā€¦)

THX

Hi, Sorry forgot about your question re sharing. What are the risks if any?

Also, I recently notified mobile alerts of an issue over the Christmas period. Non pro devices were not showing latest data in the App from 2 to 8am. Also, the sensor overview web page was unavailbale during this time. Later in the day the App caught up with the data. So, the data wasnā€™t lost but delayed. Annoying that the app and website both showed the last bit of the data in the history as the current data with the current timeā€¦ even though it wasnā€™t.

Mobile alerts aknowledged there was an issue and have now said they have fixed itā€¦

Maybe only I noticed it but in your charts you might see an unusually stable period in the early hours or even time slipped data.

ps Got my barometer built: Bosch sensor + MQTT for openhab input + stepper motor dials for fun display. RPi to the rescue again :slight_smile:

I wish I had the time butā€¦

In a nutshellā€¦cache the sensor page (and or use API call if you have pro devices) and the use transform file and regex to extract the data. I identify each sensor with its id. That way when I want to add a new sensor I just copy paste the regex and only need change the sensor id part for new sensorsā€¦

Hi, first of all I want to thank everybody for the good information in this thread.
I tried the examples but have encountered a problem.
I create an item that should display the status of 2 garage door contacts, the channels are defined like this

Group gGaragenDiiren
	"GaragenDiiren"
	(C_Garage)
String	garagenDiirAnnette
	"GaragenDiir Annette [%s]"
	(gGaragenDiiren)
	{ http="<[mobileAlerts:60000:JS(getGaragendiirAnnette.js)]" }
String garagenDiirMarc
	"GaragenDiir Marc [%s]"
	(gGaragenDiiren)
	{ http="<[mobileAlerts:60000:JS(getGaragendiirMarc.js)]" }

the problem is that i only get one item displayed, and where the second should be, I see de complete HTML code of the page.

The transformation is done like this

(function(i) {
	    var re = new RegExp('xxxxxxxxxx[\\s\\S]*?Contact Sensor[\\s\\S]*?<h4>([a-zA-Z]+)');
	    var out = i.match(re)[1];
	    return out;
})(input)

they are both identical, only the ID in the regex does change

Any ideas concerning this problem ? I also would like to find where the syntax of the channel line is documented, as I do not understand why it starts with a < tag

For testing that the regex works as expected I extracted the source code from sensor web page and then used one of the free regex test sites to test my expression. You may need to remove on the \ from double \ in your expression to work with the rest site.

Hi,

For those that are interested

I now have all Mobile Alert sensors as items in Opemhab and charted via Influx and Grafana. What was missing was some indication when a sensor had stopped working.

I could have used API call for the ā€˜Proā€™ devices but wanted something that would work for ALL my devices. So, I used web caching (need HTTP binding for this) to extract each sensor time stamp and a rule to check the time since a sensor was last seen. It took quite a bit of work determining the best method to do the task and then more wok in getting the types correct.

Details are below:

Time stamp Itemā€¦
String HeatPumpReturnTemperatureTimestamp "Heat Pump return sensor time stamp [%s]" { http="<[sensorCache:60000:JS(getTimestamp.js)]" }

JS transform with REGEX to extract the time stampā€¦

(function(i) {
    var re = new RegExp('Sensor_ID_goes_here[\\s\\S]*?Timestamp[\\s\\S]*?<h4>([0-9]+/[0-9]+/[0-9]+ [0-9]+:[0-9]+:[0-9]+ [A|P]M)</h4>');
    var out = i.match(re)[1];
    return out;
})(input)

Rule to check when a sensor was last seenā€¦

import java.text.SimpleDateFormat

rule "Heat pump return temperature time stamp check"
when
    Item HeatPumpReturnTemperatureTimestamp received update
then
    val String timestamp_str = HeatPumpReturnTemperatureTimestamp.state.toString //from http cache and REGEX transform

    val SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a")
    val DateTime timestamp = new DateTime(formatter.parse(timestamp_str))          
    val Number elapsedtime = (now.millis - timestamp.millis)/60000

    if (elapsedtime > 30) { // 30mins since last seen
        sendNotification('your email address','Heat pump return sensor not seen for  ' + elapsedtime + 'minutes')
        logInfo("Mobile Alerts" , "Time now = " + now)
        logInfo("Mobile Alerts" , "Heat pump return sensor time stamp = " + timestamp)
        logWarn("Mobile Alerts" , "Heat pump return sensor not seen for " + elapsedtime + " minutes")
    }
end

Hey Mark,
I tried to go your way. But it didnĀ“t work.

My item:
Number MobileAlerts_Outside_Temperature ā€œTemperatur Balkon [%.1f Ā°C]ā€ (mobilealerts) {http="<[mobileAlerts:60000:JS(getTemperatureout.js)]" }

My getTemperatureout.js
(function(i) {
var re = new RegExp(ā€˜Sensor-ID[\s\S]?Temperature[\s\S]?

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

My addons.cfg:
transformation = javascript,map

My http.cfg:
mobileAlerts.url=http://measurements.mobile-alerts.eu/Home/SensorsOverview?phoneid=XXXXXXXXX
mobileAlerts.updateInterval=60000

at HABpanel it only shows NULL

at Basic UI it only shows - Ā°C

at paper UI - Transfomations I installed Javasript Transformation und Map Transformation.

with https://measurements.mobile-alerts.eu/Home/SensorsOverview?phoneid=XXXXXXXXX all is shown correctly.

where did I made a mistake or what could missed?

Greetings, Ansgar

I see one problem so far

For checking regex on websites [\s\S] works but for Openhab it should be [\\s\\S]

Its easier to read if you enclose your posted in code in code fences. Button on far right after the smilie.

Any errors in the log?

Cheers Mark

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

Message at openhab.log:

org.openhab.core.transform.TransformationException: An error occurred while executing script.
at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:67) ~[210:org.openhab.core.compat1x:2.4.0]
at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:194) [246:org.openhab.binding.http:1.13.0]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:144) [210:org.openhab.core.compat1x:2.4.0]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:166) [210:org.openhab.core.compat1x:2.4.0]
2019-03-12 19:12:52.924 [WARN ] [ab.binding.http.internal.HttpBinding] - Transformation ā€˜JS(getTemperatureout.js)ā€™ threw an exception. [response=

did you test the regex on the sensor web page? eg regex101. Goto sensor web page , view source and copy the code. Paste into regex101. The regex expression will need the double backslash changing to one backslash. You can play around with the regex and you should see it match something.

sorry, I not really expert.
Where can I test this?
where do i find regex101?

I am not an expert either. I just learnt enough to get the job done.

This will test if your regex is working as expected and returning a number.

Or post the html and I can try for you

I see a possible problem. The regex should have an OR condition | to allow for + and - temperatures :

<h4>([0-9]+.[0-9]+|-[0-9]+.[0-9]+) C'

Was the outside temperature minus C when you tested?

PROBLEM SOLVED!
now I use https: and not http: at http.cfg an I find the correct names at the *.js files.

Hey Mark,
I use the sensor: TEMPERATURSENSOR MIT WASSERDICHTER KABELSONDE (MA10101)
I tried to get the info ā€œTrockenā€ or ā€œNassā€ with js-file.

Did everyone test it and can help?

Hello to everyone,
I found the solution for the sensor MA10101:

The item:

string		MobileAlerts_Indoor_Water	 				"Wassersensor KĆ¼che [%s]"										<water> 				(mobilealerts) 				{http="<[mobileAlerts:60000:JS(gettrockenin.js)]"}

Javascript:
(function(i) {
    var re = new RegExp('SENSOR-ID[\\s\\S]*?Wassersensor[\\s\\S]*?<h4>([a-zA-Z]+)');
    var out = i.match(re)[1];
    return out;
})(input)

Rule:
    rule "Wasser"
when
	Item MobileAlerts_Indoor_Water changed from Trocken to Feucht
then
	sendTelegram("BOT-Name", "Wasser!")
end

Hi togehther
I`m brand new with the openhab2 system and I need help to integrate my MobileAlert things.
what I had do:

Step One:
Add the following lines in http.cfg in the folder services . Please replace the xxx with your phoneid from the Mobile Alerts App

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

I can see in the LOG:

<div class="panel panel-default">

    <div class="panel-body">

        <div class="sensor">

<div class="sensor-header">

    <h3>

        <a href="/Home/MeasurementDetails?deviceid=XXXXXXXXXXXX&amp;vendorid=XXXXXXXX-9XXX-XXXX-XXXX-XXXXXXXXXXXX&amp;appbundle=de.synertronixx.remotemonitor">Zimmer EG</a>

    </h3>

    <div class="sensor-component">

        <h5>ID</h5>

        <h4>XXXXXXXXXXXX</h4>

    </div>

</div>

<div class="nofloat"></div>

    <div class="sensor-component">

        <h5>Zeitpunkt</h5>

        <h4>25.03.2019 15:04:38</h4>

    </div>

    <div class="sensor-component">

        <h5>Temperatur</h5>

        <h4>17,5 C</h4>

    </div>

    <div class="sensor-component">

        <h5>Luftfeuchte</h5> <!-- Luftfeuchtigkeit -->

        <h4>41%</h4>

    </div>

        </div>

    </div>

</div>

Step Two:

Create a new or edit your existing items file and add the following items:

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 %%]" <humidity> (Raumklima, Wohnzimmer) {http="<[mobileAlerts:300000:REGEX(.*?Humidity Indoor.*?\\s.*?([0-9]+)%.*)]"}

I DONT NO WHAT I NEED TO CHANGE by this file.

Step Three:

To convert the ā€œ,ā€ to ā€œ.ā€ in the temperature readings and save the values as numbers define two rules as follows:
I DONT NO IN WHICH FILE I NEED TO COPY this text

I hope someone can help me.
also how I can build a lot of sensors. Badroom, kitchen,ā€¦

kind regards
goair

ā€¦and sorry for my bad english

Hey Mark,
thanks for your answer.
I use this item:
Group mobilealerts
ā€œMobile Alerts Sensorenā€

Number mobileAlerts_Outside_Temperature ā€œTemperatur Balkon [%.1f Ā°C]ā€ (mobilealerts) {http="<[mobileAlerts:60000:JS(getTemperatureout.js)]" }
Number mobileAlerts_Outside_Rain ā€œRegen letzte 24 h [%.1f mm]ā€ (mobilealerts) {http="<[mobileAlerts:60000:JS(getrain.js)]" }
Number MobileAlerts_Indoor_Temperature ā€œTemperatur KĆ¼che [%.1f Ā°C]ā€ (mobilealerts) {http="<[mobileAlerts:60000:JS(getTemperaturein.js)]" }
Number MobileAlerts_Indoor_Humidity ā€œLuftfeuchtigkeit KĆ¼che [%d %%]ā€ (mobilealerts) {http="<[mobileAlerts:60000:JS(getHumidityin.js)]"}
String MobileAlerts_Indoor_Water ā€œWassersensor KĆ¼che [%s]ā€ (mobilealerts) {http="<[mobileAlerts:60000:JS(gettrockenin.js)]"}

this js-file for temperature:
(function(i) {
var re = new RegExp(ā€˜SENSOR ID[\s\S]?Temperatur[\s\S]?

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

this http.cfg:
mobileAlerts.url=https://measurements.mobile-alerts.eu/Home/SensorsOverview?phoneid=XXXXXXXX
mobileAlerts.updateInterval=60000

and only get rounded results

at events.log I found:
2019-03-25 18:57:46.924 [vent.ItemStateChangedEvent] - mobileAlerts_Outside_Temperature changed from 7.0 to 6.0

at openhab.log I found:

Zeitpunkt

22.03.2019 20:44:13

Temperatur

15,5 C