Announcement

Collapse
No announcement yet.

Unifi Controller Wifi user connect/disconnect data

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

    #61
    There seems to be a problem with UltraLog not triggering events even though the conditions have been met. Unfortunately this has rendered the plugin UniFi method useless for me. What a shame. The problem seems to be on the HS side. I am trying to find the post where the developer had responded to me and said it was a problem with HS3 to see if there is a workaround or anything we can do to make this work.

    Comment


      #62
      I don't know what to tell you. All I can say is that's it's rock solid for me. It's much more reliable than my Z-Wave network, for example. Hopefully UltraJones can help you sort this one out.
      Originally posted by rprade
      There is no rhyme or reason to the anarchy a defective Z-Wave device can cause

      Comment


        #63
        EDIT 15.01.19: The script is now updated to work both with AP version 3.x and AP version 4.x (logs differently)
        However, the script does not function as intended, if you have a lot of disconnects.
        I wish to implement the following:
        when disconnection is recieved: wait 1minute before disconnecting. if a reconnect appears within this timeframe, ignore the disconnect)
        i've reached the maximum number of attachments for this post, so I'll add another post with further explanation, in hope someone can help :-)
        //EDIT


        I know this is an old post, but I'm replying, in case someone else wants to try this, and might need a helping hand.
        Because of this thread, and @S-Fs great info, I decided to try this myself, and can now log devices across AP's, and log them out when they disappear.
        The steps I took are as follows

        1: Enable Remote Logging from the unifi controller. click Settings -> Site ->Enable remote Syslog server
        Add the ip adress of your homeseer server and a port number (default: 514).
        Click image for larger version  Name:	remote logging.jpg Views:	1 Size:	11.5 KB ID:	1275978

        2: in homeseer add the plugin UltraLog3, make sure in config that you set "Enable Syslog on startup" (I chose Logging severity: informational), and the same UDP port you chose in unifi controller (default 514)
        Click image for larger version  Name:	ultralog3.jpg Views:	1 Size:	57.4 KB ID:	1275979

        Then I pondered a bit about how to track my phone. I could make one event for each access point, that triggers "when <something> associates to it", but that would give me 5 events per. phone/device I want to track... and also it'd be hell to update whenever I change my phone to a newer one... so instead, I decided to try making a script.
        Note that the code is not nessecarily good, as this is not my field of expertise, but hey. it works..ish

        first off: for each phone/device you -want- to track, make a virtual device in homeseer.
        in the -address- field of your virtual phone/device, set the phones MAC address (that way it's easy whenever you change your phone, simply change the MAC)
        Click image for larger version  Name:	homseer_virtual_device.jpg Views:	1 Size:	27.8 KB ID:	1275980


        The phone will get its device string set by the name you give your access points in the script:

        Click image for larger version  Name:	example.jpg Views:	1 Size:	35.5 KB ID:	1275939

        Then create a <somefilename.vb> in the homeseer\scripts folder, and paste the attached code into it.

        finally, create an event that fires whenever UltraLog Msg Content Contains "IEEE 802.11:" that runs the script
        Click image for larger version  Name:	script.jpg Views:	1 Size:	85.9 KB ID:	1275981

        NOTE: I've made a lot of comments in the code, so it should be easy to understand.
        at a minimum, you'll need to alter the following parts (marked red in the code)
        * The DeviceID's of DeviceInfo(0,0), DeviceInfo(1,0) etc to match your devices reference IDs
        Click image for larger version  Name:	ref_id.jpg Views:	1 Size:	29.6 KB ID:	1275983

        * the MAC addresses of the Access Points. You can easily find them in your unifi controller, just click on your AP s to see their MACs..

        Do note that they log without ":" into UltraLog3 so if your MAC-address is "11:ab:22:cd:33" then you add that in the script as "11ab22cd33"!


        Code:
        Sub Main(ByVal Parms As Object)
        
        [COLOR=#008000]'------Beforehand: Make virtual devices containing the MAC of the Device/devices you want to track in the -address- field. (easy when you at some point get a new Device, just change the MAC).
        'note: if adding more devices, remember to increase _DeviceInfo array and _DeviceNumbers! ----------
        '---set timer for disassociation; e.g. time to wait before disconnecting the device here (seconds)---[/COLOR]
        dim _timer as integer [COLOR=#008000]'seconds[/COLOR]
        _timer = [COLOR=#FF0000]60[/COLOR]
        dim _SysLogType as string
        _SysLogType = "[COLOR=#FF0000]Phone[/COLOR]" [COLOR=#008000]' set name of Type/Error you want to see in Homeseer Log[/COLOR]
        
        Try
        [COLOR=#006400]'---first let's make a matrix containing the device names and device MAC adresses we want to track, and then check if the logmessage that triggered this scropt concerns a Device/device in this list---
        ' It'll look something like this:[/COLOR]
        [COLOR=#008000]'
        '| Matrix: DeviceInfo(x,y)   |
        '|-------------|-------------|
        '| My Phone    | ab:11:22:33 |
        '|-------------|-------------|
        '| Wifes Phone | aa:cc:11:22 |
        '|-------------|-------------|
        '| iPad        | ba:13:24:11 |
        '|-------------|-------------|[/COLOR]
        
        dim _DeviceNumbers as integer
        _DeviceNumbers = 3 [COLOR=#008000]'same as in matrix![/COLOR]
        dim _DeviceInfo (_DeviceNumbers,2)
        _DeviceInfo(0,0) = hs.DeviceName([COLOR=#FF0000]751[/COLOR]) [COLOR=#008000]' my Device[/COLOR]
        _DeviceInfo(0,1) = hs.GetDeviceCode(_DeviceInfo(0,0)) [COLOR=#008000]'my devices MAC[/COLOR]
        
        _DeviceInfo(1,0) = hs.DeviceName([COLOR=#FF0000]1116[/COLOR]) [COLOR=#008000]' Wifes Device[/COLOR]
        _DeviceInfo(1,1) = hs.GetDeviceCode(_DeviceInfo(1,0)) [COLOR=#008000]',wifes MAC[/COLOR]
        
        _DeviceInfo(2,0) = hs.DeviceName([COLOR=#FF0000]1117[/COLOR]) [COLOR=#008000]' an iPad[/COLOR]
        _DeviceInfo(2,1) = hs.GetDeviceCode(_DeviceInfo(2,0)) [COLOR=#008000]'iPad MAC[/COLOR]
        [COLOR=#008000]'Note to self: Should DeviceInfo be a global variable set at HS startup instead? performance?[/COLOR]
        
        [COLOR=#008000]'---unfortunately UniFi logs differently if your AP has FW 4.0 or higher than it does if your F.W. is 3.x
        'to overcome this, we do a check to see if the message tag is from "hostapd" (FW 3.x) or if it logs the AP MAC instead.[/COLOR]
        dim _FWcheck as integer
        
        if GetHomeSeerVariable("SyslogMsgTag") <> "hostapd" then
              _FWcheck = 4 'AP has firmware 4.x
        else
              _FWcheck = 3 'AP has firmware 3.x
        end if
        
        Dim _UserArray(_FWcheck+3) [COLOR=#008000]' Create an Array of the Syslog message to recieve MAC and association level of the logged event[/COLOR]
        _UserArray=Split(GetHomeSeerVariable("SyslogMsgContent")," ")
        
        Dim _LoggedMAC As String = _UserArray(_FWcheck-1) [COLOR=#008000]'this contains the MAC of Device/tablet that's been logged
        'Lets check if the logged message belongs to one of the Devices in our matrix, exit sub if it doesn't.[/COLOR]
        dim _DeviceinList as boolean
        dim _DeviceName as string
        _DeviceinList = false [COLOR=#008000]'default[/COLOR]
        
        Select Case _LoggedMAC
              Case _DeviceInfo(0,1)
                    _DeviceinList = true
                    _DeviceName = _DeviceInfo(0,0)
              Case _DeviceInfo(1,1)
                    _DeviceinList = true
                    _DeviceName = _DeviceInfo(1,0)
              Case _DeviceInfo(2,1)
                    _DeviceinList = true
                    _DeviceName = _DeviceInfo(2,0)
        [COLOR=#008000]'Case _DeviceInfo(3,0) etc etc etc [/COLOR]
        [COLOR=#008000]      ' _DeviceinList = true[/COLOR]
        [COLOR=#008000]      ' _DeviceName = _DeviceInfo(0,0)[/COLOR]
        
        End select
        
        If _DeviceinList = False then Exit Sub
        
        Dim _APArray(3) [COLOR=#008000]' Get AccessPoint MAC address from LOG[/COLOR]
        
        Select case _FWcheck
              case 4
                    _APArray=Split(GetHomeSeerVariable("SyslogMsgTag"),",")
              case 3
                    _APArray=Split(GetHomeSeerVariable("SyslogHostname"),",")
        End select
        
        Dim _APmac As String = _APArray(1)[COLOR=#008000] ' = MAC of AccessPoint[/COLOR]
        dim _APName as string [COLOR=#008000]' name to show in device string when connected[/COLOR]
        
        Select Case _APmac
             Case "[COLOR=#FF0000]garageMAChere[/COLOR]" [COLOR=#008000]' MAC address of your access point, e.g. 11aa22bb33cc[/COLOR]
                  _APName = "[COLOR=#FF0000]garage[/COLOR]"
             Case "[COLOR=#FF0000]cinemaMAChere[/COLOR]"
                  _APName = "[COLOR=#FF0000]cinema[/COLOR]"
             Case "[COLOR=#FF0000]hallwayMAChere[/COLOR]"
                  _APName = "[COLOR=#FF0000]hallway[/COLOR]"
             Case "[COLOR=#FF0000]livingroomMAC[/COLOR]"
                  _APName = "[COLOR=#FF0000]livingroom[/COLOR]"
             Case "[COLOR=#FF0000]officeMAC[/COLOR]"
                  _APName = "[COLOR=#FF0000]office[/COLOR]"
             Case "[COLOR=#FF0000]outdoorMAC[/COLOR]"
                  _APName = "[COLOR=#FF0000]outdoor[/COLOR]"
        End Select
        
        Dim _Association_type As String = _UserArray(_FWcheck+2)[COLOR=#008000] 'Associated or Disassociated[/COLOR]
        
        Select Case _Association_type
             Case "associated" [COLOR=#006400]'device is connected[/COLOR]
                  hs.SetDeviceStringByName(_DeviceName,_APName,true) [COLOR=#008000]' change device string to name of AP location[/COLOR]
                  if hs.DeviceValueByName(_DeviceName) = 0 then hs.SetDeviceValueByName(_DeviceName,100) [COLOR=#008000]' if device was disconnected, turn on[/COLOR]
                  hs.WriteLog(_SysLogType, String.Format("Device {0} is connected {1}",_DeviceName,_APName))
                  if hs.DeviceValueByName("HouseOccupancy") = 0 Then hs.SetDeviceValueByName("HouseOccupancy",100)[COLOR=#006400] 'turn on virutal device to show that someone is in the house[/COLOR]
        
             Case "disassociated"[COLOR=#008000] 'see if Device is disconnected or if it just switched AP[/COLOR]
        
        [COLOR=#008000]'***********************************************************************************************************************
        'this is where I need help: how to ignore disassociated if it reconnects within given time?
        'Threading.Thread.Sleep((_timer*1000))
        '***********************************************************************************************************************[/COLOR]
        
                  if hs.DeviceValueByName(_DeviceName) = 0 Then Exit Sub[COLOR=#008000] 'allready out NOTE: SHOULD NOT HAPPEN![/COLOR]
                  if hs.DeviceStringByName(_DeviceName) = _APName then [COLOR=#008000]'meaning device has logged out from the same AP it was last connected to[/COLOR]
                       hs.SetDeviceStringByName(_DeviceName,"not home",true) [COLOR=#008000]'or rather log out to see where it was last logged in?[/COLOR]
                       hs.SetDeviceValueByName(_DeviceName,0)
                       hs.WriteLog(_SysLogType, String.Format("Device {0} is disconnected",_DeviceName))
        
        [COLOR=#008000]'--following code is to see if -anyone- is in the house or not (i.e. if all devices has logged out, house is empty)[/COLOR]
        [COLOR=#008000]'this is for the posibillity to control heaters etc...[/COLOR]
                       dim houseoccupancy as boolean
                       houseoccupancy = false
                       dim _iloop as integer
                       For _iloop = 0 to _DeviceNumbers
                            if hs.DeviceValueByName(_DeviceInfo(_iloop,0)) = 100 then
                                 houseoccupancy = true
                                 exit for
                            end if
                       next _iloop
                       if houseoccupancy = false then
                            hs.SetDeviceValueByName("HouseOccupancy",0) [COLOR=#008000]'NOTE: I have a virtual device called "HouseOccupancy!"[/COLOR]
                       end if
        [COLOR=#008000]'--------------------------------------------------[/COLOR]
                  else
                       hs.WriteLog(_SysLogType, String.Format("Device {0} switched from AP {1} to AP {2}",_DeviceName,_APName,hs.DeviceStringByName(_DeviceName)))
                  end if
        End Select
        
        Catch pEx As Exception
        [COLOR=#008000]'
        ' Process program exception
        '[/COLOR]
        hs.WriteLog("Error", pEx.Message)
        End Try
        End sub
        
        Function GetHomeSeerVariable(ByVal strVariableName As String) As String
        Dim strVariableValue As String = String.Empty
        Try
             Dim objObject As Object = hs.GetVar(strVariableName)
             If TypeOf objObject Is String Then
                  strVariableValue = CStr(objObject)
             End If
             objObject = Nothing
             Catch pEx As Exception
        [COLOR=#008000]' Ignore errors[/COLOR]
        End Try
        Return strVariableValue
        End Function
        Hope this helps someone along!
        Last edited by RazAquato; January 15, 2019, 05:59 AM. Reason: updating script

        Comment


          #64
          Thanks for sharing

          Sent from my SM-G935V using Tapatalk

          Comment


            #65
            Thanks for sharing.

            Comment


              #66

              As stated in my above post, unfortunately the script does not function as I intend.
              I fixed the problem where the APs have different firmwares, but unfortunately it triggers on a lot of unwanted dropouts (for example if a phone disconnects for 10 seconds from the same Access point, then reconnects)

              Also, the log from UniFi does not always log "Associated" then "Disassociated"... - it might be random, which can result in a device beeing diconnected in homeseer when in fact it is conneted to an AP.

              See Attached Image for an example of a log from my system where the messages trigger the script, how the script parses it, and how I wish for it to behave. (Read from bottom to top)

              Note the yellow lines is from an access point that runs firmware 4.x, and how it includes the IP address in the "Source" field, meaning the rest of the message "shifts" to the right in the log.

              Lastly I am unsure whether the script fires twice when the date-stamp in the log is within the same second, if the script takes some time to complete.
              Any help would be appreciated, as scripting is not my strong suit.
              - I assume I need a virtual timer, but maybe in a matrix that also holds the MAC of the device or similar?
              An other alternative is to have a separate script pr. device but I hope to contain it within one .vb file.....

              (I've color-coded the script in the above post in hope to make it easy to read.)

              Comment


                #67
                How to track phones/wifi-connected devices in a building with UniFi Access Points

                Click image for larger version  Name:	fetch?id=1275939&amp;d=1547469410.jpg Views:	1 Size:	51.9 KB ID:	1277071


                Edit: do note that the following approach reads the server.log file on the UniFi controller.
                This works a lot slower than if you have enabled "remote logging" and handle the calls from the access points directly.
                See this thread for explanation.

                After writing this script, I have personally changed to remote logging and altered my script to handle ASYNC calls from all my APs
                (note: you can enable remote logging to 127.0.0.1 and let the UniFi controller act as a dedicated rsyslog) .

                The method posted below works well for examples like "
                when I'm in the office and the doorbell rings, flash the office lights".
                However, "
                when I get up in the morning, turn on the lights in the livingroom to 20% dim" does not work as expected, as it may take up to a full minute before the unifi controller registers that you switched AP; and this is simply too slow to function as a "lightswitch"

                my altered script executes immediately when changing AP, but delay 30+seconds on AP disconnection (so I have time to kills the call if my device reconnects within the given timeframe to the same AP)
                IF anyone is interested in how I did this, just let me know and I'll post (yet another) script; that should also work with UltraLog3 if you alter it a bit
                ----------------------------------------


                in homeseer, You need to create virtual devices for your phones.
                on the UniFi controller, install swatch (or swatchdog) and cURL.

                Then create a service file /etc/init.d/swatchd that you can start at boot, containing the following code: (note the name of the config file)
                Code:
                start()
                {
                    /usr/bin/swatch --config-file=[COLOR=#FF0000]/etc/swatch/wifilog.conf[/COLOR] --tail-file=/var/log/unifi/server.log --pid-file=/var/run/swatch/swatch-wifi.pid --daemon > /dev/null >&1
                }
                stop()
                {
                [COLOR=#EE82EE]PID[/COLOR]=`cat /var/run/swatch/swatch-wifi.pid`
                    kill [COLOR=#EE82EE]$PID[/COLOR]
                }
                case [COLOR=#EE82EE]$1[/COLOR] in
                start)
                    start
                    exit 0 ;;
                stop)
                    stop
                    exit 0 ;;
                restart)
                    stop
                    start
                exit 0 ;;
                
                *)
                    echo "Usage: [COLOR=#EE82EE]$0[/COLOR] { start | stop | restart }"
                    exit 1 ;;
                
                esac
                Then make an excecutable script /etc/swatch/devchange that is to be excecuted whenever a defined device is connected to a defined access point, containing the following code. (note: I have 3 devices I want to track, add more lines if needed) also remember to chmod +x /etc/swatch/devchange to make it excecutable

                changes you need to make in the code: every red line.
                (deviceref = the deviceID of your virtual device in homeseer.)

                note: whatever you set as devicenames must be reflected in the swatch config file you make later on.
                Code:
                [COLOR=#008000]#!/bin/bash
                #useage: ./devchange <phonename> <apname>[/COLOR]
                value="100"
                if [ [COLOR=#EE82EE]$2[/COLOR] = "disconnected" ]; then
                   value="0"
                fi
                case "[COLOR=#EE82EE]$1[/COLOR]" in
                   "[COLOR=#FF0000]deviceAName[/COLOR]")
                      curl "http://[COLOR=#FF0000]homeseerIP[/COLOR]/JSON?request=setdeviceproperty&ref=[COLOR=#FF0000]xxx[/COLOR]&property=NewDevString&value=$2"
                      curl "http://[COLOR=#FF0000]homeseerIP[/COLOR]/JSON?request=controldevicebyvalue&ref=[COLOR=#FF0000]xxx[/COLOR]&value=$value"
                     ;;
                   "[COLOR=#FF0000]ipad[/COLOR]")
                     curl "http://[COLOR=#FF0000]homeseerIP[/COLOR]/JSON?request=setdeviceproperty&ref=[COLOR=#FF0000]yyy[/COLOR]&property=NewDevString&value=$2"
                     curl "http://[COLOR=#FF0000]homeseerIP[/COLOR]/JSON?request=controldevicebyvalue&ref=[COLOR=#FF0000]yyy[/COLOR]&value=$value"
                     ;;
                   "[COLOR=#FF0000]deviceCName[/COLOR]")
                     curl "http://[COLOR=#FF0000]homeseerIP[/COLOR]/JSON?request=setdeviceproperty&ref=[COLOR=#FF0000]zzz[/COLOR]&property=NewDevString&value=$2"
                     curl "http://[COLOR=#FF0000]homeseerIP[/COLOR]/JSON?request=controldevicebyvalue&ref=[COLOR=#FF0000]zzz[/COLOR]&value=$value"
                     ;;
                esac
                finally, make the swatch config file that checks the log file for connections and fires devchange whenever it gets a hit, for example "devchange deviceAname disconnected"
                file /etc/swatch/wifilog.conf to contain the following code (alter to fit your MAC addresses and names:
                Code:
                [COLOR=#008000]#####DEVICES####[/COLOR]
                perlcode my [COLOR=#EE82EE]$device_a[/COLOR] = '[COLOR=#FF0000]MACaddressOfMyPhone[/COLOR]';
                perlcode my [COLOR=#EE82EE]$device_b[/COLOR] = '[COLOR=#FF0000]MACaddressOfiPad[/COLOR]';
                perlcode my [COLOR=#EE82EE]$device_c[/COLOR] = '[COLOR=#FF0000]00:aa:11:bb:22:cc[/COLOR]';
                
                [COLOR=#008000]####ACCESS_POINTS####[/COLOR]
                perlcode my [COLOR=#EE82EE]$AP_office[/COLOR] = '[COLOR=#FF0000]MACaddressOfOfficeAP[/COLOR]';
                perlcode my [COLOR=#EE82EE]$AP_livingroom[/COLOR] = '[COLOR=#FF0000]00:aa:11:bb:22:cd[/COLOR]';
                perlcode my [COLOR=#EE82EE]$AP_garage[/COLOR] = '[COLOR=#FF0000]00:aa:11:bb:22:ce[/COLOR]';
                perlcode my [COLOR=#EE82EE]$AP_cinema[/COLOR] = '[COLOR=#FF0000]00:aa:11:bb:22:cf[/COLOR]';
                perlcode my [COLOR=#EE82EE]$AP_bedroom[/COLOR] = '[COLOR=#FF0000]00:aa:11:bb:22:bc[/COLOR]';
                perlcode my [COLOR=#EE82EE]$AP_outdoor[/COLOR] = '[COLOR=#FF0000]00:aa:11:bb:22:dc[/COLOR]';
                perlcode my [COLOR=#EE82EE]$seconds[/COLOR] = '[COLOR=#FF0000]30[/COLOR]';
                
                
                [COLOR=#008000]#####################DEVICE_A#######################[/COLOR]
                [COLOR=#008000]#trigger if device a has connected to office or roams from another AP to office[/COLOR]
                watchfor /(\b\[[COLOR=#EE82EE]$device_a[/COLOR]\b.+\bhas connected to AP\[[COLOR=#EE82EE]$AP_office[/COLOR]\b)|(\b\[[COLOR=#EE82EE]$device_a[/COLOR]\b.+\broams\b.+\bto AP\[[COLOR=#EE82EE]$AP_office[/COLOR]\b)/
                exec /etc/swatch/devchange [COLOR=#FF0000]deviceAName office[/COLOR]
                threshold type=limit, seconds=$seconds
                
                [COLOR=#008000]#trigger if device a has connected to livingroomor roams from another AP to livingroom[/COLOR]
                watchfor /(\b\[[COLOR=#EE82EE]$device_a[/COLOR]\b.+\bhas connected to AP\[[COLOR=#EE82EE]$AP_livingroom[/COLOR]\b)|(\b\[[COLOR=#EE82EE]$device_a[/COLOR]\b.+\broams\b.+\bto AP\[[COLOR=#EE82EE]$AP_livingroom[/COLOR]\b)/
                exec /etc/swatch/devchange [COLOR=#FF0000]deviceAName livingroom[/COLOR]
                threshold type=limit, seconds=$seconds
                
                [COLOR=#008000]#trigger if device a has connected to bedroom..etc..[/COLOR]
                watchfor /(\b\[[COLOR=#EE82EE]$device_a[/COLOR]\b.+\bhas connected to AP\[[COLOR=#EE82EE]$AP_bedroom[/COLOR]\b)|(\b\[[COLOR=#EE82EE]$device_a[/COLOR]\b.+\broams\b.+\bto AP\[[COLOR=#EE82EE]$AP_bedroom[/COLOR]\b)/
                exec /etc/swatch/devchange [COLOR=#FF0000]deviceAName bedroom[/COLOR]
                threshold type=limit, seconds=$seconds
                
                [COLOR=#008000]#...etc...etc.. for all Access Points[/COLOR]
                
                [COLOR=#008000]#####################DEVICE_B#######################
                #trigger if device b has connected to office[/COLOR]
                watchfor /(\b\[[COLOR=#EE82EE]$device_b[/COLOR]\b.+\bhas connected to AP\[[COLOR=#EE82EE]$AP_office[/COLOR]\b)|(\b\[[COLOR=#EE82EE]$device_b[/COLOR]\b.+\broams\b.+\bto AP\[[COLOR=#EE82EE]$AP_office[/COLOR]\b)/
                exec /etc/swatch/devchange [COLOR=#FF0000]ipad office[/COLOR]
                threshold type=limit, seconds=$seconds
                
                [COLOR=#008000]#trigger if device b has connected to livingroom[/COLOR]
                watchfor /(\b\[[COLOR=#EE82EE]$device_b[/COLOR]\b.+\bhas connected to AP\[[COLOR=#EE82EE]$AP_livingroom[/COLOR]\b)|(\b\[[COLOR=#EE82EE]$device_b[/COLOR]\b.+\broams\b.+\bto AP\[[COLOR=#EE82EE]$AP_livingroom[/COLOR]\b)/
                exec /etc/swatch/devchange[COLOR=#FF0000] ipad livingroom[/COLOR]
                threshold type=limit, seconds=$seconds
                
                [COLOR=#008000]#trigger if device b has connected to bedroom[/COLOR]
                watchfor /(\b\[[COLOR=#EE82EE]$device_b[/COLOR]\b.+\bhas connected to AP\[[COLOR=#EE82EE]$AP_garage[/COLOR]\b)|(\b\[[COLOR=#EE82EE]$device_b[/COLOR]\b.+\broams\b.+\bto AP\[[COLOR=#EE82EE]$AP_garage[/COLOR]\b)/
                exec /etc/swatch/devchange[COLOR=#FF0000] ipad garage[/COLOR]
                threshold type=limit, seconds=$seconds
                
                [COLOR=#008000]#..etc..etc[/COLOR]
                and that's it. seems to work a lot more stable than my attempt with Ultralog.
                only drawback is that when you change your phone to a new one, you'll need to update the MAC address in the swatch config file rather than just in homeseer.

                extra: how-to trigger virtual switch if motion detected on UniFi video cameras (linking as it is UniFi related, and contains same type of approach)
                Last edited by RazAquato; January 28, 2019, 08:50 AM. Reason: added comment in red

                Comment


                  #68
                  Are running the PC based controller and not a CloudKey ?
                  HS3 SEL running Pro Edition 3.0.0.531 on Ubuntu 18.04, mono 5.20, 656 devices, 209 events.
                  Plug-Ins: Chromecast, Device History, EasyTrigger, Ecobee, JowiHue, LutronCaseta, MeiUnifi, PHLocation2, Pushover 3P, SDJ-Health, Sonos, WeatherFlow, weatherXML
                  Scripts: SparkMan's Lock Event, 5 of Jon00 scripts.

                  Comment


                    #69
                    Originally posted by drparker151 View Post
                    Are running the PC based controller and not a CloudKey ?
                    My controller is on PC, yes. Unfortunately I am not familiar with CloudKey..but assume you don't have direct access to the OS?

                    If that's the case, then remote logging is the only way to go I think. - I also wrote a script running ultralog further up in this post. It is not stable, but can easily be modified to function better (for example by splitting it to two scripts, one for 'connected' and one for 'disconnected')

                    Comment

                    Working...
                    X