Announcement

Collapse
No announcement yet.

All Light Status and Off Virtual Switch?

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

    All Light Status and Off Virtual Switch?

    I know this is probably an easy problem but I haven't been able to find a solution. I'm looking to add a virtual switch that will show me the status of a group of lights and then be able to shut them all off. I'd like to put all my lights in this group and have a all lights off button. Any help would be great.

    Thanks

    #2
    I use a script to count the number of lights and ceiling fans I have on. The script sets a virtual device to the light and fan number.

    You could probably modify that to suit your needs. Then create an event to turn that group of lights off when you turn the virtual device is off.

    There are multiple ways to skin a cat, this is just the one I use...


    Code:
        Public Sub Main(ByVal Parms As Object)
            ''This will count the number of lights and celing fans which are on and update the appropriate virtual device with the number
            ''This script assumes all ceiling fans have "ceiling fan" in the name and all lights have "light" in the name
            ''The exception is the "north pendent light" which is listed as "north pendent"
    
            ''in the future I may elect to expand this to act on the specified floor; It might be useful to separate outside from inside devices
            ''In my device setup 'first' floor = inside, 'outside' floor is outside
            ''dv.location2 = floor
    
            ''if we are going to specify the floor/location; pass it as a parm and uncomment the next line
            ''Dim FloorName As String = CType(Parms, String)
    
            ''Active_number_lights and Active_number_fan will act as our counters
            Dim Active_number_lights As Integer = 0
            Dim Active_number_fans As Integer = 0
    
    
            ''light and fan virtual device ref numbers
            Dim Global_fan_device_ref As Integer = 150
            Dim Global_light_device_ref As Integer = 149
    
            ''get a list of devices
            Try
                Dim dv As Scheduler.Classes.DeviceClass
                Dim EN As Scheduler.Classes.clsDeviceEnumeration
                EN = hs.GetDeviceEnumerator
                If EN Is Nothing Then
                    hs.WriteLog("count_active_devices", "Error getting Enumerator")
                    Exit Sub
                End If
    
                ''Loop through each device and see if it's a ceiling fan or a light
                Do
                    dv = EN.GetNext
                    If dv Is Nothing Then Continue Do
    
                    ''If we decide To specify the floor Then add In "And dv.Location2(Nothing).Contains(FloorName)" for the main if/then statement
                    ''Scan for devices which are on, and are either zwave multilevel (fans and dimmers) or binary switches (non dimming switches).  Then decide if it's a fan or a light and update the appropriate counter
                    If hs.IsON(dv.Ref(Nothing)) AndAlso (dv.Device_Type_String(Nothing) = "Z-Wave Switch Multilevel" Or dv.Device_Type_String(Nothing) = "Z-Wave Switch Binary") Then
    
                        ''check to see if it's a light or if it's a fan and increment as needed
                        ''check for the north pendant light, and exclude bidet fan and exhaust fan
                        If (dv.Name(Nothing).ToLower.Contains("light") Or dv.Name(Nothing) = "North Pendant") AndAlso Not dv.Name(Nothing).ToLower.Contains("fan") Then
                            Active_number_lights = Active_number_lights + 1
                        ElseIf dv.Name(Nothing).ToLower.Contains("ceiling fan") AndAlso Not dv.Name(Nothing).ToLower.Contains("light") Then
                            Active_number_fans = Active_number_fans + 1
                        End If
                        End If
    
                Loop Until EN.Finished
    
                ''Update the virtual devices, 0 = off and we need to set the device to 'off' not just 0
                ''set lights
                If Active_number_lights = 0 Then
                    hs.CAPIControlHandler(hs.CAPIGetSingleControl(Global_light_device_ref, True, "Off", False, False))
                Else
                    Dim cc As HomeSeerAPI.CAPIControl = hs.CAPIGetSingleControl(Global_light_device_ref, True, "Number: (value)", False, False)
                    cc.ControlValue = Active_number_lights
                    Dim cr As HomeSeerAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)
                End If
    
                ''set ceiling fans
                If Active_number_fans = 0 Then
                    hs.CAPIControlHandler(hs.CAPIGetSingleControl(Global_fan_device_ref, True, "Off", False, False))
                Else
                    Dim cc = hs.CAPIGetSingleControl(Global_fan_device_ref, True, "Number: (value)", False, False)
                    cc.ControlValue = Active_number_fans
                    Dim cr = hs.CAPIControlHandler(cc)
                End If
    
            Catch ex As Exception
                hs.WriteLog("Error", "Exception in script Count Active Devices:  " & ex.Message)
            End Try
    
            hs.SaveEventsDevices()
        End Sub
    Attached Files
    HS4 Pro on Shuttle NC10U, Win10; Z-NET
    Number of Devices: 1005
    Number of Events: 293

    Plug-Ins: BLLock, DirecTv, EasyTrigger, Honeywell WiFi Thermostat, Marquis monoprice Amp, MeiHarmonyHub, PHLocation2, Pushover 3P, UltraM1G3, rnbWeather, Worx Landroid, Z-Wave

    External applications: Homebridge-homeseer, Geofency, EgiGeoZone.

    Comment


      #3
      Originally posted by troy.lynch View Post
      I know this is probably an easy problem but I haven't been able to find a solution. I'm looking to add a virtual switch that will show me the status of a group of lights and then be able to shut them all off. I'd like to put all my lights in this group and have a all lights off button. Any help would be great.

      Thanks
      It would be easiest to use Spud's Easy Trigger plug-in. You can set up an Easy Trigger group of all of the lights you want to monitor/control. Several events would do it. Create a virtual device for "All Lights".

      Then there would be three events.

      Click image for larger version

