[ANSWERED]: Example of Registering for Device Changes

Posted on
Mon Jun 23, 2014 10:30 am
mark_anderson_us offline
Posts: 65
Joined: Jun 05, 2014

[ANSWERED]: Example of Registering for Device Changes

Hi All

I'm building a proof of concept for a pure HTML client 9using Angular and Bootstrap). I've got it working with REST API, but I want a way of registering for device changes, so i can update the models. I have no experience with Python yet (and likely going to use Node for the backend). Wondered if anyone had an example (or some pointers) that'd be willing to share that registers for device changes

Thanks

Mark

Posted on
Tue Jun 24, 2014 6:32 am
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Example of Registering for Device Changes

I sent you an email with some of the lower-level protocol information.

If you take the approach of creating a plugin instead, then here is an example of the hooks for catching device changes (note this includes all device property changes, not just state changes):

Code: Select all
   def deviceCreated(self, dev):
      self.server.log(u"deviceCreated: \n" + str(dev))
      indigo.PluginBase.deviceCreated(self, dev)  # be sure and call parent function

      # do something here

   def deviceDeleted(self, dev):
      self.server.log((u"deviceDeleted: \n" + str(dev))
      indigo.PluginBase.deviceDeleted(self, dev)  # be sure and call parent function

      # do something here

   def deviceUpdated(self, origDev, newDev):
      self.server.log(u"deviceUpdated orig: \n" + str(origDev))
      self.server.log(u"deviceUpdated new: \n" + str(newDev))
      indigo.PluginBase.deviceUpdated(self, origDev, newDev)  # be sure and call parent function

      # do something here

# and somewhere in plugin initialization you'll want:
   indigo.devices.subscribeToChanges()

Image

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests