Querying KNMI for MeteoAlarm

Moderator: leecollings

Post Reply
Toulon7559
Posts: 858
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Querying KNMI for MeteoAlarm

Post by Toulon7559 »

Triggered bij the present weather have been looking at reading a text for meteo-alarm, and found in the json-file provided by KNMI at weerlive.nl

Have a script extracting & querying that file.
Below the lines in that script which pull the json-file and perform the decoding.
All well with decoding, except for the last 2 lines related to meteoalarm:
expected to be more of the same, but no output coming.
val_Alarm is a value 0 or 1
AlarmText is a text string, comparable to summary0 or summary0~summary3

Somebody seeing what is 'wrong'?
[for obvious reasons in this code-listing the apikey is a placeholder]

Code: Select all

-- Line 075 = Querying KNMI
    json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()  -- For Linux
    -- result=os.capture('curl -s "http://weerlive.nl/api/json-data-10min.php?key='..api_key..'&locatie='..coord..'"')
    result=os.capture('curl -s "http://weerlive.nl/api/json-data-10min.php?key=abcdefghi&locatie=52.29626465,6.80555010"')
    -- if (DEBUG == 1) then print(result)  end
    --   
-- Line 081 = Reading values from json
    local jsonValeur = json:decode(result)
    val_Patm   =jsonValeur.liveweer[1].luchtd
    val_Tact   =jsonValeur.liveweer[1].temp
    val_Tgvl   =jsonValeur.liveweer[1].gtemp
    val_sup    =jsonValeur.liveweer[1].sup
    val_sunder =jsonValeur.liveweer[1].sunder
    summary0   =jsonValeur.liveweer[1].samenv
    val_Tmin   =jsonValeur.liveweer[1].d0tmin
    val_Tmax   =jsonValeur.liveweer[1].d0tmax
    icon       =jsonValeur.liveweer[1].image
    summary1   =jsonValeur.liveweer[1].verw 
    summary2   =jsonValeur.liveweer[1].d1weer
    val_Tmin2  =jsonValeur.liveweer[1].d1tmin
    val_Tmax2  =jsonValeur.liveweer[1].d1tmax
    summary3   =jsonValeur.liveweer[1].d2weer
    val_Tmin3  =jsonValeur.liveweer[1].d2tmin
    val_Tmax3  =jsonValeur.liveweer[1].d2tmax
    val_Alarm  =jsonValeur.liveweer[1].alarm
    AlarmText  =jsonValeur.liveweer[1].alarmtxt
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
User avatar
FireWizard
Posts: 1870
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Querying KNMI for MeteoAlarm

Post by FireWizard »

Hello @Toulon7559,
Have a script extracting & querying that file.
Below the lines in that script which pull the json-file and perform the decoding.
All well with decoding, except for the last 2 lines related to meteoalarm:
expected to be more of the same, but no output coming.
val_Alarm is a value 0 or 1
AlarmText is a text string, comparable to summary0 or summary0~summary3
I don't see any issues in your script.

The payload of liveweer[0].alarm = 0 or 1.
If there is a weather alarm, this value equals to 1, (And currently there is such an alarm)
In this case, also liveweer[0].alarmtxt is a rather long string.

The only thing I see, is that you use liveweer[1].luchtd, while the array uses 0.

See: https://weerlive.nl/api/json-data-10min ... =Amsterdam
Is this maybe the cause of your issue, but then I would expect it for all?
I would have expected for all: liveweer[0]
You can try.

Best regards
Toulon7559
Posts: 858
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Querying KNMI for MeteoAlarm

Post by Toulon7559 »

Firewizard,

Exactly my puzzle.
The JSON-file shows liveweer[0], but for some reasons ( ;-) long faded in history) the original script works fine with liveweer[1].
Seems to become 'try&error' to find a remedy to get those 2 extra lines operational.
.
Perhaps first have to look at results with the demo-call for Amsterdam, and when that works (positively showing that alarm is (not) detected),
then shift to my operational version to get the alarm-message.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest