Announcement

Collapse
No announcement yet.

Device Group & Iterate

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

    Device Group & Iterate

    So I have some events that use device groups for open and closed windows and doors.

    My question is if I can single out which window(s) is/are open using EasyTrigger. For example, I would like to periodically check if a group of windows are closed and if one or more are open then speak which windows are open.

    Thanks,
    Michael

    #2
    Originally posted by Rvtravlr View Post
    So I have some events that use device groups for open and closed windows and doors.

    My question is if I can single out which window(s) is/are open using EasyTrigger. For example, I would like to periodically check if a group of windows are closed and if one or more are open then speak which windows are open.

    Thanks,
    I didn't use Easy Trigger when I built the trigger events, but it would make the trigger events easier to build. I use a very simple script to check my doors and windows and puts the open ones in a virtual device. Then I have HS speak the virtual device or include its contents in an email or Pushover message.

    The script was modified from one another member gave me. If you would like, I can comment it, post it and explain the devices and events. You could modify it for your own use.
    HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

    Comment


      #3
      Yes, Randy, I would appreciate that.
      Michael

      Comment


        #4
        Originally posted by Rvtravlr View Post
        Yes, Randy, I would appreciate that.
        I'll put it up tomorrow after I comment it and clean it up.
        HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

        Comment


          #5
          Originally posted by Rvtravlr View Post
          Yes, Randy, I would appreciate that.
          Sorry to be late to the game. I use several virtual devices and multiple subroutines in a script to update different groups. I have pared the script down to all windows and all doors. There is a virtual device for each:

          Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	12.3 KB
