Page 2 of 3

Re: use custom states from a ghost xml device

PostPosted: Sat Dec 07, 2019 10:08 am
by howartp
Exception handling?

What is this phrase of which you speak?




Sent from my iPhone using Tapatalk Pro

Re: use custom states from a ghost xml device

PostPosted: Sat Dec 07, 2019 12:27 pm
by matt (support)
DaveL17 wrote:
I'm still working on getting a matplotlib plugin bug fix tested (hang in there Bert!) but my initial suspicion is that many of the Alpha Vantage keys start with a character or series of characters that Indigo doesn't like.

Indigo Dicts do have some additional restrictions compared to native python dicts. See this forum post for the details (including restrictions on key naming).

Re: use custom states from a ghost xml device

PostPosted: Sat Dec 07, 2019 12:35 pm
by howartp
Keys cannot start with a number....

That would be the problem then....


Sent from my iPhone using Tapatalk Pro

Re: use custom states from a ghost xml device

PostPosted: Sat Dec 07, 2019 1:14 pm
by wideglidejrp
Looks like AV not Indigo compliant in two ways: starts with a number AND has a space....

"Meta Data": {
"1. Information": "Intraday (5min) open, high, low, close prices and volume",
"2. Symbol": "UBER",
"3. Last Refreshed": "2019-12-06 16:00:00",
"4. Interval": "5min",
"5. Output Size": "Compact",
"6. Time Zone": "US/Eastern"
},
"2019-12-06 15:55:00": {
"1. open": "27.9062",
"2. high": "27.9569",
"3. low": "27.8868",
"4. close": "27.9312",
"5. volume": "735363"

Re: use custom states from a ghost xml device

PostPosted: Sat Dec 07, 2019 1:31 pm
by howartp
The plugin deals with spaces already, I saw that earlier in the code.


Sent from my iPhone using Tapatalk Pro

Re: use custom states from a ghost xml device

PostPosted: Sat Dec 07, 2019 2:55 pm
by howartp
Right, it's not the numbers or the nesting causing the problem.

However, once the plugin has got stuck, if you edit the device, Indigo throws an error:

Error (client) _setCurrentPluginDeviceType() caught exception: LowLevelBadParameterError -- illegal character in XML tag name or value


So I played about with a local copy of the JSON.

If you remove the colon symbol, it allows the plugin to 'finish' and display "Updated" - but the states don't appear, and the errror above still occurs.

So you also need to remove the decimal point symbol, which allows the states to appear and the plugin to work correctly.

Dave, line 818 just needs : and . adding to the chars_to_replace dictionary.

However be aware that as the state names are so long ("Time_Series_5min_2019_minus_12_minus_06_15_55_00_5__volume"), you can't actually see the value of the state in the UI. (You can in control pages etc)

Peter

Re: use custom states from a ghost xml device

PostPosted: Sat Dec 07, 2019 4:02 pm
by DaveL17
Peter -- a quick check confirms that the changes seem to work. I'll get something pulled together and push an update. Thank you!

John -- your quest will result in the plugin being even better, so thank you for that.

FYI -- If you hover over a custom state, a help bubble will display both the full name and the state value. I suspect there may be a character limit.

Re: use custom states from a ghost xml device

PostPosted: Sat Dec 07, 2019 5:09 pm
by DaveL17
I have posted an update to the plugin that should work with the Alpha Vantage API.

https://forums.indigodomo.com/viewtopic.php?f=249&t=18109#p175629

Re: use custom states from a ghost xml device

PostPosted: Sat Dec 07, 2019 5:47 pm
by wideglidejrp
Great! Works perfectly. Now that I see how things work, I realize I picked the wrong query for what I am trying to do. When I figure out the right one to use, I am sure the plugin will work. Thanks very much for developing this.

Re: use custom states from a ghost xml device

PostPosted: Sat Dec 07, 2019 7:53 pm
by DaveL17
Good deal. Glad to hear that the update is working for you.

Re: use custom states from a ghost xml device

PostPosted: Mon Dec 09, 2019 11:12 am
by wideglidejrp
Thanks for this great plugin. I would like to share how I am using it. Still experimenting, but it is working really well. Between the NYSE hours of 9:30 to 4:00, the plugin grabs the latest price of UBER stock using an Alpha Vantage JSON API. If the price is higher than the opening price, the Aeotec LED strip turns green across the top of my office ceiling. If the price falls below the opening price, the strip turns red. The possibilities of using the real-time data from Alpha Vantage are endless.

Re: use custom states from a ghost xml device

PostPosted: Mon Dec 09, 2019 3:40 pm
by DaveL17
Check that out. That's awesome! Thanks for sharing John.

Re: use custom states from a ghost xml device

PostPosted: Fri Jul 16, 2021 6:48 pm
by Monstergerm
I am looking for a solution to this problem. I have GhostXML devices that download information from an URL path, e.g. stock quotes.

The GhostXML devices are manually updated (plugin.executeAction("refresh_data_for_dev", deviceId = 10105275) through a python script and after a delay of 2 sec the script continues to grab individual device Custom States and puts them into variables etc.

Sometimes the device update (URL download) takes more than 2 sec and therefore the script grabs old, outdated device states. Is there an elegant solution to check whether states have indeed been updated and if not add more time delay before the script continues?

Re: use custom states from a ghost xml device

PostPosted: Fri Jul 16, 2021 7:14 pm
by DaveL17
Two seconds is pretty quick, and I can't guarantee that the device -- including all its custom states -- will be fully updated in that amount of time. But if I recall correctly, the dev.lastChanged value doesn't get updated until the parsing is complete. You could read the dev.lastChanged value, update the device, and then read the value again (comparing the difference). I'm not in the position to do a full test right now, so this is (at least partially) a guess. :D

Re: use custom states from a ghost xml device

PostPosted: Sat Jul 17, 2021 3:28 am
by FlyingDiver
Better option would be to do the GhostXML call, and have a separate trigger on the lastChanged state changing, and using that to copy the data to the variables.