Events for Devices?

Forum rules

This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo

Posted on
Tue Jul 05, 2011 1:44 pm
Perry The Cynic offline
Posts: 836
Joined: Apr 07, 2008

Events for Devices?

It looks like there's no way to make a plugin Event about something - i.e. to attach runtime data to it. In particular, there seems to be no way to make an Event "about this device". So I'm currently modeling device events by creating state variables and having the programmer use state-change triggers on those. (That's sometimes a bit hokey - to make a "hey, look at this device!" event, I ended up with an "incident count" state variable just so I have something reliable that changes.)

So what good are plugin events, actually? Are they just meant to be about global things that affect the whole plugin? (I don't actually have any plugin state anywhere; everything's in devices. Too much object-oriented training, I guess.)

Cheers
-- perry

P.S.: How far away is the ability to run Python code as an action? I'm now missing that very, very much.

Posted on
Tue Jul 05, 2011 3:17 pm
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Events for Devices?

Put a popup in the event config ui that allows the user to select the device. That's what the upcoming Airfoil plugin does with speaker change events - you select the "Speaker State Changed" event, which is a custom event, then in the config dialog for the event you select the speaker and the changes (speakers aren't devices in that plugin for various reasons) you want to monitor for.

So, for your example, you'd create a custom event - maybe "Device Alert" or something, and in the config UI for the event they'd select the device (and anything else specific to what they want to monitor for - maybe a count or something). Or, perhaps even better, use a list field so they can select multiple devices. Having an error state (or an operational state in which one value is error) isn't necessarily a bad idea but it may not be appropriate for your plugin.

So what good are plugin events, actually? Are they just meant to be about global things that affect the whole plugin?


Not at all - they're quite powerful since you can build UI to do pretty much anything.

I think the next beta - due in a couple of weeks - will probaly have embedded python scripts. In any event it will definitely be before we ship GM... ;)

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Jul 05, 2011 3:26 pm
Perry The Cynic offline
Posts: 836
Joined: Apr 07, 2008

Re: Events for Devices?

Put a popup in the event config ui that allows the user to select the device. That's what the upcoming Airfoil plugin does with speaker change events - you select the "Speaker State Changed" event, which is a custom event, then in the config dialog for the event you select the speaker and the changes (speakers aren't devices in that plugin for various reasons) you want to monitor for.


Ah. So instead of pushing data in an Event, use the Event's config to filter which ones I trigger. Got it.

Cheers
-- perry

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests