lastMotionTime updating on all Ring devices in Indigo

Posted on
Tue Jan 16, 2018 12:56 pm
ZachBenz offline
Posts: 163
Joined: Feb 08, 2014

lastMotionTime updating on all Ring devices in Indigo

I have two Ring devices set up using v0.1.25 of the plugin: a doorbell, and a floodlight cam. I'm looking to set up some automations triggered by motion detected at a particular device using a trigger off of the lastMotionTime.

Unfortunately, it looks like the lastMotionTime state gets updated on all devices whenever motion is triggered on any one device. For example, if I walk past my doorbell, my Ring app on my iPhone dutifully notifies me of the motion detected at my Front Door. In Indigo, the Ring Doorbell plugin eventually updates the device states based on the polling frequency. Because it is nondeterministic exactly what order polling will fire for the Ring devices in Indigo, whichever device happens to have its state updated first after the motion event will trigger the lastMotionTime changing. Then at some time after that, the other devices will also see their lastMotionTime changed the next time they are polled and updated. That is, regardless of where the motion was triggered, all devices will see their lastMotionTime updated when that device is next polled.

Not sure if this is a bug in how the plugin is polling the states (perhaps not correctly indexing the device lookup?) or if it is a limitation of the reverse engineered Ring "API" (such as it is).

ZachBenz's Plugins: RingForIndigo

Posted on
Tue Jan 16, 2018 2:08 pm
ZachBenz offline
Posts: 163
Joined: Feb 08, 2014

Re: lastMotionTime updating on all Ring devices in Indigo

Ok, I think I found the problem. In the plugin's plugin.py:

Code: Select all
   def _refreshStatesFromHardware(self, dev):
      try:
         doorbellId = dev.pluginProps["doorbellId"]
         #self.debugLog(u"Getting data for Doorbell : %s" % doorbellId)
         doorbell = Ring.GetDevice(self.Ring,doorbellId)

         lastEvents = Ring.GetDoorbellEvent(self.Ring)

         if len(lastEvents) == 0:
            event = Ring.GetDoorbellEventsforId(self.Ring,doorbellId)
         else:
            self.debugLog("Recient Event(s) found!  Count: %s" % len(lastEvents))
            for k,v in lastEvents.iteritems():
               event = v
               break


Ring.GetDoorbellEvent appears to be getting all new events, regardless of which device they were triggered by, which makes the if/else logic below that not behave correctly. It looks like that if no new events have occurred, then the specific event for the current device is retrieved; otherwise, if any events are in lastEvents, then the first one gets assigned as the new event for the current device, even if the event doesn't match that device.

ZachBenz's Plugins: RingForIndigo

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests