Allstar Weather Scripts – BBB (Version 1.2.1)

Allstar Weather Scripts Information for the BeagleBone Black

IMPORTANT NOTE –   Failing Text to Speech converstion due to Google Changes.

This includes specific information for the BeagleBone Black (BBB) weather script release found in the latest Allstar BBB release.

Weather Scripts Online Documentation and FAQ

Weather alerts now use NWS County code information and not Zone codes. Below reflects the latest version using NWS County codes for alert notification.

Allstar Weather Script General Information

The following BBB weather scripts provide weather reports, alerts, and forecasts to the Allstar user by downloading text from the National Weather Service (NWS) and converting them into speech which can be output can be played on the Allstar node. The following is a brief description of the files being installed and their function.

Script/File Name Description

wx_alert_product.txt
Used by “getWxAlert” to parse the alerts.
getWxFor [] Gets the weather forecast for the local area (can be changed). This also converts from text to audio file by calling text to audio script. This script is normally called by cron. Files are are downloaded to the following directory and creates the ul audio file based upon the text file:
 
     /tmp/wx/forecast//wx_forecast.txt
     /tmp/wx/forecast//forecast.ul
getWxRpt_ug [<WX_UNDERGRND_STN>] Gets the current condition (based upon xml data) from Weather Underground Stations. The xml data is downloaded from the Weather Underground station and converted to local variables. The script then uses these values to create a weather report. Since this data is more verbose, it allows greater detail including pressure trends, precipitation data, as well as other information. This script is called by cron. Files are located at:
     /usr/local/bin/Weather/getWxRpt_ug/

 
clearWxAlerts Clears and removes playWxAlertBg lockfiles. This script should be used when debugging or during a force clear of wx alerts. The main function is to remove all lock files and alert messages. This will not prevent new alerts being generated.
playWxAlertBg [<COUNTY>] This program is not a user executed program. The program  is called by getWxAlert and placed in background when an alert is issued from the NWS. The script will play the alert message as follows: initial, 15m, 15m, 15m, 30m, 30m, then every 60m. If this message broadcast is not desired, then you can modify this feature by running the wx_config.sh script which is found at: /usr/local/bin/Weather/wx_config.sh
trend The trend script is called by crond every six hours to determine the pressure trends; steady, rising, falling. The cron entry is created when the wx_config.sh script is executed and weather reports are selected.
wxtext_conv.sed This is a general text conversion sed file.  This sed conversion file converts the weather text  files into a more pleasing sounding text to speech conversion. For example: “MPH” to “Miles per Hour”, etc.  Many times you will need to change a pronunciation, like “wind” to “wynd” to make the audio clearer or correct pronunciation. The Google TTS actually does a good job with most pronunciations. This file uses the “sed” format for conversion.
wx_scripts.conf Configuration file which is created by the wx_config.sh script.

Installation

Starting with the BeagleBone Black 1.2 Allstar release, the weather scripts are included in the distribution. Installation is simple, but you will need to gather some information prior to running the weather configuration scripts, wx_config.sh.

You will need the following:

  1. NWS County information for your location
  2. NWS Zone information for your location
  3. Weather Underground local station indentifer.

The following sections will help you determine these values.

NWS Zone Information (used for Wx Forecast)

where <st> is the 2 letter state abbreviation, for example:

Pick from the various cities/areas displayed.

Select the desired identifier; this will be used for the ZONE variable for example, Wright County, MN is MNZ059. Write down this Zone number for your area (default ZONE). If you want to be alerted on multiple areas, choose those areas.

NWS COUNTY Information (used for Wx Alerts)

  • Now, pick from the various State Counties displayed.
  • Select the desired identifier; this will be used for the COUNTY variable for example, Wright County,

MN is MNC171. Write down this COUNTY number for your area/county. If you want to be alerted on multiple areas, make a note of those counties.

Weather Underground Information (used for Wx Reports)

Browse the map for your local area. You will see the Station ID’s of various weather stations. Once you select one on the map, you will find the station ID. This will be begin K, then two letter state abbreviation, and location. for example:

