Get Plugin to Response to change in Variable?

Posted on
Mon Feb 12, 2018 7:14 pm
GlennNZ offline
User avatar
Posts: 1555
Joined: Dec 07, 2014
Location: Central Coast, Australia

Get Plugin to Response to change in Variable?

Hi all,

Thanks for helping as I am struggling with triggering a plugin with a (external) variable change. What is the best way to achieve this?
eg. motion sensed by external camera - RestfulAPI post to Indigo - to change indigo variable. But need running Plugin to see this change and respond.

Options:
- subscribetoChanges() ?is there a specific variable subscribetoIncoming() or does the devices one cover both or just devices.
Would seem quite process heavy for the simple task that is needed.

- Check variable for change within Plugin every second and then trigger if changed?
Probably fairly low-level impact ?

Or is there another way of achieving this which is essentially a external event (via RestfulAPI) triggering a Plugin.

Thanks - I'll have a look at some plugins that probably face the same issue to get some ideas...

Glenn

Posted on
Mon Feb 12, 2018 7:26 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Get Plugin to Response to change in Variable?

Try

Code: Select all
indigo.variables.subscribeToChanges()


Each group has its own. I’ve not tried it with variables but I think that will work.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Mon Feb 12, 2018 7:42 pm
GlennNZ offline
User avatar
Posts: 1555
Joined: Dec 07, 2014
Location: Central Coast, Australia

Re: Get Plugin to Response to change in Variable?

Colorado4Wheeler wrote:
Try

Code: Select all
indigo.variables.subscribeToChanges()


Each group has its own. I’ve not tried it with variables but I think that will work.


Wow - thanks for the tip - that be great if works.

The other option I was thinking (before your better solution) was whether we can change a Plugin devices custom state via RestfulURL (presume we can - but haven't tested)
& if we can, and then do so - is the device Plugin notified at all (I presume not - unless checking dev.states regularly?)

Glenn

Posted on
Mon Feb 12, 2018 7:47 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Get Plugin to Response to change in Variable?

I know a total API rewrite is underway, so maybe soon. It’s not too hard to write an http server and just roll your own API for your needs.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Wed Feb 14, 2018 10:53 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Get Plugin to Response to change in Variable?

The current REST API doesn't know about custom states. We are working on a REST overhaul for sometime this year.

And, in the interests of security, I'm not sure that a random API call should be able to change a state directly. We don't provide UI to do that either. Rather, we recommend that the developer expose actions to perform actions that typically result in state changes. The user could then create an action group to do perform the action and execute that through the API.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests

cron