ID:	1195241

          When the script runs, it goes through one of two fixed arrays of reference numbers for the doors or windows I wish to check. As you can see above, the front door is open and all windows are closed. This is a simplified version of the script:

          Code:
          ' these are the virtual devices to be updated by the script
          '5281	Windows
          '8829   Doors
          
          'Use the reference ID of the door or window sensor devices in the arrays below
          
          dim array_windows() as string = {"4557", "4548", "4550", "4543", "4556", "4549", "4564", "4553", "4555", "4554", "4551", "4545", "4544","4559", "4560", "4561", "4562", "4563"}
          
          dim array_doors() as string = {"4565", "4542", "4558", "4566", "4532", "4531", "4552", "4523", "4522", "4528", "4527"}
          
          dim windows_count as integer = 0
          dim window_name as string = ""
          dim wstr as string = ""
          
          dim doors_count as integer = 0
          dim door_name as String = ""
          dim dstr as string = ""
          
          Dim dv as Object
          
          'Using 2 subs, one for doors and the other for windows
          
          'WINDOWS
          sub windows(ByVal Parms as Object)
          Try
          windows_count = 0
          window_name = ""
          wstr = ""
          for each devw as string in array_windows
                  'hs.writelog("Array", "Window " & window_name & " | Value " & hs.DeviceValue(devw))
          	if hs.DeviceValue(devw) = 1 then
                          windows_count = windows_count + 1
          		dv = hs.GetDeviceByRef(devw)
          		window_name =  dv.Name(hs)
                 		wstr = wstr & window_name & ",<br>"
          	hs.writelog("DoorWindow", window_name & " Open")
          	'hs.writelog("DoorWindow", array_windows)
                  end if
          next
          	If windows_count > 0 then 
          		hs.SetDeviceValueByRef(5281,100,true)
          		hs.SetDeviceString(5281, wstr,true)
          	Else
          		hs.SetDeviceValueByRef(5281,0,true)
          		hs.SetDeviceString(5281, "All Windows Closed",true)
          	End If
          	
          	hs.writelog("DoorWindow", "Window Count: " & windows_count)
          
          Catch ex As Exception
          hs.WriteLog ("DoorWindow", "Error: " & ex.Message)
          End Try
          
          End Sub
          
          'DOORS
          sub doors(ByVal Parms as Object)
          Try
          doors_count = 0
          door_name = ""
          dstr = ""
          for each devd as string in array_doors
                  'hs.writelog("Array", "Door " & door_name & " | Value " & hs.DeviceValue(devd))
          	if hs.DeviceValue(devd) = 1 then
          		dv = hs.GetDeviceByRef(devd)
          		door_name =  dv.Name(hs)
          		doors_count = doors_count + 1
          		dstr = dstr & door_name & ",<br>"
          	hs.writelog("DoorWindow", door_name & " Open")
                  end if
          next
          	If doors_count > 0 then 
          		hs.SetDeviceValueByRef(8829,100,true)
          		hs.SetDeviceString(8829, dstr,true)
          	Else
          		hs.SetDeviceValueByRef(8829,0,true)
          		hs.SetDeviceString(8829, "All Doors Closed",true)
          	End If
          
          	hs.writelog("DoorWindow", "Door Count: " & doors_count)
          
          Catch ex As Exception
          hs.WriteLog ("DoorWindow", "Error: " & ex.Message)
          End Try
          
          End Sub
          I use a different script with several subroutines so that I can check groups of windows and doors, depending on other variables. I think the script is commented well enough.

          Just create your virtual devices for storing windows and doors. Then use the Reference ID of the virtual devices in the script. Build your arrays using the Reference IDs of the doors and windows you want to check. The script will set the virtual device to Off (0) when all devices are closed and at On (100) if any device is open. The actual text is written to the string for each device. You can then use the device in a TTS announcement, email or other method of communicating.

          Hopefully this makes sense. If not, ask away
          HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

          Comment


            #6
            Thank you for taking the time to do this.
            Michael

            Comment


              #7
              Originally posted by randy View Post
              Sorry to be late to the game. I use several virtual devices and multiple subroutines in a script to update different groups. I have pared the script down to all windows and all doors. There is a virtual device for each:

              [ATTACH]66552[/ATTACH]

              When the script runs, it goes through one of two fixed arrays of reference numbers for the doors or windows I wish to check. As you can see above, the front door is open and all windows are closed. This is a simplified version of the script:

              Code:
              ' these are the virtual devices to be updated by the script
              '5281 Windows
              '8829 Doors
              
              'Use the reference ID of the door or window sensor devices in the arrays below
              
              dim array_windows() as string = {"4557", "4548", "4550", "4543", "4556", "4549", "4564", "4553", "4555", "4554", "4551", "4545", "4544","4559", "4560", "4561", "4562", "4563"}
              
              dim array_doors() as string = {"4565", "4542", "4558", "4566", "4532", "4531", "4552", "4523", "4522", "4528", "4527"}
              
              dim windows_count as integer = 0
              dim window_name as string = ""
              dim wstr as string = ""
              
              dim doors_count as integer = 0
              dim door_name as String = ""
              dim dstr as string = ""
              
              Dim dv as Object
              
              'Using 2 subs, one for doors and the other for windows
              
              'WINDOWS
              sub windows(ByVal Parms as Object)
              Try
              windows_count = 0
              window_name = ""
              wstr = ""
              for each devw as string in array_windows
              'hs.writelog("Array", "Window " & window_name & " | Value " & hs.DeviceValue(devw))
              if hs.DeviceValue(devw) = 1 then
              windows_count = windows_count + 1
              dv = hs.GetDeviceByRef(devw)
              window_name = dv.Name(hs)
              wstr = wstr & window_name & ",<br>"
              hs.writelog("DoorWindow", window_name & " Open")
              'hs.writelog("DoorWindow", array_windows)
              end if
              next
              If windows_count > 0 then
              hs.SetDeviceValueByRef(5281,100,true)
              hs.SetDeviceString(5281, wstr,true)
              Else
              hs.SetDeviceValueByRef(5281,0,true)
              hs.SetDeviceString(5281, "All Windows Closed",true)
              End If
              
              hs.writelog("DoorWindow", "Window Count: " & windows_count)
              
              Catch ex As Exception
              hs.WriteLog ("DoorWindow", "Error: " & ex.Message)
              End Try
              
              End Sub
              
              'DOORS
              sub doors(ByVal Parms as Object)
              Try
              doors_count = 0
              door_name = ""
              dstr = ""
              for each devd as string in array_doors
              'hs.writelog("Array", "Door " & door_name & " | Value " & hs.DeviceValue(devd))
              if hs.DeviceValue(devd) = 1 then
              dv = hs.GetDeviceByRef(devd)
              door_name = dv.Name(hs)
              doors_count = doors_count + 1
              dstr = dstr & door_name & ",<br>"
              hs.writelog("DoorWindow", door_name & " Open")
              end if
              next
              If doors_count > 0 then
              hs.SetDeviceValueByRef(8829,100,true)
              hs.SetDeviceString(8829, dstr,true)
              Else
              hs.SetDeviceValueByRef(8829,0,true)
              hs.SetDeviceString(8829, "All Doors Closed",true)
              End If
              
              hs.writelog("DoorWindow", "Door Count: " & doors_count)
              
              Catch ex As Exception
              hs.WriteLog ("DoorWindow", "Error: " & ex.Message)
              End Try
              
              End Sub
              I use a different script with several subroutines so that I can check groups of windows and doors, depending on other variables. I think the script is commented well enough.

              Just create your virtual devices for storing windows and doors. Then use the Reference ID of the virtual devices in the script. Build your arrays using the Reference IDs of the doors and windows you want to check. The script will set the virtual device to Off (0) when all devices are closed and at On (100) if any device is open. The actual text is written to the string for each device. You can then use the device in a TTS announcement, email or other method of communicating.

              Hopefully this makes sense. If not, ask away
              Hello Randy,
              Do you still use this script to populate these two VDs with the open windows and doors? It's been a while since you've posted this so I'm not sure if you have developed a different way to do this?


              HS4 4.2.6.0 &HSTouch Designer 3.0.80
              Plugin's:
              BLBackup, BLOccupied, BLShutdown, EasyTrigger, Ecobee, Nest, AK Bond
              EnvisaLink DSC, PHLocation, Pushover, SONOS, Blue Iris, UltraRachio3,
              weatherXML, Jon00 Alexa Helper, Network Monitor, MyQ, Z-Wave

              Comment


                #8
                Originally posted by The Profit View Post

                Hello Randy,
                Do you still use this script to populate these two VDs with the open windows and doors? It's been a while since you've posted this so I'm not sure if you have developed a different way to do this?

                No, still using it. It has evolved a bit. I now separate windows and doors to sub groups. In the summer we will leave the porch windows open, so they are separated from the main windows for house to sleep purposes. I also separate the garage, shed and workshop doors and windows. I also track locks with a virtual device.

                Click image for larger version

Name:	image.png
Views:	85
Size:	105.3 KB
ID:	1627368


                HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

                Comment


                  #9
                  Originally posted by The Profit View Post
                  so I'm not sure if you have developed a different way to do this?
                  If interested, I wrote a script to use virtual devices that represent multiple similar devices (motion sensors, lights, windows, locks, garage doors, house doors, etc) I call these Composite Devices (script here). Device 'groups' are dynamic, not hardcoded .. it uses text include/exclude ​(like EasyTrigger's group rules does) not hard coded device IDs since I wanted to be able to add/remove/change devices and not redo the script... and which has been nice since I've changed 200 devices over the past 2 years and not needed to touch the script except to add a new device category (aka, composite device)

                  Comment

                  Working...
                  X