Underground Weather Station Example

Underground Weather Station Example

 

The station selected is KMNSTMIC3. When selecting the desired station and review the captured information to make sure that this has all of the values you want to capture. For example, some stations do not include precipitation. I prefer the “rapid fire” stations since they update most frequently. You will use the “Station ID” for the configuration file.

Once you have the NWS Zone, NWS County and Weather Underground Station ID values from above, you are now ready to execute the wx_config.sh script.

Running the Configuration Script

Type the following commands:

    cd /usr/local/bin/Weather

    ./wx_config.sh

You will see the following output:

    Weather configuration script...

============================================================================
|                            IMPORTANT NOTICE!                               |
|                                                                            |
| No matter what the Weather Alerts are  indicating, the information         |
| gathered and presented here may NOT be accurate. You MUST use your own     |
| judgement to determine your best course of action in any given             |
| circumstance! The are many reasons WHY the data here may not be accurate,  |
| including, but not limited to, software problems, network problems, and or |
| hardware problems. The Weather Alerts and other Weather information should |
| NOT be used to make any determination of actual current conditions, it is  |
| merely an indication of what the software is seeing as a result of it's    |
| attempts to read publicly available data sources.  These data sources may  |
| be unavailable, unreachable, or inaccurate. Please check other sources to  |
| verify any information presented here.                                     |
 ============================================================================

Do you understand and acknowledge the above notice?  [y,n,q]?

You will need to enter “y” to acknowledge the notice. The next section you will be prompted if you want to various areas. Select “y” or “n” for the next selections. Below I am selecting all of the configurable options:
Do you understand and acknowledge the above notice?  [y,n,q]? y

Do you wish to setup/update the weather alerts:  [y,n,q]? y

Do you wish to setup/update the weather reports:  [y,n,q]? y

Do you wish to setup/update the weather forecasts:  [y,n,q]? y

Based upon your select, the script will provide a brief note on the next entries. If you are reading this here, you already should have all of the necessary codes. Below is an example of each area:
----------------------------------------
Weather alert setup...
----------------------------------------

Weather Alert Setup.  This script will allow you to get short alert messages 
via your node audio.  

You will need to have the NWS County number information to setup the Weather 
Alerts.  Refer to the following URL:

    http://www.weather.gov/alerts

Select the "Warnings By State" under "Active Alerts". Select the County List 
listed by the desired state.  You will see the "County Code", now pick from the 
various State Counties displayed and write this "County Code" down for reference.

For example, under Minnesota you will find - Wright. The County Code for
this county is  MNC171. If you want to be alerted on multiple areas, make a 
note of those counties and you can re-execute the script and enter the 
additional counties.

Please enter the National Weather Service County for your area
  (for example, MNC171): mnc171

Entry your county name: Wright County

     Checking/Adding crontab entry for user root...

    Adding crontab entry...
    Entry Added...

----------------------------------------
weather report setup...
----------------------------------------

Underground Weather Report Setup.  This script will allow you to get current 
weather conditions based upon Weather Underground stations by a dtmf sequence 
and will announce the weather conditions via your node audio.  

You will need to have the Underground Weather station ID information prior
to running this script. Refer to the URL below:
    http://www.wunderground.com/wundermap/

Browse the map for your local area. You will see the Station ID's of various 
weather stations. Once you select one on the map, you will find the station ID. 
This will be begin K, then two letter state abbreviation, and location. For
example:

      KMNSTMIC3

When selecting the desired station and review the captured information to make 
sure that this has all of the values you want to capture. For example, some 
stations do not include precipitation. I prefer the “rapid fire” stations 
since they update most frequently. You will use the “Station ID” for the 
configuration file.

For more information, refer to:
    http://www.w0anm.com/dokuwiki/doku.php?id=irlp:wx_scripts_doc

Please enter the Underground Weather Station ID
  (for example, KMNROGER1): kmnstmic16

     Checking/Adding crontab entry for user root...

    Adding crontab entry...
    Entry Added...

