Difference between revisions of "MythWeather"

From MythTV Official Wiki
Jump to: navigation, search
m (Requirements)
(Accuweather)
Line 184: Line 184:
 
====Accuweather====
 
====Accuweather====
 
*http://www.accuweather.com
 
*http://www.accuweather.com
*File: <code>accuweather.pl</code> http://code.google.com/p/mythweather-accuweather/
+
*File: <code>accuweather.pl</code> https://github.com/marcelrv/mythweather-accuweather
 
*You can set the response language in the file
 
*You can set the response language in the file
 
*Accu weather has  for almost any major city in the world detailed weather forecast. This script reads the accuweather forecast data for Current Conditions and Three and Six Day Forecasts.
 
*Accu weather has  for almost any major city in the world detailed weather forecast. This script reads the accuweather forecast data for Current Conditions and Three and Six Day Forecasts.

Revision as of 22:38, 12 March 2015

MythWeather is a plugin that downloads and displays weather information.

Installing MythWeather

MythWeather is part of the standard set of MythTV plugins. For most users who have installed a pre-packaged binary copy of MythTV, the work of installing MythWeather is already done. If you aren't compiling it from source, skip to the Configuration section. Otherwise, read on...

Requirements

For those users who are compiling their copy of MythTV and the plugins, there are a few dependencies to worry about. The plugin itself does not depend on any external libraries (other than those common to all MythTV plugins). However, MythWeather uses external grabber script files that actually download the weather data it displays. These grabbers live in the <prefix>/share/mythtv/mythweather/scripts directory by default.

Currently, all of the grabbers are written in PERL. Their combined dependencies include:

If you would like to test for the required modules before trying to install MythWeather, below is a quick way to do so. This is the same method used by the ./configure script. If the command runs successfully with no output, all necessary modules are installed.

cat << EOF | perl
use Carp;
use Data::Dumper;
use Date::Manip;
use Exporter;
use File::Basename;
use File::Path;
use File::stat;
use Getopt::Std;
use HTML::TreeBuilder;
use HTTP::Cache::Transparent;
use Image::Magick;
use Image::Size;
use LWP::Simple;
use SOAP::Lite;
use XML::Parser;
use XML::SAX::Base;
use XML::Simple;
use Time::Local;
EOF

If you need help installing PERL modules, check out the FAQ over at CPAN.

Compiling MythWeather

To compile MythWeather from source, grab a copy of the source code from the MythTV downloads page or check out a fresh copy of the plugins from SVN. If you're compiling the plugin yourself, I assume you are somewhat familiar with the process and won't explain the gory details of how to get your source tree set up. For those, check out the HOWTO, specifically the Plugins chapter.

Once you have your source tree all ready to go, do something similar to the following:

$ ./configure --disable-all --enable-opengl --enable-mythweather
$ make
$ make install

This will build the MythWeather plugin and install it using the default prefix (usually /usr/local).

Script Permissions

Now that you have the plug-in installed, it's best to check for the permissions on the grabber script files. This will help avoid nasty debugging in the future. Each grabber script needs to be executable by the user that mythfrontend runs under. To be safe, you can just set the permissions to 0755 for all of the *.pl files:

# chmod -v 0755 /usr/share/mythtv/mythweather/scripts/*/*.pl

Note: You may need to execute the command as root

PERL in Taint Mode

If you have your mythfrontend configured to run as root, whenever it executes a PERL script (i.e. to update the weather information), PERL will run in Taint Mode. This causes problems for the grabber scripts, because Taint Mode removes '.' (the current directory) from the @INC array in PERL. For more info, see #4954.

To get around this, you'll need to modify your grabber scripts slightly. Edit the first line of the script to read:

#! /usr/bin/perl -w -I./.

This should get your grabbers working again.

Configuration

Main Weather Settings screen
All configuration of MythWeather is done through the frontend. For global configuration of the plugin, go to the Utilities/Setup→Setup→Info Center Settings→Weather Settings page.


Global Settings

