just for the python beginner: how to list all devices/states

Posted on
Tue Jul 08, 2014 12:03 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

just for the python beginner: how to list all devices/states

copy this code into an action group server script and click on run..

Code: Select all
indigo.server.log("---------    device      ----------   --------states-------------------------")
for dev in indigo.devices:
   states = dev.states.keys()
   name = dev.name
   list =""
   for state in states:
      list += state +", " 
   indigo.server.log(name.rjust(max(len(name),35))+"   "+  list.strip(", "))
indigo.server.log("---------    device      ----------   --------states-------------------------")

prints into the log file:
Code: Select all
  Script                          ---------    device      ----------   --------states-------------------------
  Script                                                   Leo6Switch   keypadButtonLed1, keypadButtonLed2, keypadButtonLed3, keypadButtonLed4, keypadButtonLed5, keypadButtonLed6, keypadButtonLed7, keypadButtonLed8, onOffState
  Script                                              LeoCeilingLight   brightnessLevel, onOffState
  Script                                                       LeoFan   onOffState, speedIndex, speedIndex.ui, speedLevel
  Script                                      LivingRoomCeilingLights   brightnessLevel, onOffState
  Script                                          LivingRoomSpotlight   brightnessLevel, onOffState
  Script                                              MasterbedLights   brightnessLevel, onOffState
  Script                                                     me login   AppleID, Associated_Devices, LastLoggedIn, LastUpdated, Password_Accepted
  Script                                          Meter-LeftBoxClamp1   accumEnergyTimeDelta, accumEnergyTimeDelta.ui, accumEnergyTotal, accumEnergyTotal.ui, curEnergyLevel, curEnergyLevel.ui
  Script                                          Meter-LeftBoxClamp2   accumEnergyTimeDelta, accumEnergyTimeDelta.ui, accumEnergyTotal, accumEnergyTotal.ui, curEnergyLevel, curEnergyLevel.ui
  .....
  .....
  .....
  Script                          ---------    device      ----------   --------states-------------------------
 




would have loved to have something like this when I started my INDIGO-py journey

Karl

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 15 guests