Announcement

Collapse
No announcement yet.

Possible to query groups from within script?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Possible to query groups from within script?

    Is it possible to query the condition of device groups defined in the plugin from a script? Currently I have statements like


    If hs.deviceValue(StatusDevice)>0
    do something
    End If

    and for multiple devices for example I need to do

    SetStatus(337, hs.deviceValue(48)+hs.deviceValue(41)+hs.deviceValue(39)+hs. deviceValue(40)+hs.deviceValue(38)+hs.deviceValue(37) )

    and manually fetch the IDs of all the devices I want to check.

    I would love to use this plugin, assign the devices into groups (which seems to be possible) and then write a script that simply checks if *any* device in a group is ON and if so, sets a virtual status device.

    Reason: I have status devices for areas of the house. Like Livingroom, Office, Garage, Upstairs etc. Each status device should be ON if ANY of the lights in that area is on and off if ALL the devices in the area are OFF.

    #2
    It's not possible right now, but I'm going to add it to my TODO list.

    Comment


      #3
      in version 3.0.0.49 available here I have added the following scripting functions:

      Code:
      bool   AnyDevicesValueInThisGroupIsEqualTo(string groupName, double value)
      bool   AnyDevicesValueInThisGroupIsNotEqualTo(string groupName, double value)
      bool   AnyDevicesValueInThisGroupIsGreaterThan(string groupName, double value)
      bool   AnyDevicesValueInThisGroupIsLessThan(string groupName, double value)
      bool   AllDevicesValueInThisGroupAreEqualTo(string groupName, double value)
      bool   AllDevicesValueInThisGroupAreNotEqualTo(string groupName, double value)
      bool   AllDevicesValueInThisGroupAreGreaterThan(string groupName, double value)
      bool   AllDevicesValueInThisGroupAreLessThan(string groupName, double value)

      Comment


        #4
        Originally posted by spud View Post
        in version 3.0.0.49 available here I have added the following scripting functions:

        Code:
        bool AnyDevicesValueInThisGroupIsEqualTo(string groupName, double value)
        bool AnyDevicesValueInThisGroupIsNotEqualTo(string groupName, double value)
        bool AnyDevicesValueInThisGroupIsGreaterThan(string groupName, double value)
        bool AnyDevicesValueInThisGroupIsLessThan(string groupName, double value)
        bool AllDevicesValueInThisGroupAreEqualTo(string groupName, double value)
        bool AllDevicesValueInThisGroupAreNotEqualTo(string groupName, double value)
        bool AllDevicesValueInThisGroupAreGreaterThan(string groupName, double value)
        bool AllDevicesValueInThisGroupAreLessThan(string groupName, double value)

        Spud, you provided a small example snippet of code (#10) on how the scripting functions above might be used. But being a novice scripter, I didn't fulyl grasp that example. Could you give another script example that might test to see if ALLDevicesValueInThisGroupAreEqualTo 255. My group name is "AllInteriorLights".

        Thanks!

        Comment


          #5
          Originally posted by ScottAtlanta View Post

          Spud, you provided a small example snippet of code (#10) on how the scripting functions above might be used. But being a novice scripter, I didn't fulyl grasp that example. Could you give another script example that might test to see if ALLDevicesValueInThisGroupAreEqualTo 255. My group name is "AllInteriorLights".

          Thanks!
          here it is, C# script:

          ​​​​​​​
          Code:
          public object Main(object[] Parms)
          {
              bool isEqualTo255 = (bool) hs.PluginFunction("EasyTrigger", "", "AllDevicesValueInThisGroupAreEqualTo", new object[] { "AllInteriorLights", 255 });
          
              hs.WriteLog("EasyTrigger Script", "isEqualTo255= " + isEqualTo255.ToString());
              return 0;
          }

          Comment

          Working...
          X