OH3 and HTTP regex ... items not refreshed

Hi All,

OH3 build 2322 here.
I’ve a strange issue, I hope you can help me.

I’ve created a things file to grab some information from Meteoalarm.eu website

Thing http:url:meteoalarmtoday "MeteoAlarm Today" [ 
	refresh=600] {
			Type number : aw1 "Wind" [ stateTransformation="REGEX:.*aw1([1-4]+).*.?" ]
			Type number : aw2 "Snow/Ice" [ stateTransformation="REGEX:.*aw2([1-4]+).*.?" ]
			Type number : aw3 "Thunder" [ stateTransformation="REGEX:.*aw3([1-4]+).*.?" ]
			Type number : aw4 "Fog" [ stateTransformation="REGEX:.*aw4([1-4]+).*.?" ]
			Type number : aw5 "High Temp" [ stateTransformation="REGEX:.*aw5([1-4]+).*.?" ]
			Type number : aw6 "Low Temp" [ stateTransformation="REGEX:.*aw6([1-4]+).*.?" ]
			Type number : aw7 "Coastal" [ stateTransformation="REGEX:.*aw7([1-4]+).*.?" ]
			Type number : aw8 "Forest Fire" [ stateTransformation="REGEX:.*aw8([1-4]+).*.?" ]
			Type number : aw9 "Avalanches" [ stateTransformation="REGEX:.*aw9([1-4]+).*.?" ]
			Type number : aw10 "Rain" [ stateTransformation="REGEX:.*aw10([1-4]+).*.?" ]
			Type number : aw11 "Flood" [ stateTransformation="REGEX:.*aw11([1-4]+).*.?" ]
			Type number : aw12 "Rain Flood" [ stateTransformation="REGEX:.*aw12([1-4]+).*.?" ]

here my items:

Number Http_Meteoalarm_Today1               "MeteoAlarm: [MAP(meteoalarm-wind.map):%s]"         <meteoalarm_wind>       (gOutdoor, gWeather) { channel="http:url:meteoalarmtoday:aw1" }
Number Http_Meteoalarm_Today2               "MeteoAlarm: [MAP(meteoalarm-snowice.map):%s]"      <meteoalarm_snowice>    (gOutdoor, gWeather) { channel="http:url:meteoalarmtoday:aw2" }
Number Http_Meteoalarm_Today3               "MeteoAlarm: [MAP(meteoalarm-thunder.map):%s]"      <meteoalarm_thunder>    (gOutdoor, gWeather) { channel="http:url:meteoalarmtoday:aw3" }
Number Http_Meteoalarm_Today4               "MeteoAlarm: [MAP(meteoalarm-fog.map):%s]"          <meteoalarm_fog>        (gOutdoor, gWeather) { channel="http:url:meteoalarmtoday:aw4" }
Number Http_Meteoalarm_Today5               "MeteoAlarm: [MAP(meteoalarm-hightemp.map):%s]"     <meteoalarm_hitemp>     (gOutdoor, gWeather) { channel="http:url:meteoalarmtoday:aw5" }
Number Http_Meteoalarm_Today6               "MeteoAlarm: [MAP(meteoalarm-lowtemp.map):%s]"      <meteoalarm_lowtemp>    (gOutdoor, gWeather) { channel="http:url:meteoalarmtoday:aw6" }
Number Http_Meteoalarm_Today7               "MeteoAlarm: [MAP(meteoalarm-coastal.map):%s]"      <meteoalarm_coastal>    (gOutdoor, gWeather) { channel="http:url:meteoalarmtoday:aw7" }
Number Http_Meteoalarm_Today8               "MeteoAlarm: [MAP(meteoalarm-forestfire.map):%s]"   <meteoalarm_forestfire> (gOutdoor, gWeather) { channel="http:url:meteoalarmtoday:aw8" }
Number Http_Meteoalarm_Today9               "MeteoAlarm: [MAP(meteoalarm-avalanches.map):%s]"   <meteoalarm_avalanches> (gOutdoor, gWeather) { channel="http:url:meteoalarmtoday:aw9" }
Number Http_Meteoalarm_Today10              "MeteoAlarm: [MAP(meteoalarm-rain.map):%s]"         <meteoalarm_rain>       (gOutdoor, gWeather) { channel="http:url:meteoalarmtoday:aw10" }
Number Http_Meteoalarm_Today11              "MeteoAlarm: [MAP(meteoalarm-flood.map):%s]"        <meteoalarm_flood>      (gOutdoor, gWeather) { channel="http:url:meteoalarmtoday:aw11" }
Number Http_Meteoalarm_Today12              "MeteoAlarm: [MAP(meteoalarm-rainflood.map):%s]"    <meteoalarm_rainflood>  (gOutdoor, gWeather) { channel="http:url:meteoalarmtoday:aw12" }

The problem is: if, for example, today aw1 is “2” and the others are “NULL”, I see correctly “2” in Http_Meteoalarm_Today1. But if another day I have only aw2 set, for example, “3”, I see correctly Http_Meteoalarm_Today2 with “3”, but I still see “2” in aw1.

The debug is saying correctly

Transformation ChannelStateTransformation{pattern='.*aw1([1-4]+).*.?', serviceName='REGEX'} returned empty result when applied to

but Http_Meteoalarm_Today1 is reporting “2” instead of the expected “NULL”.

Uff … I know I’m doing something wrong, but … :slight_smile: not able to see.

last but not least, example of map file (meteoalarm-wind.map):


Any help?


edit: just to clarify the map file. The website is reporting the image filename structured in this way:

1-12 is the type of alarm
1-4 is the level of alarm

Why would you expect that? If the transformation found nothing to update the Item with, then it doesn’t get updated. Item retains same state as before.

I think you could use some other custom transformation to supply something different, e.g. UNDEF, if there is no data.

1 Like

It is quite strange as in OH2 the same idea was working (regex per item).

Anyway, do you think I should add a transformation per channel to set a “default” value?

This binding supports ‘chaining’ of multiple transformations. The behaviour to just stop instead of throwing an error is desirable there.

I don’t know, do you need a default value?
You might clear all of these daily things at midnight instead, I don’t know what they are or what you want.

EDIT - is only one of these combinations true at a time? That would make it simpler, but it seems to me that you can have fog and avalanche at the same time.

the website is reporting some weather alarms (aw1-12). Perhaps a binding would be definitely better, but I don’t have enough skills to do so. So I’m trying to use the flexible http binding to reach the same goal

my goal is to intercept aw1-12 (type of alarms) and the level of alarm (1-4 for each type of alarm … considering 1 is not an alarm, I would intercept only values 2-4).

The idea is: look at that website, if you find aw12, please populate the item “Http_Meteoalarm_Today1” with value “2”. For the other items better to set up a default “0”. In this way I will refresh all the items any time I’ll check the website.

What do you think? is that possible?


Yep I can have multiple alarms at the same time … That’s the reason why I’ve created multiple items, one for each alarm.

If I could set up a default value “0” before checking if there is a value in the website, that would be enough I think

Aha, so the website tells you when to clear some previous alarm, but you discard that information.

I would look at that again. Awxx = 1 is a positive “everything is ok” signal, quite different from NULL or UNDEF meaning “No idea”.

no, the website is just saying if there is an alarm. If there is not an alarm, they report a generic aw000 “no issues at all”. and it can’t help here :frowning:

Unfortunately the website is not reporting always all the 12 alarms … but only if an alarm is active, and if the level is 2-4

is there a way to set up a default value before the transformation with regex?


I think you’re going at this the wrong way.
Looking at what you are doing, it is just scraping an icon reference awxxx.jpg off a web page.
Then you do some analysis to “decode” the icon ref for meaning.

So far as I can see, there is always an icon present - aw000.jpg for “no warnings”.
Then there is always something present that can be used to clear or replace previous warnings.

I’ve not seen it, but from what you say there may be more than one icon present.

Applying some logic to all this to populate one or more Items is a bit beyond a transformation in a channel - especially as they are limited to only one Item at a time.

I’d be much more inclined to get the whole webpage into a working String Item, and process the whole show in a rule.
The rule can extract awxxx.jpg one by one, updating or resetting Items as it goes. You can do much more complex “ifs and buts” in a rule.

Do you really need 12 Items? I’d be more inclined to use just 3 or 4, depending on how many different alerts you might get in maximum. (Plus, if you’ve got 4 things to worry about, do you even care about a 5th?).

You could use JavaScript transformation instead of the regex, use the regex inside the Script, check if it matches and use the result as return value or return a default if not.

Twelve different javascripts for the original approach.


I know 12 different items are a lot, but with all 12 items you have the max flexibility possible.
I don’t see any other option to have the same flexibility (icon, level of alarm per alarm, multiple alarms) :frowning:


I’m not a JavaScript expert, but I will try to follow this direction.

Thank you


any suggestion how to start working with JavaScript? :slight_smile:
thanks for any suggestion :slight_smile:

(function(i) {
    var value = /put regex here/.exec(i)[0];
    if (value != null) {
       return value;
    return 0;    
1 Like

Thanks for your support.

I’ve tried the javascript, but in case of NULL I still see the value “NULL” and not “0”.

Here the example:

Type number : aw1 "Wind" [ stateTransformation="JS:meteoalarm-wind.js" ]


(function(i) {
    var value = /.*aw1([1-4]+).*.?/.exec(i)[0];
    if (value !== null) {
       return value;
    return 0;    

and the item file:

Number Http_Meteoalarm_Today1               "MeteoAlarm: [%d]"         <meteoalarm_wind>       (gOutdoor, gWeather) { channel="http:url:meteoalarmtoday:aw1" }

any suggestion?


maybe it’s not null but undefined. not 100% sure in JS

tried also “undefined”, same result:


(function(i) {
    var value = /.*aw1([1-4])\..*/.exec(i);
    if (value != undefined) {
       return value[1];
    return 0;    

Your old regex will fail for aw122 (alarm12, level 2) and would result in alarm 1, level 22.

1 Like

it works perfectly, thank you.

If I can ask, what [1] means?