[Solved] - How to auto refreshing label variable in home screen?
#1
Question 
Hi,

I'm trying to display the outdoor temperature in Kodi home screen.
So far that works, but I want it to auto refresh every 5 minutes or lets say every minute to follow the clock.

Here's how I have done it.

outdoor.xml (This file is being updated every 5 minutes.)

PHP Code:
<?xml version="1.0" encoding="UTF-8"?>
<includes>
    <variable name="outdoor">
        <value>1,0</value>
    </variable>
</includes> 


Home.xml

PHP Code:
...

<
control type="label">
    <
description>outdoor</description>
    <
posx>20r</posx>
    <
posy>60</posy>
    <
width>200</width>
    <
height>15</height>
    <
align>right</align>
    <
aligny>center</aligny>
    <
font>font10</font>
    <
textcolor>white</textcolor>
    <
shadowcolor>black</shadowcolor>
    <
label>Outdoor$VAR[outdoor°C</label>
    <include>
Window_OpenClose_Animation</include>
    <
animation effect="slide" start="0,0" end="-40,0" time="100" condition="Window.IsVisible(Mutebug)">conditional</animation>
</
control>

... 

The problem is that the only way to refresh the $VAR is to reboot Tongue

Any help would be very much appreciated!

/Patric
Reply
#2
well, it won't work like that.
Kodi only reads all xml files once, at startup.

instead, you'd need to create a python script
and have the script periodically update a window property.

script part:
Code:
xbmcgui.Window(10000).setProperty('outdoor', '1,0')

skin part:
Code:
<label>Outdoor: $INFO[Window(Home).Property(outdoor)] °C</label>
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#3
(2015-01-21, 02:17)ronie Wrote: well, it won't work like that.
Kodi only reads all xml files once, at startup.

instead, you'd need to create a python script
and have the script periodically update a window property.

script part:
Code:
xbmcgui.Window(10000).setProperty('outdoor', '1,0')

skin part:
Code:
<label>Outdoor: $INFO[Window(Home).Property(outdoor)] °C</label>

Thanks a lot!

I will try to figure how to do that Wink
Reply
#4
Ok, so I managed to do it my dirty way. I don't have any education in programming so I tend to find my own ways of achieving my goal Smile

This is my temperature python script that is being generated every 5 minutes by wget'ing a php script at my temp monitoring server.

PHP Code:
import xbmcxbmcgui
HOME 
xbmcgui.Window(10000)
xbmcgui.Window(10000).setProperty('Inne''22,6')
xbmcgui.Window(10000).setProperty('Ute''1,3'

My Home.xml
PHP Code:
<control type="label">
            <
description>Inne</description>
            <
posx>20r</posx>
            <
posy>60</posy>
            <
width>200</width>
            <
height>15</height>
            <
align>right</align>
            <
aligny>center</aligny>
            <
font>font12</font>
            <
textcolor>white</textcolor>
            <
shadowcolor>black</shadowcolor>
            <
label>Inne$INFO[Window(Home).Property(Inne)] °C</label>
            <include>
Window_OpenClose_Animation</include>
            <
animation effect="slide" start="0,0" end="-40,0" time="100" condition="Window.IsVisible(Mutebug)">conditional</animation>
        </
control>
        <
control type="label">
            <
description>Ute</description>
            <
posx>20r</posx>
            <
posy>75</posy>
            <
width>200</width>
            <
height>15</height>
            <
align>right</align>
            <
aligny>center</aligny>
            <
font>font12</font>
            <
textcolor>white</textcolor>
            <
shadowcolor>black</shadowcolor>
            <
label>Ute$INFO[Window(Home).Property(Ute)] °C</label>
            <include>
Window_OpenClose_Animation</include>
            <
animation effect="slide" start="0,0" end="-40,0" time="100" condition="Window.IsVisible(Mutebug)">conditional</animation>
        </
control

Now to find a way to execute the python script I linked it to the yellow button at my remote.
The script runs and the values are updated as well.... But how can I run this script every 5 minutes?

I was hoping a cronjob would do it but obviously that doesn't work since only kodi can handle this because of the "imports"...

EDIT: After a lot of reading I found a method that allowed me to use cronjob for the update task.

PHP Code:
*/* * * * kodi-send --action="XBMC.RunScript(/storage/scripts/temp.py)" >/dev/null 2>&

Only "problem" now is that the screen saver inactivates when the command is sent Big Grin

If anyone has another (better) method that I should use instead, please let me know.
Reply
#5
Put something like the following in startup.xml or home.xml

<onload>Alarmclock(RefreshTemp,RunScript(/storage/scripts/temp.py),05:00,silent,loop)</onload>
Image [RELEASE] Metroid
Image [RELEASE] IrcChat
Reply
#6
That would work although I'd just wrap the thing into a service addon and make it less hacky. It would be pretty simple, just update that property, sleep for 5 minutes, and repeat until xbmc is shutdown.
Reply
#7
Service_addons (wiki)
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#8
(2015-01-21, 20:24)MassIV Wrote: Put something like the following in startup.xml or home.xml

<onload>Alarmclock(RefreshTemp,RunScript(/storage/scripts/temp.py),05:00,silent,loop)</onload>

Thanks a lot!

That worked really well. Wink

(2015-01-21, 21:00)robweber Wrote: That would work although I'd just wrap the thing into a service addon and make it less hacky. It would be pretty simple, just update that property, sleep for 5 minutes, and repeat until xbmc is shutdown.

Oh, I found your thread now when you mentioned "service addon". I didn't know there was an addon like that util now... Blush
I figured the only way to do this was by hacking. Cool

I will for sure look into to your addon.
Reply
#9
(2015-01-21, 22:01)ronie Wrote: Service_addons (wiki)

Thanks!

It looks like I have to do something like that because my logs are filling up with this:

PHP Code:
10:17:03 261.442749 T:2667086912  NOTICE: -->Python Interpreter Initialized<--
10:17:03 261.443298 T:2667086912 WARNINGCPythonInvoker(2): Script invoked without an addonAdding all addon modules installed to python path as fallbackThis behaviour will be removed in future version
Reply

Logout Mark Read Team Forum Stats Members Help
[Solved] - How to auto refreshing label variable in home screen?0