Global settings page

There are four options to configure on this page:

  1. Seconds to display each page
    • Defines how long each page will be displayed before moving onto the next
  2. Seconds to display each page after manual page change
    • If you happen to move between pages manually (using the left and right arrows) this kicks in. A manual page change will be displayed by this many seconds before resuming the regular rotation
  3. Retrieve data in the background
    • If this is enabled, mythfrontend will automatically download new weather data in the background. This improves the startup time of MythWeather drastically, since it no longer will wait for the initial data retrieval. The grabber scripts run with nice, so you shouldn't notice anything while watching TV.
  4. Skip pages still waiting for data (Not Implemented)
    • As the page itself indicates, this feature isn't done yet. However, when it is, the plugin will not display pages that have no data.

Screen Settings

The Screen Settings page allows you to define all of the screens that you want displayed while the plugin is running. You can mix and match screens to your heart's delight. Refer to these screen shots while reading on:

Screens

The page allows you to choose from a list of Inactive Screens. By selecting one of these items in the list, it will be copied into the Active Screens list.

There are currently seven different types of screens available:

  1. Current Conditions
    • This screen displays the most recent observations of weather.
  2. 18 Hour Forecast
    • Displays a weather forecast of conditions and temperature for the next eighteen hours.
  3. Three Day Forecast
    • Displays a weather forecast of conditions and temperature for the next three days.
  4. Six Day Forecast
    • Displays a weather forecast of conditions and temperature for the next six days.
  5. Static Map
    • Displays a static map image for the configured location.
  6. Animated Map
    • Displays an animated map (radar, satellite imagery, etc.)
  7. Severe Weather Alerts
    • Displays text warnings about severe weather in the configured location.

Actions

Once in the Active Screens list, you can modify the properties of the screen by selecting it. Some screens have more actions than others, depending on what they do. For example, the Animated Maps screen doesn't use Units, so you don't have an option to change them.

The actions you can perform on Active Screens include:

  1. Change Location
    • Allows you to change the location for the selected screen. Selecting this action will prompt you to search for a new location. You can enter text into the search field with your keyboard, or using the pop-up keyboard and your remote control. Searching can usually be done with regular expressions as well.
  2. Change Units
    • Allows you to toggle between SI and English units. (SI is metric, English is... well, English).
  3. Move Up
    • Moves the selected screen up one position in the Active Screens list.
  4. Move Down
    • Moves the selected screen down one position in the Active Screens list.
  5. Remove
    • Deletes the selected screen from the Active Screens list.
  6. Cancel
    • Returns you to Screen Setup.

Saving Your Changes

Don't forget to click on the Finish button on the Screen Setup page when you're done! This will save all of your screen definitions and return you to the main Weather Settings page.

Source Settings

Change settings for each configured weather source

This screen allows you to customize the settings for each weather source you have defined. The Source Setup screen will only display the sources that you are using for your configured Active Screens.

For each of theses sources, you can configure two options:

  1. Source Update Timeout (seconds)
    • Defines how long the plugin will wait for this source to provide data (in seconds)
  2. Data Retrieval Interval (minutes)
    • Defines how long the plugin will wait between subsequent data downloads (in minutes)

The Source Setup screen is also nice enough to provide you the credits of who wrote your configured weather source grabber and it's current version.

Note: Some grabbers will locally cache their downloaded data to limit the effect on the servers they use as a source.

Using MythWeather

Once configured, using MythWeather requires little brain-power. When the plugin is started it will begin cycling through the screens. If you wish to pause on a screen press PAUSE (p). If you wish to manually move between pages, use the left and right arrows. If you wish to manually initiate an update, press 'u'. Thats about it, to exit press EXIT (escape).

Here are some screen shots of the different screens in action:


Sources

Sources are external programs which retrieve weather data. They can be found in the scripts/ directory of the MythWeather source tree, when installed they are in <prefix>/share/mythtv/mythweather/scripts/ where prefix is usually /usr. If you are interested in how the sources interact with the plugin there is a README in the scripts/ directory. Below is a list of sources currently included with MythWeather. If you write a source feel free to provide a link to it here.

