Nest home is resetting itself somehow?

Posted on
Sat Feb 10, 2018 3:30 pm
dduff617 offline
Posts: 659
Joined: Jul 05, 2006
Location: Massachusetts, USA

Nest home is resetting itself somehow?

I believe this has happened at least twice to me in the last month or two:

I find that triggers I had previously set up that used my Nest thermostats go completely missing from my Indigo configuration. I had a set of four Indigo triggers that used changes in state of my thermostats. Then sometime later, I go to look for them and they are gone. I notice that my thermostats objects seem to have been removed and replaced with new ones. I say this because I had previously moved my thermostat objects to a folder called "HVAC". Now I see the thermostats are sitting in folder called "Nest Home" again.

So it appears as though something is causing all my Thermostat objects using Nest Home AND their corresponding triggers to be deleted, then new replacement objets are being created.

The only thing I can remember that might be related or perhaps caused it was a few weeks back I had been seeing some error messages about missing states (something to do with humidity, I think). I think I may have done a "reload" on Nest Home plugin and (looking at it only briefly) it seemed like that caused the error msgs to stop, so I thought all was ok.

I also note that my Nest Protect objects are still living in the same folder I put them in; they did not seem to be reset/replaced the same way the thermostats were. So it's only my thermostat objects that were affected.

Anyone else seeing this? I believe it has happened to me twice. It's kind of painful for me because I had spent some time tweaking and designing a bunch of triggers and they just disappeared without a trace!

Between this problem and the problem I reported earlier with my Nest Home objects not updating correctly, I'm sorry to say that I'm having a bad time so far trying to actually do anything useful with Nest Home.

Posted on
Fri Jun 08, 2018 7:12 am
vtmikel offline
Posts: 628
Joined: Aug 31, 2012
Location: Boston, MA

Re: Nest home is resetting itself somehow?

I think I'm experiencing the same problem. viewtopic.php?f=170&t=20810&p=161582#p161582

Posted on
Fri Jun 08, 2018 8:52 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Nest home is resetting itself somehow?

I just briefly looked at the code, and it definitely does delete Indigo devices if it finds one that doesn't correspond to what the NEST API is presenting. I don't fully understand the code beyond that, but it's definitely possible that it's deleting devices.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Jun 17, 2018 11:43 am
vtmikel offline
Posts: 628
Joined: Aug 31, 2012
Location: Boston, MA

Re: Nest home is resetting itself somehow?

Jay,

I was giving this some thought-

What's the justification for plugins having access to delete devices (even devices of their own)?

I while back, I remember a post by you or Matt discouraging the automatic creation of devices. However, this pattern has become the norm (I use it myself in my JustAddPower plugin), and I quite like it when a plugin is able to discover it's own child devices. Fing, Lutron, NEST all do this.

However, I cannot think of a single plugin I use that deletes a device from my setup. I actually don't like the idea that plugins can do this. Is it something to consider restricting?

Mike

Posted on
Sun Jun 17, 2018 12:40 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Nest home is resetting itself somehow?

Plugins can only delete devices that they own. We think that's a reasonable balance.

Discovery and auto creation are two different things. We're all for discovery if it's possible. But having a plugin that just automatically creates devices at random is not something we think is intuitive to users. A balance that we use in our plugins is to show a list of discovered devices in the device create dialog where the user can explicitly add the device.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Jun 17, 2018 2:10 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Nest home is resetting itself somehow?

Actually, plugins and script can delete any device (or variable), not just ones they created or define. As to if this should be the case is probably something we need to evaluate some more. But currently both plugins and scripts have the ability to add and delete devices (and variables).

