use custom states from a ghost xml device

Posted on
Sat Jul 17, 2021 5:03 pm
Monstergerm offline
Posts: 274
Joined: Sep 01, 2009

Re: use custom states from a ghost xml device

Hi Dave,
so here is something weird. If I refresh my stock quote ghostxml device using a python script it takes about 2 seconds for the device "Last update date" to change.

If I however add a delay of 10 seconds in the python script AFTER the device refresh code line, the device "Last update date" does not change for 10 seconds but then shows again a date that is 2 seconds after I ran the script. Hope this is clear. So it looks like the Indigo interface does not update the date for 10 seconds and if I grab the "Last update date" during this time it still shows the old date. Only after the script finishes, everything gets properly updated with the correct times.

Now, I am not even sure anymore that adding a delay will help me getting updated data for my variables.

Posted on
Sat Jul 17, 2021 5:59 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: use custom states from a ghost xml device

If you're doing a sleep() call in the middle of an embedded Python script, you're locking up the entire Indigo server until after the script ends. So the variables can't be updated during the script.

Just do the initial GhostXML call in the script, then do the rest in a trigger on the device state changing.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sat Jul 17, 2021 6:08 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: use custom states from a ghost xml device

That's not necessarily strange in so far as Indigo may just be waiting to update the UI with the latest information.

I think Joe's suggestion might be the safest bet. Fire an update on your time table and then trigger on when the device Last Update value changes.

EDIT: Jinx. Buy me a Coke.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Jul 02, 2022 12:03 pm
gskarp offline
Posts: 141
Joined: Apr 19, 2012

Re: use custom states from a ghost xml device

How would we trap for a custom state that is not always in the feed.? In the Open Weather feed, the rain forecast shows up occasionally. I would like to capture that number whenever it happens. Is there a way to run a script that ignores that state if is does not exist?

Posted on
Sat Jul 02, 2022 12:41 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: use custom states from a ghost xml device

Absolutely. In Python, you can account for a missing dictionary key with 'get':

Code: Select all
x = my_dict.get('key', "default value if key doesn't exist")

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Who is online

Users browsing this forum: No registered users and 2 guests