No announcement yet.

What is the best way to count the number of devices that are equal to a value?

  • Filter
  • Time
  • Show
Clear All
new posts

    What is the best way to count the number of devices that are equal to a value?


    I am trying to create a counter that will count the number of people in my house. I want to set the counter every night at 2:00 AM to the number of people in the house (I am using Life360 places). How can I set a counter to the number of people at a particular place (i.e. Home)?

    Throughout the day I will increment and decrement the counter as people come and go, but I want a way to make sure it reset it every night so things don't get out of sync.


    More information would be helpful. Are you using a virtual device as your counter or a HomeSeer counter? (Device values are much easier to manipulate than counters.)
    Mike____________________________________________________________ __________________
    HS3 Pro Edition, NUC i3

    HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti


      You have three ways to count anything

      1. Use a counter
      2. Use a virtual device
      3. Use a global variable.

      1. The counter can be controlled using the functions CounterReset, CounterIncrement, and CounterDecrement. The functions can be used as an immediate script as &hs.CounterDecrement("mycounter")

      2. If you create a virtual device you can add and subtract from the value. The most straight forward is to write a script where you can set the device value.

      hs.SetDeviceValue("VirtualDevice", 5)

      3. You can create a global variable in startup.vb this is done as shown in the help manual

      dim errst

      errst = CreateVar("myvar")

      if errst <> "" then
      msgbox "Error creating variable"
      end if

      You can then use a script or an immediate script to set the value and save

      SaveVar("myvar", myvalue)

      These are the methods that I am aware of but there may be others.


        Keep the counts in an .ini file is another option