Name:	Capture.png
Views:	1
Size:	69.3 KB
ID:	1194512

      The first one turns the virtual device OFF if ALL of the lights in the group are OFF.

      The second one turns the virtual device ON if ANY of the lights in the group are ON.

      The third one turns all of the lights in the group OFF whrn the virtual device is turned OFF.
      HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

      Comment


        #4
        Thanks guys. Exactly what I was looking for

        Comment


          #5
          Hi,

          I have already tried a little with this, and just want to hear from your experience about this.

          For me it seems to work 3 out of 4 times.

          But sometimes it goes in the loop, after which lights turn on and off in a loop

          I'm Trigger the event with a z-wave switch and turning on my HUE via jowihue

          I have tried to make a "dummy" bulb, and use this as a status, and turn this device on in my "light - on" event - which I use for status when I thought my HUE lamps were too long to update the status - but it did not change anything

          Have you experienced similar - and possibly. found a solution

          / Lars

          Comment


            #6
            Originally posted by thobiasen View Post
            Hi,

            I have already tried a little with this, and just want to hear from your experience about this.

            For me it seems to work 3 out of 4 times.

            But sometimes it goes in the loop, after which lights turn on and off in a loop

            I'm Trigger the event with a z-wave switch and turning on my HUE via jowihue

            I have tried to make a "dummy" bulb, and use this as a status, and turn this device on in my "light - on" event - which I use for status when I thought my HUE lamps were too long to update the status - but it did not change anything

            Have you experienced similar - and possibly. found a solution

            / Lars

            My setup is for information purposes only, however I find it to be very accurate. My suggestion is to use an event to monitor your virtual device. When it's set to off turn off; use that event to turn off the lights in that group.
            HS4 Pro on Shuttle NC10U, Win10; Z-NET
            Number of Devices: 1005
            Number of Events: 293

            Plug-Ins: BLLock, DirecTv, EasyTrigger, Honeywell WiFi Thermostat, Marquis monoprice Amp, MeiHarmonyHub, PHLocation2, Pushover 3P, UltraM1G3, rnbWeather, Worx Landroid, Z-Wave

            External applications: Homebridge-homeseer, Geofency, EgiGeoZone.

            Comment

            Working...
            X