----------------------------------------
weather forecast setup...
----------------------------------------

Weather Forecast Setup.  This script will allow you to get your NWS weather 
forecast messages by a DTMF sequence and will announce the weather conditions 
via your node audio.

You will need to have the NWS Weather Zone ID information prior to running this script.

Refer to the following URL:

    http://www.weather.gov/alerts

Select the "Warnings By State" under "Active Alerts". Select the "Zone List" 
listed by the desired state.  You will see the "Zone Code", now pick from the 
various State Counties displayed and write this Zone Code down for reference.

For example, Under Minnesota you will find - Wright. The Zone Code for
this county is  MNZ059. If you want to to have forecast for other areas,
make a note of those counties and you can re-execute the script and enter the 
additional counties.

Press any key to continue...

Please enter the NWS Zone forecast ID 
  (for example, MNZ059): mnz059

     Checking/Adding crontab entry for user root...

    Adding crontab entry...
    Entry Added...

Enter Allstar Node Number:29062

Do you want to enable over the air weather alerts?  [y,n,q]? y
y
----------------------------------------
Stanza Modification Example for:
 /etc/asterisk/rpt.conf
----------------------------------------
    You will need to edit the /etc/asterisk/rpt.conf file to include the localplay
    entries under your node's functions stanza.

    Below is an example. Please update dtmf sequence to your requirements.

    (/etc/asterisk/rpt.conf)

        [functions]

    ; Play local wx report, *986 
    986=localplay,/tmp/wx/wxreport_ug/KMNSTMIC16/cur_WxRpt_ug
    ; Play local wx alert, *987
    987=localplay,/tmp/wx/alert/MNC171/alert_short
    ; Play local wx forecast, *988
    988=localplay,/tmp/wx/forecast/MNZ059/wx_forecast

-----------------NOTE-------------------

You can run this script multiple times to add additional weather stations
to your crontab or features.

----------------------------------------
Setup/Update Completed
----------------------------------------

This script can be executed over and over to add additional alert areas, weather forecast areas, or underground weather stations. When the scripted is executed, additional entries will be added to root’s cron entry. However, you will still need to modify the rpt.conf function stanza for the additional dtmf sequences to play the added stations/areas.

Modifying rpt.conf File

In order to play reports, forecasts and alerts, you will need to edit the rpt.conf file and setup the DTMF sequencies. The area to modify is the nodes “function” stanza. Below is an example of selecting:

  • *986 – play underground weather rebport
  • *987 – play NWS weather alert summary
  • *988 – play weather forecast

Edit /etc/asterisk/rpt.conf file and under the “functions” stanza add the localplay commands. The commands can be changed to reflect your nodes dtmf scheme.

        [functions]

    ; Play local wx report, *986 
    986=localplay,/tmp/wx/wxreport_ug/KMNSTMIC16/cur_WxRpt_ug
    ; Play local wx alert, *987
    987=localplay,/tmp/wx/alert/MNC171/alert_short
    ; Play local wx forecast, *988
    988=localplay,/tmp/wx/forecast/MNZ059/wx_forecast

After editing the /etc/asterisk/rpt.conf file, you must restart rpt module to allow the changes to take affect.  This is done by entering the following command:

asterisk -rx “rpt reload”

Testing Weather Alerts

Follow the steps below:

  1. list cron entries:

          crontab -l
    

    Which shows:
    # NWS Alert for MNC171 in Wright County
    */14 * * * * (/usr/local/bin/Weather/getWxAlert MNC171 "Wright County" &amp;&gt; /dev/null 2&gt;&amp;1)

    # Underground Weather for station: KMNROGER1
    */16 * * * * (/usr/local/bin/Weather/getWxRpt_ug KMNROGER1 &> /dev/null 2>&1)

    # Underground Weather (pressure trends) for station: KMNROGER1
    0 */6 * * * (/usr/local/bin/Weather/trend KMNROGER1 &> /dev/null 2>&1)

    # National Wx Service Forecast based on Zone: MNZ059
    */16 * * * * (/usr/local/bin/Weather/getWxFor MNZ059 &> /dev/null 2&>1)

  2. Execute the getWxAlert entry:

    /usr/local/bin/Weather/getWxAlert MNC171  "Wright County"

  3. Verify the following files that were created in /tmp/wx by entering:

    ls /tmp/wx/alert/

