Posts: 3,716
Threads: 196
Joined: Aug 2006
What is the best practice for how to do this?
Example - I would like to see the TOTAL number of lights currently turned on. If there are 6 lights on in the house, I would like to have the number 6 displayed in the IV. if i turn one off, that number would change to 5, or if i turn another on it would increment to 7.
Any thoughts or suggestions on how to best do this?
do the needful ...
Hue | Sonos | Harmony | Elk M1G // Netatmo / Brultech
Posts: 7,970
Threads: 554
Joined: Mar 2005
the way i did it upon asking alexa about # of open windows was to set an LVar to 0, then if-then adding 1 if on, cycling through all. I only had 16ish windows to count though, you have a ton of lights.
Posts: 40,483
Threads: 491
Joined: Aug 2002
That's something I'd probably fall back to CML for, given that it's sort of unwieldy if you have a lot of them. And it sort of depends on how often you need to know this. Do you only need to know it once in a while when a user invokes an action, or does you need to know it all the time?
Dean Roddey
Explorans limites defectum
Posts: 4,225
Threads: 365
Joined: May 2005
simple way - triggers.
As a light is >0 add one to a variable driver field.
as a light = 0 (off) subtract one from a variable driver field.
You need to set a trigger for a change on every field.
Basically as IVB indicated.
A macro could do it but it can lag behind the actual state. If you ran it say every minute it could be up to 60 seconds out of date. Again, I would use a variable field driver to hold the value.
The best method would be to have it added to the driver - depending on your CML skills you could modify the driver yourself and create a new field and have it count the number of lights on and off.
Mick
Mykel Koblenz
Illawarra Smart Home
Posts: 40,483
Threads: 491
Joined: Aug 2002
Ultimately, I guess that's a good one for the Logic Server, a new type that treats any source field whose expression comes out true as a 1, else a zero, and so maintains a running count of the number of course fields that meet some criteria.
Dean Roddey
Explorans limites defectum
Posts: 165
Threads: 29
Joined: Apr 2007
The way I did it was to use the Logic server and a sum function and then set my trigger against the Logic Server value then do what IVB said. Downside to Logic Server is it only allowed me 8 lights to track per Logic Server field. As I add lights I will add a second field. I use UPB so orinigally I thought a trigger may have been On Load however UPB does not use that event type so that is why I went this route.
System: WHS, UPB, Plex, Elk
Drivers: Autopatch, DataLog DB, DTV IP, GC-100, IRA, Logic Server, Variable Driver, Weather Underground
Posts: 3,716
Threads: 196
Joined: Aug 2006
Ugh - I have like 46 bulbs. I guess I should just 'head down, power through' and use triggers and variables until a better solution comes along (to be read as: until a solution I understand comes along

.
It's probably time I read the docs for the logic server so I can start to use it, but I can't seem to wrap my head around it right now.
Dean, for my purposes, this would be counting and displaying all the time in the IV.
do the needful ...
Hue | Sonos | Harmony | Elk M1G // Netatmo / Brultech
Posts: 4,225
Threads: 365
Joined: May 2005
Then the logic server is the way forward for you. Simple enough to do as its all through a GUI. I would still use a field in a variable driver as the "output" field.
If you use the logic server you wont need triggers - the server does the comparison itself and internally triggers the function you have assigned to it. Its actually really simple the logic server.
Mykel Koblenz
Illawarra Smart Home
Posts: 3,716
Threads: 196
Joined: Aug 2006
it's totally foreign to me.
what type of field would I make for this? the lights are True/False, so i can't really 'count' anything. i looked for docs, but i dont see one for the logic server, either.
do the needful ...
Hue | Sonos | Harmony | Elk M1G // Netatmo / Brultech
Posts: 3,716
Threads: 196
Joined: Aug 2006
ignore, wrong thread.
do the needful ...
Hue | Sonos | Harmony | Elk M1G // Netatmo / Brultech