www.homeseer.com    
 

Go Back   HomeSeer Message Board > HomeSeer Products & Services > HomeSeer Software

HomeSeer Software Discussions regarding all current HomeSeer software

Reply
 
Thread Tools Display Modes
  #1  
Old December 23rd, 2017, 10:41 PM
troy.lynch troy.lynch is offline
Seer
 
Join Date: Dec 2017
Location: Rockford, IL
Posts: 62
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
Reply With Quote
  #2  
Old December 23rd, 2017, 11:06 PM
jmaddox jmaddox is offline
Seer Deluxe
 
Join Date: Oct 2010
Location: Dallas, Texas
Posts: 186
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 Images
  
__________________
HS3 Pro on Hometroller S6 with Z-NET
Number of Devices: 143
Number of Events: 87

Plug-Ins: BLLock, DoorBird, Honeywell WiFi Thermostat, HSTouch Server, Restart, Z-Wave, EasyTrigger, PHLocation, Pushover 3P

External applications: Homebridge-homeseer, Geofency
Reply With Quote
  #3  
Old December 23rd, 2017, 11:23 PM
rprade's Avatar
rprade rprade is online now
OverSeer
 
Join Date: Jan 2014
Location: Colorado
Posts: 6,712
Quote:
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.

Name:  Capture.png
Views: 115
Size:  69.3 KB

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

PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino
Reply With Quote
  #4  
Old December 24th, 2017, 02:14 AM
troy.lynch troy.lynch is offline
Seer
 
Join Date: Dec 2017
Location: Rockford, IL
Posts: 62
Thanks guys. Exactly what I was looking for
Reply With Quote
  #5  
Old December 25th, 2017, 05:01 PM
thobiasen thobiasen is offline
Seer
 
Join Date: Dec 2017
Location: Danmark
Posts: 7
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
Reply With Quote
  #6  
Old December 25th, 2017, 06:35 PM
jmaddox jmaddox is offline
Seer Deluxe
 
Join Date: Oct 2010
Location: Dallas, Texas
Posts: 186
Quote:
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.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set the value of a virtual switch ? mikee123 HS3 Scripting 2 July 16th, 2016 10:52 AM
Copy zwave wall switch status to HUE light. zyx JowiHue Plug-In 5 March 4th, 2016 11:50 AM
Light switch with instant status denisl HomeSeer Z-Wave Plug-in 4 June 14th, 2015 10:34 PM
HS3 Script Syntax to copy one virtual device status string to another virtual device pjohnson HS3 Scripting 8 December 31st, 2014 02:48 PM
Trying to set the status of a virtual device on the status change of multiple devices scott12v HS2 / HSPRO 5 October 17th, 2009 01:12 PM


All times are GMT -4. The time now is 11:19 PM.


Copyright HomeSeer Technologies, LLC