Number of lights turned on / open windows etc. - as a value

Posted on
Tue Nov 10, 2015 2:19 pm
DrLaban offline
Posts: 53
Joined: Apr 28, 2015
Location: Norway

Number of lights turned on / open windows etc. - as a value

Hi,

Is it possible to create a variable that is the number of lights turned ON ?
Or number of open windows etc.

If yes - what to do?

Posted on
Tue Nov 10, 2015 4:25 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Number of lights turned on / open windows etc. - as a va

(a) you could add 2 triggers for each device (if any change) and in a action:
trigger on: increment variable
trigger of:f decrement variable

But that would give you a very large number of triggers 2* the number of devices,


(b) Or a litte script you run 1/ minute that goes through a list of devices and counts.

you put this into an action of a schedule execute script (script and file Actions) and run it once a minute
Code: Select all
list=[799923553,1996809732]  #  <-- here the list of devices you like to count if lights are on/.off  either use the ID's
list=["LeoCeilingLight","KonsCeilingLight"]  # or names
vari="lightsOn"

try:
   indigo.variable.create(vari,"0")
except:
   pass

count =0
for nextLight in list:
      dev=indigo.devices[nextLight]
      if dev.states["onOffState"]: count+=1

indigo.variable.updateValue(vari,str(count))

Then the variable lightsOn will contain the number of devices that have onOffState =True
If the device does not have an onOffstate it will bomb and you should remove the device from the list

If you need further help let me know.

Karl

Posted on
Tue Nov 10, 2015 5:13 pm
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Number of lights turned on / open windows etc. - as a va

Karl, isn't there a dictionary (off the top of my head) for each of the built in device types (OnOff, Sensor, Thermostat, etc) that you could enumerate instead of manually maintaining $list[]?


Sent from my iPhone using Tapatalk

Posted on
Tue Nov 10, 2015 5:18 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Number of lights turned on / open windows etc. - as a va

Yes but onOff is not just for lights.


Sent from my iPhone using Tapatalk

Posted on
Tue Nov 10, 2015 6:17 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Number of lights turned on / open windows etc. - as a va

Code: Select all
  719674580                                       switch for insteon modem:  accumEnergyTimeDelta("17532043"), accumEnergyTimeDelta.ui("17532043 seconds"), accumEnergyTotal("7.622"), accumEnergyTotal.ui("7.622 kWh"), curEnergyLevel("1.588"),
                                                                          :  curEnergyLevel.ui("1.588 W"), onOffState("True"),
  397127077                                                    StudyLights:  brightnessLevel("0"), onOffState("False"),
  1860008679                                                   SmokeBridge:  onOffState("True"),
 

Here some examples of devices and their states.. many have onOffState , but no light, on the other hand the switches can be used to drive lamps, they don't have "brightness"
Section on if dev.state contains "brightness" does not select properly.

I would manually maintain the list as you you probably will like to select certain lamps ...
If you have to many to fit into a line:
you can do
Code: Select all
list=["LeoCeilingLight","KonsCeilingLight"] 
list+=[799923553, 123456,"deviceA"] # you could do device # or names or mix them if you like
if you want to see all devices and their current states, look at the the utility plugin http://forums.indigodomo.com/viewforum.php?f=184

Karl

Posted on
Tue Nov 10, 2015 6:45 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Number of lights turned on / open windows etc. - as a va

kw123 wrote:
Yes but onOff is not just for lights.


You can enumerate the device types you want (indigo.Dimmer, indigo.Relay, etc).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Nov 11, 2015 8:39 am
DrLaban offline
Posts: 53
Joined: Apr 28, 2015
Location: Norway

Re: Number of lights turned on / open windows etc. - as a va

Thanx guys!

I will check this out :)

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests