I have a plugin that seems to have been working but suddenly stopped. It's a pretty basic concept, the user configures one or more weather snoop devices and the plugin fires when one of those devices changes (via indigo.devices.subscribeToChanges() and then deviceUpdated().
My question is if it's better to store the device ID or the device itself in the plugin. If I store the ID then each time I run my function I need to do an indigo.devices[12345], if I store the device then I can just simply get the states I'm after (wsdevice.states["temperature_C"] for example).
My plugin storing the devices as variables seemed to be working great but suddenly broke for some reason and now the variable (wsdevice) is "stale" and only shows data as of when the plugin was reloaded rather than maintaining a persistent connection to the device for the current states.
If I am able to keep a persistent connection to the device as a variable in my plugin, what would cause it to go stale like this all of the sudden? When I say "all of the sudden", I did some code clean up to take out testing functions and stuff like that, so I'm wondering if I accidentally took something out of my script that keeps that device in a persistent state or if I was just getting lucky before. Its frustrating to have it break so suddenly but if I was doing it wrong in the first place then I suppose I can't complain, it just seems expensive to query the device list each time so it made more sense to me to keep a persistent device in the plugin.