As Jay mentioned, device deletion can be useful for factory created devices, where multiple devices are created as part of a discovery/sync process. For example, if you are syncing with a Z-Wave node to create a new device in Indigo and it is a multi-sensor then multiple devices are created (Motion, Temperature, Humidity and Lux ). If that device then needs to be replaced in the future but it gets replaced with a different type of multi-sensor (or maybe just a sensor) then when the user re-performs the sync they may end up with more or fewer devices in that group. So for example, the new device might just have Motion and Temperature, so the Humidity and Lux devices now need to be removed from the group (and from Indigo's database).

One issue with device deletion is that if the device is used as the primary component of a Trigger then upon deletion that Trigger will also be deleted. So there can be a cascading effect of objects that end up getting removed. Our internal Z-Wave plugin handles this by first pre-flighting the delete with a indigo.device.getDependencies() call. So in the example, above where the user is re-syncing a module and it now has fewer devices needed (because it is a different model), Indigo first checks to see if it can cleanly delete the devices without it impacting other database elements (Triggers, Control Pages, Conditionals). If it can then it deletes those devices. If it cannot then it logs an error to the Event Log and tells the user to manually edit/remove the dependent objects first. Here is some example code snippets of what it does:

Code: Select all
dev_id_list = []   # this contains a list of the device IDs for a device group
if old_num_devs_in_group > new_num_devs_in_group:
   # The current number of devices assigned to this node is greater than
   # what it will be after the sync. The user must have swapped modules
   # with a different module type. We can only allow this if the extra
   # devices that will be deleted are not currently being used in any
   # actions, triggers, etc. Here we make sure that is the case, and abort
   # if it isn't in which case the user will have to manually fix/remove
   # the device dependencies first (ideally we would offer to manually
   # fix those dependencies by having them point to a placeholder/nil
   # device). We don't want to delete the devices automatically in this
   # case since it will potentially alter logic.
   dependent_dev_names = []
   for dev_id in dev_id_list[(new_num_devs_in_group - old_num_devs_in_group):]:
      dependencies = indigo.device.getDependencies(dev_id)
      if len(dependencies['actionGroups']) > 0 or len(dependencies['controlPages']) > 0 \
      or len(dependencies['schedules']) > 0 or len(dependencies['triggers']) > 0 \
      or len(dependencies['variables']) > 0:
         dependent_dev_names.append(indigo.devices.getName(dev_id))

   if len(dependent_dev_names) > 0:
      # User is going to have to remove dependencies before we can proceed.
      dev_name = ', '.join(["%s" % name for name in dependent_dev_names])
      errdesc = u"Devices \"%s\" are currently referenced by other objects, so the sync cannot be performed. Right-click on the devices in the main window and choose the Show Dependencies menu to find the references, then modify those objects to not reference the device and re-sync this device again." % (dev_name)
      self.logError(errdesc)
      return (False, errdesc)

   for dev_id in dev_id_list[(new_num_devs_in_group - old_num_devs_in_group):]:
      del_dev_name = indigo.devices.getName(dev_id)
      indigo.device.delete(dev_id)
      self.logInfo(u"deleted unused device \"%s\" " % (del_dev_name), forceSyncPrefix=True)

   dev_id_list = dev_id_list[:new_num_devs_in_group]
   old_num_devs_in_group = new_num_devs_in_group      # dev_id_list size now matches node's sub model list size.

So in summary, if a plugin is going to delete a device it should definitely use the indigo.device.getDependencies() call first to make sure the result will only be that device being deleted. We should have made the delete call default to throwing an exception if there are dependencies, unless an override parameter is set. We might add that in the future, but it gets complicated since we don't want to break any legacy logic/plugins. Although it should be pretty rare that a plugin really will want both the device and its dependencies removed.

Image

Posted on
Mon Jun 18, 2018 3:34 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Nest home is resetting itself somehow?

jay (support) wrote:
Plugins can only delete devices that they own. We think that's a reasonable balance.

Discovery and auto creation are two different things. We're all for discovery if it's possible. But having a plugin that just automatically creates devices at random is not something we think is intuitive to users. A balance that we use in our plugins is to show a list of discovered devices in the device create dialog where the user can explicitly add the device.

Currently my LIFX plugin automatically creates Indigo devices for all the LIFX devices it discovers. For the next version of the plugin (still in development) I am changing it so that the user can either select Auto Create Indigo Devices or add them as normal via the New ... button i.e. I am following your recommendation above. My nanoleaf plugin already works this way. :)

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests

cron