Device filter to exclude disabled plugin devices

Posted on
Mon Jul 02, 2018 11:38 am
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Device filter to exclude disabled plugin devices

I would like to suggest adding a filter to device iterations on forms so that when you use
Code: Select all
<List class="indigo.devices" />
that you can have an option to exclude any devices that are in error or part of a disabled or missing plugin. Maybe something like 'indigo.activeDevices' or something.

I've run into an issue on a plugin that wants to deep dive into a selected device but because it is part of a disabled plugin I have to code in a work-around for it.

Alternatively (or in addition to) this request, having an attribute with this information would also be handy, something like
Code: Select all
deviceStatus: plugin disabled
-or-
deviceStatus: plugin missing


I had hoped to use the 'errorState' attribute but it doesn't give me any info in regards to this issue. I had also hoped that using the UI state would be useful but it changes from device to device. Even though the UI list shows 'plugin disabled' the device attributes don't seem to reflect that.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Mon Jul 02, 2018 2:23 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Device filter to exclude disabled plugin devices

You could do a (static)method that loops though all devices and checks for
dev.enabled :
Xx=[]
for dev in indigo.devices.iter():
If dev.enabled: xx.append([dev.id ,dev.name])
return xx
?

Karl


Sent from my iPhone using Tapatalk

Posted on
Mon Jul 02, 2018 2:46 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Device filter to exclude disabled plugin devices

I believe we've got that one on the list. You can do a comprehension (similar to Karl's suggestion) in your own device list method:

Code: Select all
[(dev.id, dev.name) for dev in indigo.devices if dev.enabled]

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Jul 02, 2018 3:01 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Device filter to exclude disabled plugin devices

kw123 wrote:
You could do a (static)method that loops though all devices and checks for
dev.enabled :
Xx=[]
for dev in indigo.devices.iter():
If dev.enabled: xx.append([dev.id ,dev.name])
return xx
?

jay (support) wrote:
I believe we've got that one on the list. You can do a comprehension (similar to Karl's suggestion) in your own device list method:

Code: Select all
[(dev.id, dev.name) for dev in indigo.devices if dev.enabled]


I already do something similar, that's why I was adding a built-in method to the feature request ;).

That being said, the 'enabled' attribute does not properly represent a disabled plugin's device as you can see by this device dump that is from a plugin that is disabled:

Code: Select all
address :
batteryLevel : None
buttonGroupCount : 0
configured : True
description :
deviceTypeId : etoIrrigationZone
displayStateId : serverTimeSeconds
displayStateImageSel : None
displayStateValRaw : None
displayStateValUi :

enabled : True  <----------------------------

energyAccumBaseTime : None
energyAccumTimeDelta : None
energyAccumTotal : None
energyCurLevel : None
errorState :
folderId : 1006009504


The only way I've gotten around it thus far is to write a code that invokes the plugin adapter and then check if the plugin 'isEnabled()' or not.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Mon Jul 02, 2018 5:34 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Device filter to exclude disabled plugin devices

Colorado4Wheeler wrote:
That being said, the 'enabled' attribute does not properly represent a disabled plugin's device


Hmmm - that's likely a bug, but it's also one that's likely not an easy fix. I'll add that to the list.

Out of curiosity, you say that you need to "deep dive" on a device and that doesn't work when it's plugin is disabled. Can you explain more what that means?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Jul 02, 2018 7:31 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Device filter to exclude disabled plugin devices

jay (support) wrote:
Out of curiosity, you say that you need to "deep dive" on a device and that doesn't work when it's plugin is disabled. Can you explain more what that means?

Sure. In many of my plugins, especially Device Extensions (which is what brought this up as I’m doing a massive overhaul of that) reads details from the plugins to derive things such as state descriptions and action fields. When a user selects a device from the list the information is parsed in real-time but when it’s a disabled plugin I have to handle that failure (because it cannot find the plugin package in the plugin folder) and disallow the action since the plugin device doesn’t technically work anyway.

Does that make sense?

Like I said, I have a workaround for it, a custom filter that performs an ‘isEnabled()’ on each unique plugin device but it adds a bit of overhead. My alternative is to also parse the disabled folder but that then leads to what to do if it’s been removed entirely, etc.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Tue Jul 03, 2018 2:22 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Device filter to exclude disabled plugin devices