For an example, the county id that I have setup is MNC171. Here is the output for the command above:

ls -la /tmp/wx/alert/MNC171                           
total 64                                                                       
drwxr-xr-x 2 root root   160 Oct 19 12:47 .                                    
drwxr-xr-x 3 root root    60 Oct 19 12:42 ..                                   
-rw-r--r-- 1 root root  1775 Oct 19 12:47 alert.info                           
-rw-r--r-- 1 root root   172 Oct 19 12:42 alert_prev_summary.txt               
-rw-r--r-- 1 root root 41208 Oct 19 12:42 alert_short.ul                       
-rw-r--r-- 1 root root   172 Oct 19 12:47 alert_summary.txt                    
-rw-r--r-- 1 root root    74 Oct 19 12:42 no_alerts.txt                        
-rw-r--r-- 1 root root    56 Oct 19 12:47 wx_new.txt

You will notice that there is an audio file created alert_short.ul

  • Verify that the DTMF sequence works. In the above examples, I have “*987” defined to play the alert message. Enter your dtmf squence with by a remote radio, or by using the asterisk command line as follows:

    asterisk -rx "rpt fun [node_number] [dtmf_seq] "
    
        asterisk -rx "rpt fun 29062 *987"

You can also use the lsnodes web interface to inter the sequence. You should hear the output of the audio file.

Weather Alert Troubleshooting

  • Check to make sure that the county id is valid and was entered correctly.
  • If dtmf sequence fails to output, make sure that there is an audio file in /tmp/wx/alert/<county_id>/alert_short.ul and it’s a “non-zero” length file meaning that the file size is greater than 0, and typically it’s 41K in size.
  • In the rare event that the locking files are in a “dead lock” condition, you can clear the weather alerts by using the “/usr/local/bin/Weather/clearWxAlert” script as follows:

    /usr/local/bin/Weather/clearWxAlerts                  
      Stopping Weather Alert Messages...     Done.                              
      Removing lock files from /tmp...     Done.                                
      Cleaning up the alert weather directories...     Done.                    
      Removing temporary files in /tmp/wx..     Done.

Testing Weather Forecast

Verify that the crontab entry for the weather forecast is present. Type:

crontab -l

Look for the entry:

# National Wx Service Forecast based on Zone: MNZ059
*/16 * * * * (/usr/local/bin/Weather/getWxFor MNZ059 &amp;&gt; /dev/null 2&gt;&amp;1)

If the entry is not present, you will need to execute the /usr/local/bin/Weather/wx_config.sh script and select “y” to the prompt “Do you wish to setup/update the weather forecasts”. For weather forecasts, first get the data manually using the following commands:

/usr/local/bin/Weather/getWxFor ;

For example:
/usr/local/bin/Weather/getWxFor MNZ059

There will be a delay before the prompt is returned. The getWxFor script is pulling data from the NWS website and parsing the data. Once the data is parsed, the data files and audios files are created in /tmp/wx/forecast/;. For example:
/tmp/wx/forecast/MNZ059
wx_forecast.txt  wx_forecast.ul

The wx_forecast.txt file is the text file for the weather forecast and the wx_forecast.ul is the audio file.

Weather Weather Underground Reports

Verify that the crontab entry for the weather forecast is present. Type:

crontab -l

Look for the entry:

# Underground Weather for station: KMNSTMIC3
*/16 * * * * (/usr/local/bin/Weather/getWxRpt_ug KMNSTMIC3 &amp;&gt; /dev/null 2&gt;&amp;1)

