Weather addons

From Official Kodi Wiki
Revision as of 02:01, 4 December 2016 by Ronie (talk | contribs)
Jump to navigation Jump to search

addon.xml

Weather addons use the 'xbmc.python.weather' extension point. The basic layout of the addon.xml of a weather addon will look like:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="weather.name" name="My Weather" version="1.2.3" provider-name="me">
	<requires>
		<import addon="xbmc.python" version=""/>
	</requires>
	<extension point="xbmc.python.weather" library=""/>
	<extension point="xbmc.addon.metadata">
		<summary lang="en"></summary>
		<description lang="en"></description>
		<language></language>
		<platform></platform>
		<license></license>
		<forum></forum>
		<website></website>
		<email></email>
		<source></source>
	</extension>
</addon>


Things you need to know!

There's a few things (quirks) you need to be aware of when creating a weather addon...

  • Kodi will automatically run a weather addon when the skins asks to display one of the weather specific infolabels
  • Weather.Conditions
  • Weather.Temperature
  • Weather.Location
  • Kodi will run the weather addon at a 30 min interval (as long the current skin window displays one of the specific weather infolabels mentioned before)
  • In the weather window, kodi will automatically try to translate all the weather strings
  • Kodi will also handle transformations between units (for instance, Celsius to Fahrenheit, km/h to mph)


How Kodi runs a weather addon

Kodi can run a weather addon in two modes

Setup a weather location in the weather addon settings

In order to set up a weather addon, you need to include a settings.xml file for your weather addon. It needs to have this structure:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
	<category>
		<setting id="Location1" label="Location 1" type="action" action="RunScript($ID,Loc1)" default=""/>
		<setting id="Location2" label="Location 2" type="action" action="RunScript($ID,Loc2)" enable="!eq(-1,)" default=""/>
		<setting id="Location3" label="Location 3" type="action" action="RunScript($ID,Loc3)" enable="!eq(-1,)" default=""/>
		<setting id="Location4" label="Location 4" type="action" action="RunScript($ID,Loc4)" enable="!eq(-1,)" default=""/>
		<setting id="Location5" label="Location 5" type="action" action="RunScript($ID,Loc5)" enable="!eq(-1,)" default=""/>
	</category>
</settings>

You can define as much weather locations as you want in your settings.xml file.

When you're going to set up a location in the weather addon settings, Kodi will pass the argument you've defined in the RunScript() action above to your addon. For instance, if you select to 'Location 2' setting, Kodi will pass 'Loc2' to your addon.


Retrieve weather for a location

When weather information needs to be retrieved, Kodi will pass the location number to your addon. For instance, if the weather for Location 4 is requested, Kodi will pass '4' to the weather addon.


Info a weather addon needs to return

lots


Weather Codes

Kodi ships with an icon pack that includes an icon for each weather condition.
(https://github.com/xbmc/xbmc/tree/master/addons/resource.images.weathericons.default)
Several additional weather icon packs are available through the official Kodi repository.

The following condition-code table is used for the icon names:

0 	tornado
1 	tropical storm
2 	hurricane
3 	severe thunderstorms
4 	thunderstorms
5 	mixed rain and snow
6 	mixed rain and sleet
7 	mixed snow and sleet
8 	freezing drizzle
9 	drizzle
10 	freezing rain
11 	showers
12 	showers
13 	snow flurries
14 	light snow showers
15 	blowing snow
16 	snow
17 	hail
18 	sleet
19 	dust
20 	foggy
21 	haze
22 	smoky
23 	blustery
24 	windy
25 	cold
26 	cloudy
27 	mostly cloudy (night)
28 	mostly cloudy (day)
29 	partly cloudy (night)
30 	partly cloudy (day)
31 	clear (night)
32 	sunny
33 	fair (night)
34 	fair (day)
35 	mixed rain and hail
36 	hot
37 	isolated thunderstorms
38 	scattered thunderstorms
39 	scattered thunderstorms
40 	scattered showers
41 	heavy snow
42 	scattered snow showers
43 	heavy snow
44 	partly cloudy
45 	thundershowers
46 	snow showers
47 	isolated thundershowers
na 	not available