Auto Company Modes for the Fingscan Plugin

Posted on
Mon Dec 12, 2016 9:17 pm
Dewster35 offline
Posts: 1030
Joined: Jul 06, 2010
Location: Petoskey, MI

Re: Auto Company Modes for the Fingscan Plugin

Thank you Karl.

Running this gives me the following error message in my event log:

Code: Select all
   Script Error                    CompanyCheck.Py: unexpected indent
   Script Error                    around line 13 - "anyUp=True"


Any ideas on how to fix?

Posted on
Mon Dec 12, 2016 9:44 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Auto Company Modes for the Fingscan Plugin

convert every indent to 4-spaces OR 1-tab

probably while copying it went to 4-spaces, which I am using , you might be using tabs.. or the other way around

Posted on
Tue Dec 13, 2016 4:38 am
Dewster35 offline
Posts: 1030
Joined: Jul 06, 2010
Location: Petoskey, MI

Re: Auto Company Modes for the Fingscan Plugin

Thanks Karl! That did it and all seems to be working now. Thank you!

Posted on
Sat Jun 24, 2017 7:41 pm
Dewster35 offline
Posts: 1030
Joined: Jul 06, 2010
Location: Petoskey, MI

Re: Auto Company Modes for the Fingscan Plugin

This is related and I'm sure it is pretty trivial. How do I get a device name based on a device ID from indigo and place it into a variable?

Posted on
Sat Jun 24, 2017 8:13 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Auto Company Modes for the Fingscan Plugin

So the contents of variable should be the device id ?


Sent from my iPhone using Tapatalk

Posted on
Sun Jun 25, 2017 4:36 am
Dewster35 offline
Posts: 1030
Joined: Jul 06, 2010
Location: Petoskey, MI

Re: Auto Company Modes for the Fingscan Plugin

Nope. The device name.

Posted on
Sun Jun 25, 2017 10:26 am
Dewster35 offline
Posts: 1030
Joined: Jul 06, 2010
Location: Petoskey, MI

Re: Auto Company Modes for the Fingscan Plugin

I was able to get this far. I got the snippet to populate the device name into variable and then push that to an indigo variable, but I'm having trouble integrating it into the main script. Below is where I end up getting stuck.


Code: Select all
folder_id = 1637326348  # the ID of your default folder
variable_id = 936521597  # the ID of your tracking variable

anyUp = False
# Loop through Indigo devices
for dev in indigo.devices.itervalues():
   
    # Is the device in the default folder?
    if dev.folderId == folder_id:
        try:
            if dev.states['status'].lower() =='up':
               #WhoComp = indigo.devices[lower()]
            #CName = WhoComp.name
            #indigo.variable.updateValue(117345824, CName)
                indigo.variable.updateValue(variable_id, 'true')
                anyUp=True
                break
        except:
                    pass

if not anyUp:
    indigo.variable.updateValue(variable_id, 'false')

Posted on
Sun Jun 25, 2017 7:14 pm
Dewster35 offline
Posts: 1030
Joined: Jul 06, 2010
Location: Petoskey, MI

Re: Auto Company Modes for the Fingscan Plugin

One more step forward... now my issue is string manipulation.

My devices follow a standard convention.

(Last name of person) (-) (Company) (# if last name has multiple devices)

So I"m trying to find the position of the dash, then slice the string of the device name 2 positions before that dash.... below is what I've got but it's giving me a syntax error...

Code: Select all
folder_id = 1637326348  # the ID of your default folder
variable_id = 936521597  # the ID of your tracking variable

anyUp = False
#  Loop through Indigo devices
for dev in indigo.devices.itervalues():
   
    # Is the device in the default folder?
    if dev.folderId == folder_id:
        try:
            if dev.states['status'].lower() =='up':
      whoIs = dev.name
      dComp = whoIs.index('-')
      firstCompany = whoIs(:dComp - 2)
      indigo.variable.updateValue(117345824, firstCompany)
               indigo.variable.updateValue(variable_id, 'true')
      anyUp=True
           break
        except:
                    pass

if not anyUp:
    indigo.variable.updateValue(variable_id, 'false')

Posted on
Sun Jun 25, 2017 9:16 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Auto Company Modes for the Fingscan Plugin

try:
Code: Select all
whoIs[:dComp - 2]
it is not a function call but an index of a list, they go with [] not ()

this should also work
Code: Select all
      whoIs = dev.name.split("-")[0][0:-2]
1. split into 2 elements
2. take first element
3 use everything from the beginning to end -2 characters

Posted on
Sun Jul 02, 2017 12:16 pm
Dewster35 offline
Posts: 1030
Joined: Jul 06, 2010
Location: Petoskey, MI

Re: Auto Company Modes for the Fingscan Plugin

Python newbie! This worked. Thank you the tips.

Who is online

Users browsing this forum: No registered users and 3 guests