[SOLVED] Item Status "-" - how to deal with it?

Hi all,

I’ve got a working implementation of a Pollen status overview.

I would like to highlight the result in different colors using valuecolor in the sitemap and depending on the severity of the pollen exposure of the day. The values returned are numbers and it works as long as the number actually has a value.
When there is no pollen exposure the status of the item is “-” (not NULL, UNDEF, …). I would still like to map a color to that status, but need help in how to deal with it:


Number PollenBirke_d0 "Birch today: [MAP(pollen.map):%s]" <birch> (Wetter) { http="<[http://192.xxx.xxx.xxx:8080/static/pollen.txt:60000:JSONPATH($.Birke[0].selection2[0].selection3[0].Belastung)]"}


4=very high
-=no exposure


Text item=PollenBirke_d0 valuecolor=[**X**="lime", 1="green", 2="orange", 3="red", 4="maroon"] 

What do I need to add to the sitemap instead of the X in the sitemap to reflect the status of “-”?
I’ve tried different ways, but cannot come to a working solution.

Using -="lime" for example, would produce the below error in the logs

Configuration model has errors, therefore ignoring it: no viable alternative at input '=' 

thanks in advance for your support,

-” is a sitemap representation of NULL (I think but it could be Undefined, let’s find out together… :smiley:)

Text item=PollenBirke_d0 valuecolor=[NULL="lime", 1="green", 2="orange", 3="red", 4="maroon"] 

ha! You’re a marvel!!!
I’ve played arround with it a million times and now it’s working.
thanks! :slight_smile:

Hi Kurt,
I am very interested in your implementation. Would you mind giving more information about your workaround with that pollen.txt file? How do you fill the values every day?

Hi Ben,

I’m using parsehub to scrap the data from a webpage (which has no API unfortunately) but is the only reliable source for Pollen exposure around the area I’m living in.

parsehub is a opensource tool, which is quite easy to use (just click on the data field you want to scrap): https://www.parsehub.com/

Via the parsehub API, I’m first triggering the run (basically asking pasehub to run the querry of the page) via a script and then downloading the data into a txt file.
I’m then using a JasonPath Transformation to querry the Pollen exposure from the txt file via the Item. (where actually @vzorglub was a big help)

Querry Data:

curl -X POST 'https://www.parsehub.com/api/v2/projects/PROJECTKEY/run?api_key=APIKEY'

Download Data:

curl -X GET 'https://www.parsehub.com/api/v2/projects/PROJECTKEY/last_ready_run/data?api_key=APIKEY&format=JSON' | gunzip > /srv/openhab2-conf/html/pollen.txt

the text file gets saved into the HTML folder, so I can access it.
For me, paseHub gives me a zipped file, so I’m also unzipping it.


rule "Pollen"
		Time cron "	0 0 0/4 1/1 * ? *" // this one cycles every 4 hours. 

var Timer ParseHubTimer = null

    executeCommandLine("sh /srv/openhab2-conf/scripts/parsehub_run.sh")
    logInfo("POLLEN", "parseHub Data Run BIRCH initiated")    

ParseHubTimer = createTimer(now.plusMinutes(10))[|
// give some time to allow ParseHub to complete the run

    executeCommandLine("sh /srv/openhab2-conf/scripts/parsehub_save.sh")
    logInfo("POLLEN", "parseHub Data File BIRCH saved")    

I’m querrying the Pollen exposure for the next 3 days:

Number PollenBirch_d0 "Birch today: [MAP(pollen.map):%s]" <birch> (Wetter) { http="<[http://192.xxx.xxx.xxx:8080/static/pollen.txt:60000:JSONPATH($.Birke[0].selection2[0].selection3[0].Belastung)]"}
Number PollenBirch_d1 "Birch tomorrow: [MAP(pollen.map):%s]" <birch> (Wetter) { http="<[http://192.xxx.xxx.xxx:8080/static/pollen.txt:60000:JSONPATH($.Birke[1].selection2[0].selection3[6].Belastung)]"}
Number PollenBirch_d2 "Birch day after tomorrow: [MAP(pollen.map):%s]" <birch> (Wetter) { http="<[http://192.xxx.xxx.xxx:8080/static/pollen.txt:60000:JSONPATH($.Birke[2].selection2[0].selection3[12].Belastung)]"}

Also, I’m transforming the querried data, which you can see in the transform file above.
In the above example, I’ve translated it into English.
The outcome in the sitemap looks like that (in German and showing birch and grass, as birch has no exposure currently where I’m living).


hope it helps. If you want any further guidance, let me know.


1 Like

Thanks so much for your time to answer my question in such a detailed way. Its actually more kind of a very nice tutorial now :grinning:
I will try your workaround and will have a look especially on parsehub. Seems to be a very nice tool.