Notification of new device creation
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
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
Notification of new device creation
Is there a call Indigo can make to a plugin to inform the plugin of the creation of a new device?
Re: Notification of new device creation
It appears that the "deviceCreated" method is called, and can be overridden by your plugin, whenever a device that was owned by your plugin is created. The method is described here.
- jay (support)
- Site Admin
- Posts: 19232
- Joined: Wed Mar 19, 2008 11:52 am
- Location: Austin, Texas
- Contact:
Re: Notification of new device creation
Note that in Indigo 6 deviceCreated() is called before your config dialog has a chance to run. We're a bit behind in the documentation, but you can use the new dev.configured property inside the deviceUpdated() method to see if your config dialog has run on the device at least one time.
The main place we recommend looking for devices is in deviceStartComm - though obviously that doesn't necessarily serve all purposes.
The main place we recommend looking for devices is in deviceStartComm - though obviously that doesn't necessarily serve all purposes.
Re: Notification of new device creation
Thanks... for now deviceCreated and the related calls meets my need. The issue here is that the plugin maintains a list of devices that should be polled at regular intervals. For simplicity I keep the device info in an internal dict. But, I need to update that dict if a device is added/changed or deleted. So, all I was looking for was notification that a change had been made - which, thanks to nsheldon for telling me and Jay and Matt for creating, I now have.
- jay (support)
- Site Admin
- Posts: 19232
- Joined: Wed Mar 19, 2008 11:52 am
- Location: Austin, Texas
- Contact:
Re: Notification of new device creation
You should manage that in deviceStartComm() and deviceStopComm() since you don't want to poll devices that aren't enabled... 
Re: Notification of new device creation
Yup, I could do that. But, since I only poll the thermostats energy n minutes its pretty easy to just use runConcurrentThread and then loop over the devices once each time the method loops.
- jay (support)
- Site Admin
- Posts: 19232
- Joined: Wed Mar 19, 2008 11:52 am
- Location: Austin, Texas
- Contact:
Re: Notification of new device creation
You're missing the point - if the user disables communication to the thermostat, they expect that it won't be communicated with.
You can do exactly what you're talking about doing - you just manage the contents of the device list from deviceStartComm() and deviceStopComm(). In deviceStartComm, you add it to the list of devices to poll, in deviceStopComm you remove it from the list. That way, the user can disable the thermostat if they need to power it down, move it, etc., and they won't get a stream of communication errors when you try to poll a device that isn't there.
You can do exactly what you're talking about doing - you just manage the contents of the device list from deviceStartComm() and deviceStopComm(). In deviceStartComm, you add it to the list of devices to poll, in deviceStopComm you remove it from the list. That way, the user can disable the thermostat if they need to power it down, move it, etc., and they won't get a stream of communication errors when you try to poll a device that isn't there.
Re: Notification of new device creation
Really, I think I get it. But, since I added support for deviceUpdated. I get notified when communications are enabled and disabled as well as for device config changes.
- jay (support)
- Site Admin
- Posts: 19232
- Joined: Wed Mar 19, 2008 11:52 am
- Location: Austin, Texas
- Contact:
Re: Notification of new device creation
OK - just trying to help make it less complex... 