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

    HS3 Pro 3.0.0.470 | 849 devices | 349 events | OpenSprinkler | BLShutdown | EasyTrigger | NetCAM | Harmony Hub | Sonos | SDJ-Health | BLUPS | PHLocation | BLBackup | BLLock | Z-Wave 3.0.1.243 | weatherXML | Pushover 3P | Blue-Iris | AirPlaySpeak

  • #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.
    Randy Prade
    Aurora, CO
    Prades.net

    PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

    Comment


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

      HS3 Pro 3.0.0.470 | 849 devices | 349 events | OpenSprinkler | BLShutdown | EasyTrigger | NetCAM | Harmony Hub | Sonos | SDJ-Health | BLUPS | PHLocation | BLBackup | BLLock | Z-Wave 3.0.1.243 | weatherXML | Pushover 3P | Blue-Iris | AirPlaySpeak

      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.
        Randy Prade
        Aurora, CO
        Prades.net

        PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

        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
          Randy Prade
          Aurora, CO
          Prades.net

          PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

          Comment


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

            HS3 Pro 3.0.0.470 | 849 devices | 349 events | OpenSprinkler | BLShutdown | EasyTrigger | NetCAM | Harmony Hub | Sonos | SDJ-Health | BLUPS | PHLocation | BLBackup | BLLock | Z-Wave 3.0.1.243 | weatherXML | Pushover 3P | Blue-Iris | AirPlaySpeak

            Comment

            Working...
            X