Ticket #8236: interface.wiki

File interface.wiki, 11.5 KB (added by Alec leamas <leamas.alec.%alfa%.gmail.com>, 16 years ago)
Line 
1= Mythweather grabber interface =
2
3== General ==
4
5MythWeather has six different types of pages. Grabbers are categorized into these types by the data they specify as capable of providing. Grabbers can seamlessly provide data for multiple pages by making sure to meet all the requirements for each.
6
7The program flows roughly like:
8
9 * myth scans the script directories for executable files. To each
10 of them myth issues the -v command. The grabber replies with
11 a version number (+ additional info). If the version is
12 unchanged, myth uses already present data in the database.
13 Otherwise:
14 * myth issues -t command. The grabber lists what kind of data it
15 provides. If the list is enough to meet the requirements for one
16 or more pages, myth will use it for these.
17 * myth issues -T command. Grabber replies with
18 data_timeout(min),http timeout(seconds) e. g., '3600,20'.
19 * User sets up a page using the mythfrontend setup tool. Eventually,
20 she has to search for available data for a specific place. When
21 doing so, myth issues -l <search string > command. The grabber
22 replies with a list of possible places matching the user search
23 string.
24 * Myth presents all matches it has got from all grabbers, user
25 selects one of them.
26 * From this point, myth issues -u <units> -d /dir <location> commands
27 to fill the screen. Grabber replies with lines of data.
28
29== Commands ==
30
31In the examples here, the grabber is named 'grabber'. In reality it has
32any name. The examples follows the cycle for a map provider. Other
33providers works in the same way, but with much longer parameter lists.
34
35Unless stated otherwise, everything is ascii.
36
37=== grabber -v ===
38
39Example:
40{{{
41$ ./grabber -v
42Wunderground,0.5,Alec Leamas,nowhere@gmail.com
43}}}
44
45The reply is four, ','separated items:id,version,author,email.
46The id (Wunderground) is used to identify the data source.
47The version string is tested for equality, as long as it doesn't change myth
48uses data about grabber already in database. The rest is used for
49administrative purposes.
50
51=== grabber -T ===
52
53Example:
54{{{
55$ ./grabber -T
56180,20
57}}}
58
59The reply is data_timeout,http_timeout. The data timeout governs how long
60it takes for the data provided by this grabber to expire (minutes), and thus
61needs a reload. The http timout describes how long myth should wait for
62reply before giving up(seconds,TBD).
63
64=== grabber -t ===
65
66Example:
67{{{
68$ ./grabber -t
69amdesc
70animatedimage
71copyright
72updatetime
73}}}
74
75This command lists the data provided by this grabber.To be meaningful,
76the reply must list at least all items for one of the screens.
77Many grabbers lists items for two or more screens e. g., the complete list
78required for a 3-day and 6-day forecast.
79
80=== grabber -l <search string> ===
81
82Example:
83{{{
84$ ./grabber -l norway
85western_norway::Western Norway radar map animation
86central_norway::Central Norway radar map animation
87nordland_troms::Nordland-Troms radar map animation
88troms_finnmark::Troms-Finnmark radar map animation
89southwest_norway::Southwest Norway radar map animation
90}}}
91
92The reply is zero or more lines matching the <search string>. Each
93line is formatted like 'id::label'. The id is used when retrieving data,
94the label is used in the ui to show the location.
95
96The label might contain non-ascii data. The id is ascii.
97
98=== grabber -u <SI|ENG> -d /somewhere <location id> ===
99
100Example:
101{{{
102$ ./grabber -u SI -d /tmp western_norway
103amdesc::Western Norway
104animatedimage::/tmp/mythweather_yr/anim_dir/animation-%1-9-800x1002
105copyright::Copyright (C) 2008 The Norwegian Meteorological Institute.
106updatetime::2010-03-28T10:42:45Z
107}}}
108
109The <location id> is the id provided by -l. The -d command is a writeable
110directory, always the same. This is typically used for caching. The -u
111flag determines whether the reply should use SI units or English (well,
112American) units.
113
114The reply is one line for each item listed by -t. Each line is formatted
115like 'id::value', where <id> is the the id listed by -t, and the value
116the actual value. Values are in some cases non-ascii. For encoding of value,
117read on.
118
119== Data representation ==
120
121All data is printable. General types:
122
123float::
124 A numeric value, which could be parsed directly as a float. It
125 should not contain any unit information, just a plain number.
126 A missing or undefined value is represented as 'NA'
127
128string::
129 An ascii string, possibly 'NA' representing undefined/non-existing
130 value.
131
132i18nstring::
133 String holding non-ascii data, character encoding TBD.
134
135date::
136 One of Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday
137
138time::
139 Time of day, 12-hour clock e. g., '3 PM'.
140
141updatetime::
142 ISO time stamp, like '2010-02-21T12:34:33Z', representing a
143 best-effort date when the data was created.TBD
144
145icon::
146 Ascii string naming of a mythtv weather icon, as used in the file
147 weather_types
148
149map::
150 A static map is an image, which is downloaded to a local file by the
151 grabber. The map is a string like /dir1/dir2/filename-600x800. This
152 represents a local file /dir1/dir2/filename with an image sized
153 600x800. The '-600x800' suffix is not mandatory, if missing the image
154 will be expanded to fill the window.
155
156animation::
157 An animation is typically downloaded as a single file. The grabber
158 splits it into separate files which are stored locally. These files
159 are represented by a single animation string like
160 /dir1/dir2/filename-%1-6-800x600.
161
162 The %1 part is replaced with a unique number for each file. So with
163 animation like above there will be files like filename-0,
164 filename-1 etc.
165
166 The '6' digit is the number of files. For this example, there will be
167 6 files named filename-0..filename-5
168
169 The last part is the image size (width x height).
170
171 Bottom line: an animation like filename-%1-4-800x600 represents an
172 animation with four frames named filename-0..filename-3 sized 800x600.
173
174== Valid data types ==
175
176In this list, only the SI variant is listed; ENG values are TBD.
177
178=== Static map screen ===
179
180|| smdesc || i18nstring || ||
181|| map || map || ||
182|| copyright || i18nstring || Copyright clause for data provider. ||
183|| updatetime || updatetime || ||
184
185See: StaticImageScreen::prepareDataItem
186
187=== Dynamic map screen ===
188
189|| amdesc || i18nstring || ||
190|| copyright || i18nstring || Copyright clause for data provider. ||
191|| updatetime || updatetime || ||
192|| animatedimage || animation || ||
193
194See: AnimatedImageScreen::prepareDataItem
195
196=== Observation (current conditions) data ===
197
198|| cclocation || i18nstring || Descriptive string ||
199|| station_id || string || The string given to myth to identify the station. ||
200|| copyright || i18nstring || ||
201|| observation_time || iso date|| ||
202|| weather || string || Weather conditions, free text ||
203|| temp || float || Current temp, Celsius ||
204|| relative_humidity|| float || percent ||
205|| wind_dir || string || string like 'NNW', 'S' etc. ||
206|| wind_degrees || float || wind direction, 0 <= d < 360 ||
207|| pressure || float || mb ||
208|| dewpoint || float || Celsius, x < temp ||
209|| visibility || float || km, typically 1-10, less in fog. ||
210|| weather_icon || icon || ||
211|| wind_speed || float || Average wind speed, m/s ||
212|| wind_gust || float || *Max wind speed. Legacy: wind_spdgst. TBD ||
213|| appt || float || Apparent temperature, heat index and windchill combo ||
214|| windchill || float || Celsius, See TBD ||
215
216See: WeatherScreen::formatDataItem
217
218=== 18 hour forecast data ===
219
220The temp, 18icon,time and pop values have suffixes to provide 6 three-hours
221values: temp-0, temp-2..temp-5, 18icon-0..18icon-5 etc.
222
223|| 18hrlocation || i18nstring || descriptive string ||
224|| temp || float || Current temp, Celsius ||
225|| 18icon || icon || ||
226|| time || time || ||
227|| precipitation || float || *Anticipated precipitation (mm)TBD ||
228|| pop || float || Probability of precipitation(percent) ||
229|| updatetime || updatetime || Last forecast update, best effort. ||
230
231=== 3 days forecast ===
232
233The high, low, date and icon values have suffixes to provide data for
234three days: high-0, high-1, high-2, low-0..low-2 etc.
235
236|| 3dlocation || i18nstring || descriptive string ||
237|| high || float || Max day temp, high-0..high2 ||
238|| low || float || Lowest day temp, low-0..low-2 ||
239|| date || date || Date string, date-0..date-2 ||
240|| icon || icon || Day's icon, icon-0..icon-2 ||
241|| copyright || i18nstring || ||
242|| updatetime || updatetime || last forecast update, best effort. ||
243
244=== 6 days forecast ===
245
246The high, low, date and icon values have suffixes to provide data for
247six days: high-0, high-5, low-0..low-5 etc.
248
249|| 6dlocation || i18nstring || Descriptive string ||
250|| high || float || Max day temp, high-0..high-5 ||
251|| low || float || Lowest day temp, low-0..low-5 ||
252|| date || date || Date string, date-0..date-5 ||
253|| icon || icon || Day's icon, icon-0..icon-5 ||
254|| copyright || i18nstring || ||
255|| updatetime || updatetime || Last forecast update, best effort. ||
256
257== Known issues ==
258
259* Image paths are cut on first '-', even in directory parts like
260 /tmp/spool-al/cache/image.gif. Avoid directories with a '-' FTM.
261* Unclear character encoding of i18nstring. Practically, I have used latin-1
262 successfully but YMMV.
263* The ui presents the parameter wind_spdgst as 'wind (gust)'. This is
264 problematic, partly because many stations only provide wind_speed and
265 not wind_gust. Besides, the 'wind_spdgst' is the only parameter which not
266 is used by the weather stations; the use 'wind_gust'.
267* The ui presents the probablity of precipitation, pop. Many forecasts don't
268 compute pop, but instead provides the anticipated amount of precipitation
269 in mm. It's possible for grabbers to send the precipitation data in the
270 'pop' data item, but the ui still uses 'pop' and '%' which is plain wrong.
271* The -d option is not provided to all commands although it really should,
272 both practically and according to the docs.
273
274== References ==
275
276appt::
277 http://ams.confex.com/ams/pdfpapers/156484.pdf, pg 2-3
278
279heat index::
280 http://en.wikipedia.org/wiki/Heat_index
281
282windchill::
283 http://en.wikipedia.org/wiki/Windchill
284
285wind gust::
286 http://www.erh.noaa.gov/images/afi/windgust.html
287
288
289
290
291
292
293