Skip to content

Would like to add alerts #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RogerSchaefer opened this issue May 30, 2016 · 10 comments
Closed

Would like to add alerts #30

RogerSchaefer opened this issue May 30, 2016 · 10 comments

Comments

@RogerSchaefer
Copy link

The weather station works fine for me
HOWEVER
I would like to add 'alerts' because i would like to add an alarm when there is bad weather nearby. I added alerts and it started to load but crashed when it got to the field "message". Perhaps because it is too large.

Can you help?
Oldmicroguy

@squix78
Copy link
Collaborator

squix78 commented May 30, 2016

Hi Roger
Thanks for your request. Can you explain a bit more what alerts are? I assume they are part of the Wunderground API? Maybe paste the part of the json object that you are interested in here...
Regards,
Daniel

@RogerSchaefer
Copy link
Author

Hello Daniel,
Your Weather Station uses Wunderground “conditions” and “forecast10day”. “alerts” is another Data Feature.
The problem is testing because you have to find a part of the county that is experiencing some sort of weather alert.
Here is an example:

// 20160530145454
// http://api.wunderground.com/api/eceaa409b9a76e6c/alerts/q/AZ/Yuma.json

{
"response": {
"version": "0.1",
"termsofService": "http://www.wunderground.com/weather/api/d/terms.html",
"features": {
"alerts": 1
}
},
"query_zone": "025",
"alerts": [
{
"type": "HEA",
"description": "Excessive Heat Watch",
"date": "4:48 am PDT on May 30, 2016/",
"date_epoch": "1464608880",
"expires": "8:00 PM MST on June 05, 2016",
"expires_epoch": "1465182000",
"tz_short": "PDT",
"tz_long": "America/Los_Angeles",
"message": "\n...Excessive heat watch in effect from Friday morning through\nSunday evening...\n\nThe National Weather Service in Phoenix has issued an excessive\nheat watch...which is in effect from Friday morning through\nSunday evening. \n\n* Affected area...the lower deserts of southwest and south-central\n Arizona and southeast California. \n\n* Temperature...highs of 108-112 degrees...hottest on Saturday.\n\n* Impacts...heat related illness will be likely for those doing\n strenuous activity outdoors...or those with health conditions that\n do not have adequate access to air conditioning. If\n untreated...some illness events could be fatal. \n\nPrecautionary/preparedness actions...\n\nNever leave kids or pets unattended in cars. Drink more water\nthan usual and avoid alcohol...sugar...and caffeine. When\noutdoors...wear light colored clothing and a wide-brimmed hat to\nkeep your head and body cooler. Take frequent rest breaks in\nshaded or air conditioned environments. Public places with air\nconditioning include libraries...community centers...government\nbuildings...malls...and special Refuge stations. \n\nRecognize the signs and symptoms of heat illness. Early symptoms\ninclude things such as headache...thirst...and muscle cramps.\nSerious symptoms include weakness...skin that is cool to the\ntouch...fast but weak pulse...nausea...and fainting. Severe\nsymptoms include hot and red dry skin...fast and strong\npulse...sweating that has stopped...and unconsciousness.\nUntreated heat illness can lead to fatal heat stroke. \n\nStay cool...stay hydrated...stay informed.\n\n\n\nAj\n\n\n\n",
"phenomena": "EH",
"significance": "A",
"ZONES": [
{
"state": "AZ",
"ZONE": "020"

Your program crashes at the field “message”
Roger

From: squix78
Sent: Monday, May 30, 2016 2:36 PM
To: squix78/esp8266-weather-station
Cc: RogerSchaefer ; Author
Subject: Re: [squix78/esp8266-weather-station] Would like to add alerts (#30)

Hi Roger
Thanks for your request. Can you explain a bit more what alerts are? I assume they are part of the Wunderground API? Maybe paste the part of the json object that you are interested in here...
Regards,
Daniel


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@squix78
Copy link
Collaborator

squix78 commented May 31, 2016

Hi Roger
I assume you extended the WundergroundClient class to call the alerts URL and parse the message attribute and add it's content into? The problem is most probably in my json-streaming-parser class which limits the length of a value to 512 bytes: https://github.com/squix78/json-streaming-parser/blob/master/JsonStreamingParser.h
If I remember correctly this was an issue I wanted to resolve later or at least make it possible to change. While the library is currently able of parse huge json objects for relatively small length of keys and values it has a problem with keys or values bigger than 512 bytes. I can offer a quick fix by just ommitting characters beyond that length. If you are not interested in the messages field that should solve the problem...

@SCKStef
Copy link

SCKStef commented May 31, 2016

Hi Daniel,

I have the same issue, I have extended the parser too...

As example here an response from Germany which have more than one alert:

{
"response": {
"version":"0.1",
"termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
"features": {
"alerts": 1
}
}
,"query_zone": "999",
"alerts": [
{
"type": "WND",
"wtype_meteoalarm": "1",
"wtype_meteoalarm_name": "Wind",
"level_meteoalarm": "4",
"level_meteoalarm_name": "Red",
"level_meteoalarm_description": "The weather is very dangerous. Exceptionally intense meteorological phenomena have been forecast. Major damage and accidents are likely, in many cases with threat to life and limb, over a wide area. Keep frequently informed about detailed expected meteorological conditions and risks. Follow orders and any advice given by your authorities under all circumstances, be prepared for extraordinary measures.",
"description": "\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0009deutsch: Von Südosten ziehen wiederholt Gewitter auf. Dabei gibt es heftigen Starkregen mit Niederschlagsmengen um 40 l/m² pro Stunde sowie Windböen mit Geschwindigkeiten um 55 km/h (15m/s, 30kn, Bft 7) und kleinkörnigen Hagel.",
"date": "2016-05-29 19:09:00 GMT",
"date_epoch": "NA",
"expires": "2016-05-29 20:30:00 GMT",
"expires_epoch": "NA",
"message": "\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0009deutsch: Von Südosten ziehen wiederholt Gewitter auf. Dabei gibt es heftigen Starkregen mit Niederschlagsmengen um 40 l/m² pro Stunde sowie Windböen mit Geschwindigkeiten um 55 km/h (15m/s, 30kn, Bft 7) und kleinkörnigen Hagel.)",
"phenomena": "NA",
"significance": "NA",
"attribution": "Information provided by , EUMETNET - MeteoAlarm Note: Time delays between this website and Meteoalarm.eu are possible. For the most up-to-date information about alert levels as published by the participating National Meteorological Services, please visit Meteoalarm. For terms of use of this information, and copyright information, see Meteoalarm Terms of Use."
}
,
{
"type": "WRN",
"wtype_meteoalarm": "3",
"wtype_meteoalarm_name": "Thunderstorms",
"level_meteoalarm": "4",
"level_meteoalarm_name": "Red",
"level_meteoalarm_description": "The weather is very dangerous. Exceptionally intense meteorological phenomena have been forecast. Major damage and accidents are likely, in many cases with threat to life and limb, over a wide area. Keep frequently informed about detailed expected meteorological conditions and risks. Follow orders and any advice given by your authorities under all circumstances, be prepared for extraordinary measures.",
"description": "\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0009deutsch: Von Südosten ziehen wiederholt Gewitter auf. Dabei gibt es heftigen Starkregen mit Niederschlagsmengen um 40 l/m² pro Stunde sowie Windböen mit Geschwindigkeiten um 55 km/h (15m/s, 30kn, Bft 7) und kleinkörnigen Hagel.",
"date": "2016-05-29 19:09:00 GMT",
"date_epoch": "NA",
"expires": "2016-05-29 20:30:00 GMT",
"expires_epoch": "NA",
"message": "\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0009deutsch: Von Südosten ziehen wiederholt Gewitter auf. Dabei gibt es heftigen Starkregen mit Niederschlagsmengen um 40 l/m² pro Stunde sowie Windböen mit Geschwindigkeiten um 55 km/h (15m/s, 30kn, Bft 7) und kleinkörnigen Hagel.)",
"phenomena": "NA",
"significance": "NA",
"attribution": "Information provided by , EUMETNET - MeteoAlarm Note: Time delays between this website and Meteoalarm.eu are possible. For the most up-to-date information about alert levels as published by the participating National Meteorological Services, please visit Meteoalarm. For terms of use of this information, and copyright information, see Meteoalarm Terms of Use."
}
,
{
"type": "FLO",
"wtype_meteoalarm": "10",
"wtype_meteoalarm_name": "Rain",
"level_meteoalarm": "4",
"level_meteoalarm_name": "Red",
"level_meteoalarm_description": "The weather is very dangerous. Exceptionally intense meteorological phenomena have been forecast. Major damage and accidents are likely, in many cases with threat to life and limb, over a wide area. Keep frequently informed about detailed expected meteorological conditions and risks. Follow orders and any advice given by your authorities under all circumstances, be prepared for extraordinary measures.",
"description": "\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0009deutsch: Von Südosten ziehen wiederholt Gewitter auf. Dabei gibt es heftigen Starkregen mit Niederschlagsmengen um 40 l/m² pro Stunde sowie Windböen mit Geschwindigkeiten um 55 km/h (15m/s, 30kn, Bft 7) und kleinkörnigen Hagel.",
"date": "2016-05-29 19:09:00 GMT",
"date_epoch": "NA",
"expires": "2016-05-29 20:30:00 GMT",
"expires_epoch": "NA",
"message": "\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0009deutsch: Von Südosten ziehen wiederholt Gewitter auf. Dabei gibt es heftigen Starkregen mit Niederschlagsmengen um 40 l/m² pro Stunde sowie Windböen mit Geschwindigkeiten um 55 km/h (15m/s, 30kn, Bft 7) und kleinkörnigen Hagel.)",
"phenomena": "NA",
"significance": "NA",
"attribution": "Information provided by , EUMETNET - MeteoAlarm Note: Time delays between this website and Meteoalarm.eu are possible. For the most up-to-date information about alert levels as published by the participating National Meteorological Services, please visit Meteoalarm. For terms of use of this information, and copyright information, see Meteoalarm Terms of Use."
}
]
}

@RogerSchaefer
Copy link
Author

Hi Daniel,
Omitting characters beyond 512 bytes is exactly what I need. Will you issue a new version of the JsonStreamingParser?
Roger

From: squix78
Sent: Tuesday, May 31, 2016 12:52 AM
To: squix78/esp8266-weather-station
Cc: RogerSchaefer ; Author
Subject: Re: [squix78/esp8266-weather-station] Would like to add alerts (#30)

Hi Roger
I assume you extended the WundergroundClient class to call the alerts URL and parse the message attribute and add it's content into? The problem is most probably in my json-streaming-parser class which limits the length of a value to 512 bytes: https://github.com/squix78/json-streaming-parser/blob/master/JsonStreamingParser.h
If I remember correctly this was an issue I wanted to resolve later or at least make it possible to change. While the library is currently able of parse huge json objects for relatively small length of keys and values it has a problem with keys or values bigger than 512 bytes. I can offer a quick fix by just ommitting characters beyond that length. If you are not interested in the messages field that should solve the problem...


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@squix78
Copy link
Collaborator

squix78 commented May 31, 2016

I released a new version of the json-streaming-parser library. Can you update your local copy and make sure that you have version 1.0.3? Then please let me know if it fixes your issues...

@RogerSchaefer
Copy link
Author

I just installed version 1.0.3 but unfortunately it did not fix the problem. The ESP8266 still crashes when it tries to load a large field into a 512 byte buffer.
Roger

From: squix78
Sent: Tuesday, May 31, 2016 10:07 AM
To: squix78/esp8266-weather-station
Cc: RogerSchaefer ; Author
Subject: Re: [squix78/esp8266-weather-station] Would like to add alerts (#30)

I released a new version of the json-streaming-parser library. Can you update your local copy and make sure that you have version 1.0.3? Then please let me know if it fixes your issues...


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@squix78
Copy link
Collaborator

squix78 commented Jun 5, 2016

Do you see an Exception when the ESP crashes? Can you copy here that exception? Or even better would be, if you could do the steps described here: esp8266/Arduino#869 (comment)

I am getting the ESP to crash with a big local json object but I am not sure if that is the same problem...

@squix78
Copy link
Collaborator

squix78 commented Jun 5, 2016

There were some parsing problems for json containing unicode characters. I think they have been fixed. After the fix the json posted by @SCKStef could now be parsed, before it miserably crashed. Would you mind updating the json-streaming-parser library to 1.0.4 and test if you now can succesfuly read the alert json object?

@RogerSchaefer
Copy link
Author

Yes json-streaming-parser ver 1.04 fixes the problem. Thank you.
Roger

From: Daniel Eichhorn
Sent: Sunday, June 05, 2016 8:13 AM
To: squix78/esp8266-weather-station
Cc: RogerSchaefer ; Author
Subject: Re: [squix78/esp8266-weather-station] Would like to add alerts (#30)

There were some parsing problems for json containing unicode characters. I think they have been fixed. After the fix the json posted by @SCKStef could now be parsed, before it miserably crashed. Would you mind updating the json-streaming-parser library to 1.0.4 and test if you now can succesfuly read the alert json object?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@squix78 squix78 closed this as completed Jun 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants