Kodi Community Forum

Full Version: Basic add-on to update information on the home screen
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to display some information on the homescreen (next to the weather), and update it periodically.

Context: I have plenty of programming experience, but zero XBMC knowledge and I need some help architecting my solution. I'm using Frodo/Confluence.

I want to show how much data I can download before I hit my ISPs monthly throttling limit: information that I'll need to scrape from my account page on their website.

Can I achieve this with just a scraper?

If not, I guess I'm making an add-on - but should this add-on be a plugin or a script? If it's a plugin, what media type should it be? If it's a script, is it a service or a module?

It most closely fits the plugin/weather paradigm, but of course it's not weather data that I'm dealing with.

I think I can define and set custom InfoLabels from my add-on, but what triggers my add-on to run? Should I collect the required data in an external script (& cronjob) and pass it to my add-on via the JSON-RPC API?
Welcome to the XBMC forums.

I'm no programmer, but a quick-and-dirty option may be to have a cronjob or daemon that periodically scrapes that usage data and places it in an XML file. You could then use the RSS ticker that scrolls along the bottom of the homepage to display this local "newsfeed" file. You can set the refresh interval of the RSS ticker so that it coincides with the frequency of the usage data refresh job.
You can do it all from an add-on, if you like.

Add-on type: script, media type name: service(a script that will be run at either login or startup)

I like the RSS ticker idea otherwise you'll have to do some skinning modifications and/or make a skin for your add-on.
Thanks for the pointers - very useful.

If I make a script/service, will it only update the home screen every time I restart XBMC?
You can use a 'while' loop that keeps the service running. Something like -
Code:
while not xbmc.abortRequest:
    # run some code
    get_data()
    # sleep 10 seconds
    xbmc.sleep(10000)
Thanks divingmule

I now have an addon up and running. My addon.xml presents an executable and a 'service' version. They are identical except that the service version is inside the while / sleep loop that you describe. The executable version allows me do a manual refresh, while the service polls every 2hrs.

I have a few remaining questions now;

a) When I run the executable version, it works fine, but it pops up a black modal window with no contents. I can just press 'back' on my remote and it goes away, but it's irritating. Is there a way to prevent this window appearing?

b) Secondly, I'd prefer to minimise the number of times the screenscraper runs. The service runs the screenscraper every 2 hrs, but most of the day I'm at work or asleep. So 90% of those scrapes are wasted. Can I skip the scraping when the screensaver is on? Can I capture a "HOME_SCREEN_ACTIVATED" event and only scrape then?! How do weather addons handle it? I'm sure they aren't scraping all the time?

c) To get my info on screen, I added a new control to Home.xml of the confluence skin that I'm using. I'm assuming this ins't the right way to do things? I'm assuming my addon should create and add the label control to the home screen programmatically?

Thanks for the advice.
b) You might do something with xbmcgui.getCurrentWindowId -> http://mirrors.xbmc.org/docs/python-docs...ntWindowId

Hopefully others will jump in here as my skinning knowledge isn't much. It may help if you paste or pastebin your code.