No announcement yet.

Possible to query groups from within script?

  • 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.


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

      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)