# Underground Weather (pressure trends) for station: KMNSTMIC3
0 */6 * * * (/usr/local/bin/Weather/trend KMNSTMIC3 &> /dev/null 2>&1)

If the entry is not present, you will need to execute the /usr/local/bin/Weather/wx_config.sh script and select “y” to the prompt “Do you wish to setup/update the weather reports: [y,n,q]?”. For weather reports, first get the data manually using the following commands:

/usr/local/bin/Weather/getWxRpt_ug 
/usr/local/bin/Weather/trend

For example:
/usr/local/bin/Weather/getWxRpt_ug KMNSTMIC3
/usr/local/bin/Weather/trend KMNSTMIC3

There will be a delay before the prompt is returned. The getWxPrtp_ug script is pulling data from the Weather Underground Station and parsing the data. Once the data is parsed, the data files and audios files are created in /tmp/wx/wxreport_ug/<WX_Underground_STNID>. For example:
/tmp/wx/wxreport_ug KMNSTMIC3

The directory will contain several files:
cur_WxRpt_ug.txt  cur_WxRpt_ug.ul  KMNSTMIC3.xml  saved_pressure.var  var.src

The cur_WxRpt_ug.txt file is the text file for the weather forecast and the cur_WxRpt_ug.ul is the audio file. There are also pressure trend files that are saved in this directory. This monitors the pressure trends in a six hour period if the data is available.

Using the Scripts

Once the scripts are setup in cron to gather the information and the rpt.conf file has been modified, there is not much to using the scripts. The cron entries will automatically gather the weather information. I would suggestion to stagger the gathering times if you are gathering a lot of weather information. This can be accomplished by editing the corntab by using the command:

crontab -e

The format of the crontab file is as follows:
 The time and date fields are:

              field          allowed values
              -----          --------------
              minute         0-59
              hour           0-23
              day of month   1-31
              month          1-12 (or names, see below)
              day of week    0-7 (0 or 7 is Sunday, or use names)

The first field, minute, can follow a range with “/<number>” specifies skips of the number’s value through the range. For example, “0/20” can be used to specify command execution every 20 minutes, or you can select a step range. For example:
0, 18, 34, 46 * * * * (/usr/local/bin/Weather/getWxRpt_ug KMNSTMIC3 &amp;&gt; /dev/null 2&gt;&amp;1)

This will execute the script on top of the hour, 18 minutes past the hour, 34 minutes past the hour, and then 46 past the hour.

WxScripts FAQ’s

I rebooted my system and now the weather information is missing?

This is normal, all data is stored in /tmp directory which is cleared when the BBB is rebooted. You can ether run the getWx scripts manually or just let the cron daemon run the scripts which will re-populate the weather files. Prior to creating the new files, any weather dtmf sequence will not play any weather information. If there was a weather alert occurring at the time of the reboot, it will resend the alert message after cron daemon has re-excuted the getWxAlert script.

Recommendations

Another thing that will be changing on the next release is a  result too many cron entries pulling down data and using the BBB processing power.  I have addressed this issue with the next release  of the weather scripts, but for the release you are using, I would recommend that you add “nice -19” in front of the entries to avoid issues:


# NWS Alert for MNC171 in Wright County
*/14 * * * * ( nice -19 /usr/local/bin/Weather/getWxAlert MNC171 "Wright County" &amp;&gt; /dev/null 2&gt;&amp;1)

# National Wx Service Forecast based on Zone: MNZ059
*/28 * * * * (nice -19 /usr/local/bin/Weather/getWxFor MNZ059 &> /dev/null 2>&1)

# Underground Weather for station: KMNSAINT16
*/16 * * * * (nice -19 /usr/local/bin/getWxRpt_ug KMNSTMIC3 &> /dev/null 2>&1)

# Underground Weather (pressure trends) for station: KMNSTMIC3
0 */6 * * * (/usr/local/bin/Weather/trend KMNSTMIC3 &> /dev/null 2>&1)

 