World

These sources cover the globe. If you can't find a local provider of weather data, use these instead.

BBC Weather Centre

  • http://www.bbc.co.uk/weather/
  • Files: bbccurrentxml.pl BBCLocation.pm bbcthreedayxml.pl
  • These two scripts provide forecast data for Current Conditions and Three Day Forecasts for almost any major city in the world. More detailed information is available for UK cities and towns.

Accuweather

United States

These sources are all for locations in the United States.

  • "Animated maps and most (if not all) of the static ones aren't listed by zip/city. Leave the search box blank and search for everything. You'll get a list of stuff by region of the US. Pick your region of the US from the search results. Took me a while to figure that one out. :)" via Brad DerManouelian

National Weather Service Current Observations XML Feeds

  • http://www.weather.gov/data/current_obs/
  • Files: nwsxml.pl, NWS-Stations.xml, icons, NWSLocation.pm
  • This script uses XML feeds provided by the National Weather Service for current observations. The NWS-Stations.xml file describes the locations supported by this script. You can also browse the above link to see avaiable locations. Locations can be searched for by their station id, station name, or state abbreviation. Searches are done using the search string as a perl regular expression. NWS updates their observations hourly

National Digital Forecast Database XML/SOAP Service

  • http://www.weather.gov/xml
  • Files: ndfd.pl, ndfd18.pl, NDFDParser.pm, NWSLocation.pm ndfdXML.pm, icons, NWS-Stations.xml
  • Accesses the National Weather Services XML/SOAP forecast information to give data up to 6 days in advance. It uses the same NWS-Stations.xml file and location search mechanism as the current observations script, however, since NDFD works on lat/lon

National Weather Service's CAP/XML (Common Alert Protocol) Severe Weather Alert Service

Weather.com's Map Room (both static and animated images)

  • http://www.weather.com/maps/
  • Files: maps.pl, animaps.pl, MapSearch.pm, maps.xml weathercommaps.pl (in dir above scripts/)
  • This script downloads and static and animated maps from weather.com. weathercommaps.pl was used to crawl weather.com's map room and generate the maps.xml file, which is then used for the static map source (maps.pl) and the animated map source (animaps.pl). Location searches look at the map name, so you'll probably want to search for things like "radar", "doppler", "northeast", etc... Maps from other sites can be added easily, just follow the format in maps.xml.

Canada

These sources are for locations in Canada.

Environment Canada's Weather Office

  • http://www.weatheroffice.gc.ca/
  • Files: envcan.pl ENVCANParser.pm ENVCANLocation.pm ENVCAN-Stations.xml
  • This script downloads XML RSS feeds from Environment Canada's Weather Office site. Location searches are powered by the ENVCAN-Stations.xml file, which contains a list of all defined Canadian sites. When searching, simply look for the city or town that you're closest to.


Environment Canada's Satellite Imagery

  • http://www.weatheroffice.gc.ca/satellite
  • Files: envcan_animaps.pl ENVCANMapSearch.pm ENVCAN-Maps.xml
  • This script downloads animated map images from Environment Canada's Satellite Imagery service. The locations are all named after the regions the images cover. So, search for stuff like 'Western' or 'Eastern' to get the best results. If in doubt, take a look at the ENVCAN-Maps.xml file... it defines all of the animated maps.

Australia

You can use the weather.com settings or BOM for Australia. weather.com is the default.

BOM

It works for a three day listing but I cannot get the animated maps working yet.

The link above has not been accessible for some time now.

The scripts have been updated and now work with version 0.27, see information at

https://sites.google.com/site/mygeekytechbits/home/mythtv

More Questions

If there is a problem with this page, feel free to fix it. Questions about using MythWeather should be directed to the mythtv-users mailing list or #mythtv-users on freenode. Issues or bugs with the code should be directed to the mythtv-dev mailing list or #mythtv channel.