Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I 'count' fields?
#1
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
Reply
#2
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.
------------------------------------
Some of my devices: Sonos, Aeotec zWave, Nest, Rain8Net, Various H/T
What's next: CQC-Voice, Brultech GEM
My vlogs: https://www.youtube.com/c/IVBsHomeAutomation
Reply
#3
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
Reply
#4
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
Reply
#5
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
Reply
#6
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
Reply
#7
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 Smile.

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
Reply
#8
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
Reply
#9
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
Reply
#10
ignore, wrong thread.
do the needful ...
Hue | Sonos | Harmony | Elk M1G // Netatmo / Brultech
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  The maximum collection node count has been exceeded. Max=0 NightLight 5 1,823 02-28-2020, 08:28 AM
Last Post: gReatAutomation
  Can't add fields to ElkDev driver rbroders 4 2,246 08-07-2018, 06:24 PM
Last Post: Dean Roddey
  TrayMon: "Maximum collection node count exceeded" IVB 6 2,723 06-24-2018, 11:21 AM
Last Post: Dean Roddey
  Lumagen Radiance fields missing dlmorgan999 14 8,613 02-18-2017, 11:04 AM
Last Post: dlmorgan999
  Field Check Box fields George M 2 2,438 01-25-2017, 04:14 PM
Last Post: George M
  Cant use fields of Denon driver in global actions George M 4 3,947 12-18-2016, 06:21 PM
Last Post: Dean Roddey
  Persistent Fields Ron Haley 1 1,694 05-06-2016, 03:31 PM
Last Post: Ron Haley
  Logic Server Fields Limit zra 11 5,565 03-20-2016, 07:59 AM
Last Post: zra
  Feature Request: Fields in Error per driver IVB 13 5,648 12-28-2015, 09:42 AM
Last Post: Dean Roddey
  Best way to iterate fields and check for a value? dlmorgan999 2 1,905 07-26-2015, 05:28 PM
Last Post: dlmorgan999

Forum Jump:


Users browsing this thread: 1 Guest(s)