16 Responses to “Allstar Weather Scripts – BBB (Version 1.2.1)”

  1. Chris Says:

    I have to apologies for the site changing the coding. It appears that WordPress does not like “&> /dev/null 2>&1” and keeps re-formatting. I have attempted to fix this in the html code.

    73, Chris

  2. KK4ZKP Says:

    Hello,

    I absolutely love the WX scripts. Very convenient, not to mention very well-coded. Do you have any plans to create a similar script for the marine forecast?

    Thanks & 73,
    KK4ZKP

  3. Marshall Says:

    How do I get this in a ACID Install?

  4. Chris Says:

    I’ll be posting a blog later with the acid release for Centos 5.x. The release will be in the form of an rpm package.

  5. Mike Says:

    Hello, thanks for the scripts. Can you help me with a problem I am having on my RPi? I installed the RPi image at
    http://crompton.com/hamradio/BeagleBoneBlackAllstar/
    There is no audio transmitted when I execute the WX scripts – just a dead carrier. The node works just fine for other Allstar connections. I also accidentally deleted getWxRpt_ug. Can you send it to me as an attachment or post the RPi/BeagleBone source code to sourceforge?

    BTW, the preinstalled ./wx_config.sh from the image at crompton is in /usr/local/bin not /usr/local/bin/Weather. Maybe that is part of the problem?

    Thanks,
    Mike, AA9VI
    (if anyone else wants to reply, my email is at qrz.com)

  6. Chris Says:

    Hi Mike, I think we worked this one out. Yes, the later wx versions are using /usr/local/bin. I am planning to update some of the documents to reflect the latest versions and the pending acid update/release.

    73,

    Chris

  7. Bradley Says:

    figured out where i went wrong!! thanks for the great script.. How often will the weather alert be played on the air during the warning event or watch event?

  8. Chris Says:

    This can be selected. The next version will have entry to select the timing periods. You can also disable the alerts via a dtmf command. The issue is that the alerts can be reset and start from the first timing period during an event. This is caused by the NWS updating the alerts as the event take place.

    73,

    Chris

  9. Greg Says:

    When there are active wx alerts, do they key the radio and transmit automatically or does a user have to request alerts via dtmf? Thanks

  10. Chris Says:

    You can set it up for both. The node will transmit the short alert, and you can setup a dtmf sequence to play the long alert. Here is an example to play the long alert:

    ; play local wx alert, long *777
    777=localplay,/tmp/wx/alert//alert_full

    where is the alert county you selected for your alerts.

    On the down side, the full alerts can be lengthy. I would not recommend using it unless it’s a local node.

    73, Chris

  11. Bradley Says:

    Question.. fixed my issue on WX alerts but when it does play the alert it says Weather alert for ____ it leaves out the county.. WHere do i Head to look to fix that issue.

    Bradley
    kc9gqr

  12. Chris Says:

    This is caused by not having the county name as an argument. Make sure that the cron entry has the county name:

    # NWS Alert for MNC171 in Wright
    */14 * * * * (/usr/local/bin/getWxAlert MNC171 “Wright” &> /dev/null 2>&1)

    This is where the name is defined. In the above entry, the county is “Wright”.

    73, Chris

  13. Greg Says:

    Hi Chris.. I can do that but the suggested file ‘alert_full’ isn’t present in that directory. The file ‘pre_conv_alert_summary.txt’ looks like something I’d like to query on the radio but how can it be automated to be converted to TTS?

  14. Chris Says:

    I am looking into this issue, the latest wx_alert scripts and being updated. I’ll review this as I thought it was addressed in the later unreleased version. If I remember, the alert_full, is only present when there is an ongoing alert.

    73,

    Chris

  15. Rick Frerker Says:

    Hi,

    Rather scripts were working fine for about a year, then recently not at all. Investigating, it seems there is no *.ul files being generated. I re-imaged with a known working image and same issue. Is there a reason and a fix. I so miss the weather script function. I am using 1.2.1. Many thanks!

  16. Chris Says:

    See the following post:
    http://w0anm.com/blog/?p=702

Leave a Reply