as an intermediate performance suggestion :
first loop through the plugins, check if isEnabled() ; then loop though THOSE devices
that would reduce the if isEnabled() check for the plugin devices

but that would skip the devices that do not have a plugin associated .. ie insteon ...

In most of my plugin I keep internal tables for the devices (internal id, indigo id) that are refreshed once every x minutes and in devices start/stop.Tthose tables indicate if a device is on /off etc. Using that avoids the looping though all devices.

just a thought

Karl

Posted on
Tue Jul 03, 2018 6:54 am
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Device filter to exclude disabled plugin devices

kw123 wrote:
as an intermediate performance suggestion :
first loop through the plugins, check if isEnabled() ; then loop though THOSE devices
that would reduce the if isEnabled() check for the plugin devices

I do it in the way that gives the best performance at the moment, which is to simply loop the devices and if the pluginId is not empty then check if it is enabled, then cache that plugin name into a list that is checked on each subsequent plugin device and if it's already been checked it won't be checked again. I have a good solution for what is available now but thanks for the suggestion.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Tue Jul 03, 2018 8:50 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Device filter to exclude disabled plugin devices

Colorado4Wheeler wrote:
reads details from the plugins to derive things such as state descriptions and action fields


So, you're parsing the XML files for devices and actions?

Note, that won't work reliably for all plugins since they can generate and /or alter that information programmatically - several of ours do that. The WeatherSnoop plugin (which is now owned by Boisy), for instance, adds states programmatically based on what's passed back from querying WeatherSnoop. So parsing the Devices.xml file for WS 3+ agent devices will give you the few common fields, but the majority of the useful data fields won't show up.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Jul 03, 2018 9:41 am
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Device filter to exclude disabled plugin devices

jay (support) wrote:
So parsing the Devices.xml file for WS 3+ agent devices will give you the few common fields, but the majority of the useful data fields won't show up.

I realize that could be the case so I get what I can and just report on the raw state name if I cannot otherwise determine what it should be. It's not a perfect solution by any stretch but for my needs it's better to show 'Device On/Off State' than 'onOffState' as a choice (depending on what I can extrapolate).

I would rather be able to deal with 99% of the plugins that don't do that and then the 1% has a few lingering states than have raw state names for 100% of the time. The 1% will show what it can and then the raw state names below that as a last resort, but I can also sort of derive that info too if I needed to on a case-by-case basis.

The idea being that something that does not do dynamic state manipulation shows:
Screen Shot 2018-07-03 at 9.36.04 AM.png
Screen Shot 2018-07-03 at 9.36.04 AM.png (147.25 KiB) Viewed 2410 times


Instead of:
Screen Shot 2018-07-03 at 9.43.04 AM.png
Screen Shot 2018-07-03 at 9.43.04 AM.png (66.79 KiB) Viewed 2408 times

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Tue Jul 03, 2018 9:49 am
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Device filter to exclude disabled plugin devices

FYI, WeatherSnoop's dynamic gets handled (right now) like this (Name -> Version are static states, below the line are the dynamic states):
Screen Shot 2018-07-03 at 9.47.46 AM.png
Screen Shot 2018-07-03 at 9.47.46 AM.png (142.64 KiB) Viewed 2407 times

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Tue Jul 03, 2018 9:52 am
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Device filter to exclude disabled plugin devices

But you have given me an excellent idea for how to grab all that dynamic state data too! I'll post the screenshot after I do that, shouldn't take long.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Tue Jul 03, 2018 9:57 am
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Device filter to exclude disabled plugin devices

Oh man, very cool, I do love this stuff sometimes. By the way, in case you are wondering, even with the plugin isEnabled checking the dynamic plugin parsing and list generation takes < 1 second. For my testing form I have around 10 dynamic lists doing various filters in a library I built for the purpose and it all takes about 5 seconds to pull, but I think having the filter will reduce that significantly, maybe to 1-2 seconds.

Screen Shot 2018-07-03 at 9.57.19 AM.png
Screen Shot 2018-07-03 at 9.57.19 AM.png (167.78 KiB) Viewed 2398 times

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest