use custom states from a ghost xml device

Posted on
Sat Dec 07, 2019 10:08 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: use custom states from a ghost xml device

Exception handling?

What is this phrase of which you speak?




Sent from my iPhone using Tapatalk Pro

Posted on
Sat Dec 07, 2019 12:27 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: use custom states from a ghost xml device

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).

Image

Posted on
Sat Dec 07, 2019 12:35 pm
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: use custom states from a ghost xml device

Keys cannot start with a number....

That would be the problem then....


Sent from my iPhone using Tapatalk Pro

Posted on
Sat Dec 07, 2019 1:14 pm
wideglidejrp offline
User avatar
Posts: 555
Joined: Jan 15, 2012
Location: Danbury, CT

Re: use custom states from a ghost xml device

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"

John R Patrick
Author of
Home Attitude

Posted on
Sat Dec 07, 2019 1:31 pm
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: use custom states from a ghost xml device

The plugin deals with spaces already, I saw that earlier in the code.


Sent from my iPhone using Tapatalk Pro

Posted on
Sat Dec 07, 2019 2:55 pm
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: use custom states from a ghost xml device

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

Posted on
Sat Dec 07, 2019 4:02 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: use custom states from a ghost xml device

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.

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

[My Plugins] - [My Forums]

Posted on
Sat Dec 07, 2019 5:09 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: use custom states from a ghost xml device

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

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

[My Plugins] - [My Forums]

Posted on
Sat Dec 07, 2019 5:47 pm
wideglidejrp offline
User avatar
Posts: 555
Joined: Jan 15, 2012
Location: Danbury, CT

Re: use custom states from a ghost xml device

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.

John R Patrick
Author of
Home Attitude

Posted on
Sat Dec 07, 2019 7:53 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: use custom states from a ghost xml device

Good deal. Glad to hear that the update is working for you.

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

[My Plugins] - [My Forums]

Posted on
Mon Dec 09, 2019 11:12 am
wideglidejrp offline
User avatar
Posts: 555
Joined: Jan 15, 2012
Location: Danbury, CT

Re: use custom states from a ghost xml device

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.
Attachments
IMG_0363.jpeg
IMG_0363.jpeg (59.34 KiB) Viewed 2965 times
IMG_0362.jpeg
IMG_0362.jpeg (58.01 KiB) Viewed 2965 times

John R Patrick
Author of
Home Attitude

Posted on
Mon Dec 09, 2019 3:40 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: use custom states from a ghost xml device

Check that out. That's awesome! Thanks for sharing John.

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

[My Plugins] - [My Forums]

Posted on
Fri Jul 16, 2021 6:48 pm
Monstergerm offline
Posts: 274
Joined: Sep 01, 2009

Re: use custom states from a ghost xml device

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?

Posted on
Fri Jul 16, 2021 7:14 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: use custom states from a ghost xml device

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

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

[My Plugins] - [My Forums]

Posted on
Sat Jul 17, 2021 3:28 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: use custom states from a ghost xml device

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.

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

Who is online

Users browsing this forum: No registered users and 1 guest