Trigger for Device State is Limited

Posted on
Tue Dec 11, 2018 6:32 pm
Charles offline
Posts: 5
Joined: Dec 10, 2018

Trigger for Device State is Limited

Hi, I'm posting for the first time in decades, seriously :)

I am attempting to create a simple action from a seemingly simple trigger. I have successfully parsed a very simple XML file (using GhostXML), which contains a list of temperatures –one of which is "outsideTemp". I've defined this XML data list as a Device.

I would like to base my action on how much "outsideTemp" increases. But when I select "outsideTemp" only three options area allowed.

-Becomes equal to
-Becomes not equal to
-Has any change

I would like to be much more specific with my action. How can I change these options?

Also, if I choose a different "sub-device", like "DeviceTimestamp" a completely different set of options becomes available, including...

-Becomes greater than
-Becomes less than

How does Indigo decide these options for sub-devices? I would like these options for the temp sub-devices.

Thanks, Charles

Posted on
Wed Dec 12, 2018 6:56 am
DaveL17 offline
User avatar
Posts: 4591
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Trigger for Device State is Limited

Hi - Indigo is deciding based on the type of value that you're using. In this case, I'd suggest that this is what's happening:

  1. The GhostXML plugin parses all values from XML and JSON payloads into strings. Since the value of outsideTemp is now a string, Indigo is presenting relevant options for string values. While it's technically possible to do greater than/less than operations with strings, it's of very limited usefulness here, so I suspect that's why Matt and Jay don't show them as options. The plugin does this because it's extremely non-trivial to try to evaluate every payload value to determine what is the most appropriate data type to apply, so it just stringifies everything.
  2. The DeviceTimestamp state is generated by the plugin itself, so we can assign that an appropriate type when it's created (in this case, a decimal number) so Indigo presents the greater than/less than options.
Indigo does a bit more logic with variable values, trying to interpret the logic than can be applied based on the variable's value (all variables are stored as strings, but Indigo already understands that). So a simple way to address this would be to save the 'outsideTemp' value to an Indigo variable and then apply your trigger to the variable value.

Hope that helps.

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

[My Plugins] - [My Forums]

Posted on
Wed Dec 12, 2018 10:32 am
jay (support) offline
Site Admin
User avatar
Posts: 15149
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Trigger for Device State is Limited

Would be cool if a user could specify an element and the type it should be - then they could map to the right type (and even specify formatters for things like dates)... :D

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Dec 12, 2018 4:31 pm
Charles offline
Posts: 5
Joined: Dec 10, 2018

Re: Trigger for Device State is Limited

Jay and Dave, thanks for the help :) :D

I agree Jay, it would be very useful to be able to define the types. In my case, I'm limited by the hardware which doesn't allow changes...though very happy it provides the XML –so I don't have to scrape and parse on my own.

Thanks again guys :)

Posted on
Wed Dec 12, 2018 5:00 pm
DaveL17 offline
User avatar
Posts: 4591
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Trigger for Device State is Limited

jay (support) wrote:
Would be cool if a user could specify an element and the type it should be - then they could map to the right type (and even specify formatters for things like dates)... :D

Too true. There's a couple things to think about, though (not an exhaustive list):

  1. One original design premise of the plugin is that it be constructed in such a way as to be completely resilient to changes in the underlying XML or JSON payload. That way, if a provider added or removed elements, the plugin would pick those up (or drop them) "automatically". By picking elements and specifying their type--that kind of presumes a degree of permanence--I'm not sure how we would handle that.
  2. Another possibility is if the nature of an element provided changes over time. Think the string "False" today and the number Zero tomorrow... Also of note here is payloads that provide 0/1 data that's intended to be a bool. I get that a user could specify the type, but, see item 1.
  3. I have thought that a method that might work at least semi-automatically and in a more robust way would be something like literal_eval -- but I'm not sure how resilient that is when things go sideways. Some quick testing has been promising, but need to do some more research there.
  4. Lastly, I haven't looked to see how Indigo would like a dynamic state that's defined as a string today and then something else tomorrow. I should be able to figure this out through testing; I haven't tried yet.

You could always do a pull request, Jay! :D

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

[My Plugins] - [My Forums]

Posted on
Wed Dec 12, 2018 5:02 pm
DaveL17 offline
User avatar
Posts: 4591
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Trigger for Device State is Limited

Charles wrote:
Jay and Dave, thanks for the help :) :D

My pleasure. I hope you can get some good use out of the plugin.

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

[My Plugins] - [My Forums]

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 0 guests

cron