Presence detection using UniFi Controller and DzVents  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

rgroothuis
Posts: 347
Joined: Friday 03 April 2015 17:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Presence detection using UniFi Controller and DzVents

Post by rgroothuis »

Different question on the same topic, presence detection on UniFi controller. How do you handle the situation of Apple devices using this "private address" option? Where the Apple device uses a different MAC address each time?
Delfuego
Posts: 32
Joined: Sunday 29 July 2018 16:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands
Contact:

Re: Presence detection using UniFi Controller and DzVents

Post by Delfuego »

Because using a different mac address each time you log in is especially useful on other wifi networks, I turned off this private option for my own wifi on all Apple devices.

You can turn this off separately for each wifi network.
rgroothuis
Posts: 347
Joined: Friday 03 April 2015 17:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Presence detection using UniFi Controller and DzVents

Post by rgroothuis »

Delfuego wrote: Monday 22 March 2021 14:33 Because using a different mac address each time you log in is especially useful on other wifi networks, I turned off this private option for my own wifi on all Apple devices.

You can turn this off separately for each wifi network.
Thanks, I know and understand that you can switch it off. But what about situation where Apple users don't want to switch it off?
It would be great if presence detection can also be done on the name of the device.
Delfuego
Posts: 32
Joined: Sunday 29 July 2018 16:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands
Contact:

Re: Presence detection using UniFi Controller and DzVents

Post by Delfuego »

OK but that's not a problem. You can also select on the names of devices in the script. Just replace MAC address with the name of the device. That works too.

For example

Code: Select all

local Mac = {'11:aa:22:bb:33:cc' , '11:aa:22:bb:33:cc' , '11:aa:22:bb:33:cc' , '11:aa:22:bb:33:cc' , '11:aa:22:bb:33:cc' }  --Change to mac addresses of devices you want to monitor
replaced by

Code: Select all

local Mac = {'iPhone John' , 'iPhone Doe' , 'iPhone Jane' , 'iPhone John Doe' , 'iPhone Jane Doe' }  --Change to names of devices you want to monitor
Everything else just stays the same. So the only point is that people can use the same name for their device.
rgroothuis
Posts: 347
Joined: Friday 03 April 2015 17:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Presence detection using UniFi Controller and DzVents

Post by rgroothuis »

Delfuego wrote: Monday 22 March 2021 15:14 OK but that's not a problem. You can also select on the names of devices in the script. Just replace MAC address with the name of the device. That works too.

For example

Code: Select all

local Mac = {'11:aa:22:bb:33:cc' , '11:aa:22:bb:33:cc' , '11:aa:22:bb:33:cc' , '11:aa:22:bb:33:cc' , '11:aa:22:bb:33:cc' }  --Change to mac addresses of devices you want to monitor
replaced by

Code: Select all

local Mac = {'iPhone John' , 'iPhone Doe' , 'iPhone Jane' , 'iPhone John Doe' , 'iPhone Jane Doe' }  --Change to names of devices you want to monitor
Everything else just stays the same. So the only point is that people can use the same name for their device.
Excellent, I didn't realise that is was already possible.
I'm testing it right now. And indeed, I'm aware about the fact that the device name can be changed as well. Thanks.
labrag12
Posts: 14
Joined: Monday 15 March 2021 16:47
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Presence detection using UniFi Controller and DzVents

Post by labrag12 »

Hi Luuk,

i checked, and i'm using default site as controller.
this is the script i use

Code: Select all

return {
   on = {
      timer = { 'every 5 minutes' },
      httpResponses = { 'loggedin' , 'data' }
   },
   execute = function(domoticz, item)
        if (item.isTimer) then
            domoticz.openURL({
                url = 'https://192.168.2.12:8443/api/login',  --Change IP and Port to your Unifi Controller settings
                method = 'POST',
                postData = { ['password'] = '*********' , ['username'] = '**********' }, --Change YourPassword en YourUsername to your password en username for Unifi Controller (I advice to create a separate read-only admin in your Unifi controller with only system stats access)
                callback = 'loggedin'
         })
        end
        if (item.isHTTPResponse and item.ok) then
            if (item.trigger == 'loggedin') then
                domoticz.openURL({
                url = 'https://192.168.2.12:8443/api/s/default/stat/sta',  --Change IP and Port to your Unifi Controller settings
                method = 'GET',
                callback = 'data'
                })
            else    
                            
                local Mac = {'de:1c:4c:06:bf:62' , '60:1d:91:cb:b0:2d' }  --Change to mac addresses of devices you want to monitor
                local DzIndx = {13,14}  --Change to Domiticz Idx, the position in DxIndx has to be the same as the mac adress for that device in Mac (previous line)
                for i,y in ipairs(Mac)
                do
                    home = string.find( item.data , Mac[i])
                    if (home == nil) then
                        domoticz.devices(DzIndx[i]).switchOff().checkFirst()
                    else
                        domoticz.devices(DzIndx[i]).switchOn().checkFirst()
                    end
                end    
            end
        end    
   end 
}
Delfuego
Posts: 32
Joined: Sunday 29 July 2018 16:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands
Contact:

Re: Presence detection using UniFi Controller and DzVents

Post by Delfuego »

I checked your script and think it is fine. (btw. please post scripts using Code display button in the future)

It also seems like the connection to the Unifi API is there because the error is reporting on httpResponses: 'loggedin". So please check if the username/password combination is correct and that this user has enough rights. For the purpose of this script I created a admin account in Unifi controller with only reading rights.

Hope this helps.
rgroothuis
Posts: 347
Joined: Friday 03 April 2015 17:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Presence detection using UniFi Controller and DzVents

Post by rgroothuis »

Regarding checking on a device name instead of MAC address, I'm trying this but it doesn't work.

Some code snippets and debug information:
local devices = { -- all lower case!
['iphone-van-isis'] = 111
}
I've added: string.lower to make sure it is due to a mismatch in upper or lower case characters.
local isPresent = string.find(string.lower(item.data), mac)
Debug info:
2021-03-24 11:57:01.695 Status: dzVents: Debug: CheckiPhoneAtHome: ** Mac:iphone-van-isis- Item data:{"meta":{"rc":"ok"},"data":[{"site_id":"5ebbc931903a37906ea3c3e4","assoc_time":1616580489,"latest_assoc_time":1616583383,"oui":"","user_id":"6048cea011850100157b58c3","_id":"6048cea011850100157b58c3","mac":"xxxxxxx","is_guest":false,"first_seen":1615384224,"last_seen":1616583412,"is_wired":false,"hostname":"iPhone-van-Isis","_uptime_by_ugw":18,"_last_seen_by_ugw":1616583401,"_is_guest_by_ugw":false,"gw_mac":"e0:xxxxxxf:55","network":"LAN","network_id":"5ebbc933903a37906ea3c3f3","ip":"192.168.0.232","uptime":2923,"tx_bytes":6986509,"rx_bytes":6847601,"tx_packets":12056,"tx_retries":3475,"wifi_tx_attempts":15481,"rx_packets":12237,"bytes-r":5,"tx_bytes-r":3,"rx_bytes-r":2,"authorized":true,"qos_policy_applied":true,"_uptime_by_uap":2923,"_last_seen_by_uap":1616583412,"_is_guest_by_uap":false,"ap_mac":"74:83:c2:da:24:3d","channel":40,"radio":"na","radio_name":"rai0","essid":"HoekHuis","bssid":"7xxxxxx3f","powersave_enabled":true,"is_11r":true,"ccq":0,"rssi":37,"noise":-96,"signal":-59,"tx_rate":270000,"rx_rate":360000,"tx_power":0,"idletime":2,"dhcpend_time":460,"satisfaction":97,"anomalies":0,"vlan":0,"radio_proto":"ac","_uptime_by_usw":150,"_last_seen_by_usw":1616583371,"_is_guest_by_usw":false,"sw_mac":"e0:xxxxxx:8c","sw_depth":-1,"sw_port":1}
<<< removed some lines >>

2021-03-24 11:57:01.697 Status: dzVents: Debug: CheckiPhoneAtHome: Processing device-adapter for iPhoneIsisAtHome: Switch device adapter
2021-03-24 11:57:01.697 Status: dzVents: Debug: CheckiPhoneAtHome: Constructed timed-command: Off
Any suggestion why this is not working?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Presence detection using UniFi Controller and DzVents

Post by waaren »

rgroothuis wrote: Wednesday 24 March 2021 12:06 Any suggestion why this is not working?
Please share the complete script and log (and only obscure sensitive data). That will make it much easier to help.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
rgroothuis
Posts: 347
Joined: Friday 03 April 2015 17:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Presence detection using UniFi Controller and DzVents

Post by rgroothuis »

This is the full script:

Code: Select all

return {
 	logging = {
 		level = domoticz.LOG_ERROR, --DEBUG, --ERROR, 		-- Adjust to your needs
 		marker = 'CheckiPhoneAtHome'
 	},
    on = {
        timer = { 
            'every 4 minutes' 
        },
        httpResponses = { 
            'unifi_loggedin',
            'unifi_data' 
        }
    },
    data = {
        presenceHistory = { 
            history = true, 
            maxMinutes = 6
        } 		-- Change maxMinutes value to appropriate for your devices
    },
    execute = function(domoticz, item)
        domoticz.log('============================================================================================', domoticz.LOG_DEBUG)
        domoticz.log('CheckiPhoneAtHome script.', domoticz.LOG_DEBUG)

        local controllerUrl = 'https://192.168.0.25:8443/' 	-- Change IP and Port to your Unifi Controller settings
        local controllerLogin = 'xxxxxxx'					-- Your username for Unifi Controller
        local controllerPassword = 'xxxxxx' 				-- Your password for Unifi Controller

        local devices = { -- all lower case!
            ['iphone-van-isis'] = 111,
            ['aa:aa:aa:aa:aa:aa'] = 108,
            ['bb:bb:bb:bb:bb:bb'] = 109
        }

        if (item.isTimer) then
            domoticz.openURL({
                url = controllerUrl .. 'api/login',
                method = 'POST',
                postData = { 
                    ['password'] = controllerPassword, 
                    ['username'] = controllerLogin 
                },
                callback = 'unifi_loggedin'
            })
        end
        
        if item.isHTTPResponse and not (item.ok) then
            domoticz.log("problem with HTTPResponse", domoticz.LOG_ERROR)
            domoticz.log(item, domoticz.LOG_ERROR)
        elseif (item.isHTTPResponse and item.ok) then
            
            -- HTTP response first
            if (item.trigger == 'unifi_loggedin') then
                domoticz.openURL({
                    url = controllerUrl .. 'api/s/default/stat/sta',
                    method = 'GET',
                    callback = 'unifi_data'
                })
            end
        
            -- HTTP response second
            if (item.trigger == 'unifi_data') then 
                local presenceHistory = domoticz.data.presenceHistory

                for mac, device in pairs(devices) do
                    domoticz.log('** Mac: ' .. mac .. ' - Item data:' .. item.data .. '.', domoticz.LOG_DEBUG)
                    -- item.data contains the feebdback from Unifi with all the wifi clients, mac addresses and more data.
                    -- mac contains the string to search for in the response data. 
                    local isPresent = string.find(string.lower(item.data), mac)

                    presenceHistory.add({
                        ['mac'] = mac,
                        ['isPresent'] = not (isPresent == nil)
                    })
                
                    local wasPresent = presenceHistory.reduce(function(acc, item)
                        if (item.data.mac == mac and item.data.isPresent) then
                            acc = acc + 1
                        end
                        
                        return acc
                    end, 0)
                                       
                    if (wasPresent == 0) then
                        domoticz.devices(device).switchOff().checkFirst()
                    else
                        domoticz.devices(device).switchOn().checkFirst()
                    end
                end
            end
        end

        domoticz.log('============================================================================================', domoticz.LOG_DEBUG)
    end
}
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Presence detection using UniFi Controller and DzVents

Post by waaren »

rgroothuis wrote: Wednesday 24 March 2021 14:46 This is the full script:
OK.
can you execute this one (after entering your details and share the log that it produce? (and obscure any sensitive data)
That should give enough information to help understanding what does not work when using names iso mac addresses.

Code: Select all

return {
    on = {
        timer = { 
            'every 4 minutes' 
        },
        httpResponses = { 
            'unifi_loggedin',
            'unifi_data' 
        }
    },

     logging = {
         level = domoticz.LOG_DEBUG, --DEBUG, --ERROR,         -- Adjust to your needs
         marker = 'CheckiPhoneAtHome'
     },

    data = {
        presenceHistory = { 
            history = true, 
            maxMinutes = 6
        }         -- Change maxMinutes value to appropriate for your devices
    },

    execute = function(domoticz, item)
        domoticz.log('============================================================================================', domoticz.LOG_DEBUG)
        domoticz.log('CheckiPhoneAtHome script.', domoticz.LOG_DEBUG)

        local controllerUrl = 'https://192.168.0.25:8443/'     -- Change IP and Port to your Unifi Controller settings
        local controllerLogin = 'xxxxxxx'                    -- Your username for Unifi Controller
        local controllerPassword = 'xxxxxx'                 -- Your password for Unifi Controller

        local devices = { -- all lower case!
            ['iphone-van-isis'] = 111,
            ['aa:aa:aa:aa:aa:aa'] = 108,
            ['bb:bb:bb:bb:bb:bb'] = 109
        }

        if (item.isTimer) then
            domoticz.openURL({
                url = controllerUrl .. 'api/login',
                method = 'POST',
                postData = { 
                    ['password'] = controllerPassword, 
                    ['username'] = controllerLogin 
                },
                callback = 'unifi_loggedin'
            })
        end
        
        if item.isHTTPResponse and not (item.ok) then
            domoticz.log("problem with HTTPResponse", domoticz.LOG_ERROR)
            domoticz.log(item, domoticz.LOG_ERROR)
        elseif (item.isHTTPResponse and item.ok) then
            
            -- HTTP response first
            if (item.trigger == 'unifi_loggedin') then
                domoticz.openURL({
                    url = controllerUrl .. 'api/s/default/stat/sta',
                    method = 'GET',
                    callback = 'unifi_data'
                })
            end
        
            -- HTTP response second
            if (item.trigger == 'unifi_data') then 

                domoticz.utils.dumpTable(item)
                domoticz.utils.dumpTable(globalvariables)
                do return end

                local presenceHistory = domoticz.data.presenceHistory

                for mac, device in pairs(devices) do
                    domoticz.log('** Mac: ' .. mac .. ' - Item data:' .. item.data .. '.', domoticz.LOG_DEBUG)
                    -- item.data contains the feebdback from Unifi with all the wifi clients, mac addresses and more data.
                    -- mac contains the string to search for in the response data. 
                    local isPresent = string.find(string.lower(item.data), mac)

                    presenceHistory.add({
                        ['mac'] = mac,
                        ['isPresent'] = not (isPresent == nil)
                    })
                
                    local wasPresent = presenceHistory.reduce(function(acc, item)
                        if (item.data.mac == mac and item.data.isPresent) then
                            acc = acc + 1
                        end
                        
                        return acc
                    end, 0)
                                       
                    if (wasPresent == 0) then
                        domoticz.devices(device).switchOff().checkFirst()
                    else
                        domoticz.devices(device).switchOn().checkFirst()
                    end
                end
            end
        end

        domoticz.log('============================================================================================', domoticz.LOG_DEBUG)
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
rgroothuis
Posts: 347
Joined: Friday 03 April 2015 17:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Presence detection using UniFi Controller and DzVents

Post by rgroothuis »

Thanks, will give this a try and get back to you with the debug info.
rgroothuis
Posts: 347
Joined: Friday 03 April 2015 17:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Presence detection using UniFi Controller and DzVents

Post by rgroothuis »

This is the log created:

Code: Select all

2021-03-25 08:54:01.523 Status: dzVents: > tx_bytes: 52557040
2021-03-25 08:54:01.523 Status: dzVents: > tx_packets: 434295
2021-03-25 08:54:01.523 Status: dzVents: > sw_depth: 1
2021-03-25 08:54:01.523 Status: dzVents: > _last_seen_by_ugw: 1616658801
2021-03-25 08:54:01.523 Status: dzVents: > dev_id_override: 2014
2021-03-25 08:54:01.523 Status: dzVents: > satisfaction: 100
2021-03-25 08:54:01.523 Status: dzVents: > tx_retries: 0
2021-03-25 08:54:01.523 Status: dzVents: > ip: 192.168.0.99
2021-03-25 08:54:01.523 Status: dzVents: > wired-tx_bytes-r: 959
2021-03-25 08:54:01.523 Status: dzVents: > wired-rx_bytes-r: 2807
2021-03-25 08:54:01.523 Status: dzVents: > mac: xxxxx
2021-03-25 08:54:01.523 Status: dzVents: > site_id: 5ebbc931903a37906ea3c3e4
2021-03-25 08:54:01.523 Status: dzVents: > latest_assoc_time: 1616658773
2021-03-25 08:54:01.523 Status: dzVents: > wifi_tx_attempts: 0
2021-03-25 08:54:01.523 Status: dzVents: > rx_bytes: 67779101
2021-03-25 08:54:01.523 Status: dzVents: > sw_port: 22
2021-03-25 08:54:01.523 Status: dzVents: > _is_guest_by_usw: false
2021-03-25 08:54:01.523 Status: dzVents: > is_guest: false
2021-03-25 08:54:01.523 Status: dzVents: > oui: PhilipsL
2021-03-25 08:54:01.523 Status: dzVents: > 21:
2021-03-25 08:54:01.523 Status: dzVents: > _last_seen_by_usw: 1616658806
2021-03-25 08:54:01.523 Status: dzVents: > _last_seen_by_ugw: 1616658801
2021-03-25 08:54:01.523 Status: dzVents: > network: LAN
2021-03-25 08:54:01.523 Status: dzVents: > oui: Sonos
2021-03-25 08:54:01.523 Status: dzVents: > sw_mac: xxxxxx
2021-03-25 08:54:01.523 Status: dzVents: > first_seen: 1613738789
2021-03-25 08:54:01.523 Status: dzVents: > gw_mac: xxxxxx
2021-03-25 08:54:01.524 Status: dzVents: > network_id: 5ebbc933903a37906ea3c3f3
2021-03-25 08:54:01.524 Status: dzVents: > _uptime_by_ugw: 507
2021-03-25 08:54:01.524 Status: dzVents: > authorized: true
2021-03-25 08:54:01.524 Status: dzVents: > user_id: 602fb3251185010015780920
2021-03-25 08:54:01.524 Status: dzVents: > tx_bytes-r: 7
2021-03-25 08:54:01.524 Status: dzVents: > anomalies: 0
2021-03-25 08:54:01.524 Status: dzVents: > rx_bytes-r: 40
2021-03-25 08:54:01.524 Status: dzVents: > uptime: 2920027
2021-03-25 08:54:01.524 Status: dzVents: > assoc_time: 1613738779
2021-03-25 08:54:01.524 Status: dzVents: > bytes-r: 47
2021-03-25 08:54:01.524 Status: dzVents: > qos_policy_applied: true
2021-03-25 08:54:01.524 Status: dzVents: > tx_bytes: 7185171090
2021-03-25 08:54:01.524 Status: dzVents: > rx_packets: 5692970
2021-03-25 08:54:01.524 Status: dzVents: > _id: 602fb3251185010015780920
2021-03-25 08:54:01.524 Status: dzVents: > hostname: SonosZP
2021-03-25 08:54:01.524 Status: dzVents: > tx_packets: 6026603
2021-03-25 08:54:01.524 Status: dzVents: > sw_depth: 2
2021-03-25 08:54:01.524 Status: dzVents: > _uptime_by_usw: 37397
2021-03-25 08:54:01.524 Status: dzVents: > satisfaction: 100
2021-03-25 08:54:01.524 Status: dzVents: > tx_retries: 0
2021-03-25 08:54:01.524 Status: dzVents: > ip: 192.168.0.240
2021-03-25 08:54:01.524 Status: dzVents: > sw_port: 3
2021-03-25 08:54:01.524 Status: dzVents: > last_seen: 1616658806
2021-03-25 08:54:01.524 Status: dzVents: > mac: xxxxx
2021-03-25 08:54:01.524 Status: dzVents: > site_id: 5ebbc931903a37906ea3c3e4
2021-03-25 08:54:01.524 Status: dzVents: > latest_assoc_time: 1616658294
2021-03-25 08:54:01.524 Status: dzVents: > wifi_tx_attempts: 0
2021-03-25 08:54:01.524 Status: dzVents: > rx_bytes: 410561438
2021-03-25 08:54:01.524 Status: dzVents: > _is_guest_by_usw: false
2021-03-25 08:54:01.524 Status: dzVents: > is_guest: false
2021-03-25 08:54:01.524 Status: dzVents: > is_wired: true
2021-03-25 08:54:01.524 Status: dzVents: > _is_guest_by_ugw: false
2021-03-25 08:54:01.524 Status: dzVents: > meta:
2021-03-25 08:54:01.524 Status: dzVents: > rc: ok
2021-03-25 08:54:01.524 Status: dzVents: > isJSON: true
2021-03-25 08:54:01.524 Status: dzVents: > baseType: httpResponse
2021-03-25 08:54:01.524 Status: dzVents: > callback: unifi_data
2021-03-25 08:54:01.524 Status: dzVents: > data: {"meta":{"rc":"ok"},"data":[{"site_id":"5ebbc931903a37906ea3c3e4","assoc_time":1610043705,"latest_assoc_time":1616658805,"oui":"Sonos","user_id":"5efe3c9f401fee0015a90ca7","_id":"5efe3c9f401fee0015a90ca7","mac":"xxxxx","is_guest":false,"first_seen":1593719967,"last_seen":1616658806,"is_wired":true,"hostname":"SonosZB","usergroup_id":"","name":"SonosBase","noted":true,"use_fixedip":true,"network_id":"5ebbc933903a37906ea3c3f3","fixed_ip":"192.168.0.239","_uptime_by_usw":1,"_last_seen_by_usw":1616658806,"_is_guest_by_usw":false,"sw_mac":"xxxxx","sw_depth":2,"sw_port":3,"network":"LAN","satisfaction":100,"anomalies":0,"uptime":6615101,"ip":"192.168.0.239","_uptime_by_ugw":2845,"_last_seen_by_ugw":1616658719,"_is_guest_by_ugw":false,"gw_mac":"xxxx","tx_bytes":2803766,"rx_bytes":52775527,"tx_packets":3196,"tx_retries":0,"wifi_tx_attempts":0,"rx_packets":145020,"bytes-r":11,"tx_bytes-r":0,"rx_bytes-r":11,"authorized":true,"qos_policy_applied":true,"wired-tx_bytes":1112019,"wired-rx_bytes":54322,"wired-tx_packets":11356,"wired-rx_packets":799,"wired-tx_bytes-r":80,"wired-rx_bytes-r":64},{"site_id":"5ebbc931903a37906ea3c3e4","assoc_time":1615827362,"latest_assoc_time":1616658671,"oui":"Espressi","user_id":"5f68814b25f690001531bf17","_id":"5f68814b25f690001531bf17","mac":"xxxxx","is_guest":false,"first_seen":1600684363,"last_seen":1616658840,"is_wired":false,"hostname":"Nuki_Bridge_1D04C002","use_fixedip":true,"network_id":"5ebbc933903a37906ea3c3f3","fixed_ip":"192.168.0.98","noted":true,"usergroup_id":"","name":"Nuki Bridge","fingerprint_override":true,"dev_id_override":3593,"_uptime_by_ugw":540291,"_last_seen_by_ugw":1616658801,"_is_guest_by_ugw":false,"gw_mac":"xxxx","network":"LAN","ip":"192.168.0.98","uptime":831478,"tx_bytes":4828840,"rx_bytes":9810041,"tx_packets":69044,"tx_retries":0,"wifi_tx_attempts":69044,"rx_packets":91493,"bytes-r":0,"tx_bytes-r":0,"rx_bytes-r":0,"authorized":true,"qos_policy_applied":true,"_uptime_by_uap":831480,"_last_seen_by_uap":1616658840,"_is_guest_by_uap":false,"ap_mac":"xxxx","channel":1,"radio":"ng","radio_name":"ra0","essid":"HoekHuis","bssid":"74:83:c2:da:24:3e","powersave_enabled":false,"is_11r":false,"ccq":0,"rssi":56,"noise":-96,"signal":-40,"tx_rate":65000,"rx_rate":72000,"tx_power":0,"idletime":5,"dhcpend_time":400,"satisfaction":99,"anomalies":0,"vlan":0,"radio_proto":"ng","_uptime_by_usw":135,"_last_seen_by_usw":1616658806,"_is_guest_by_usw":false,"sw_mac":"xxxxx","sw_depth":-1,"sw_port":1},{"site_id":"5ebbc931903a37906ea3c3e4","assoc_time":1616639082,"latest_assoc_time":1616658794,"oui":"Google","user_id":"5ec54987b1487100163e01a4","_id":"5ec54987b1487100163e01a4","mac":"xxxx","is_guest":false,"first_seen":1589987719,"last_seen":1616658840,"is_wired":false,"hostname":"Google-Nest-Mini","name":"Google-Home-Mini-Noor","usergroup_id":"","use_fixedip":true,"noted":true,"fingerprint_override":true,"dev_id_override":3419,"network_id":"5ebbc933903a37906ea3c3f3","fixed_ip":"192.168.0.19","_uptime_by_ugw":7,"_last_seen_by_ugw":1616658801,"_is_guest_by_ugw":false,"gw_mac":"xxxx","network":"LAN","ip":"192.168.0.19","uptime":19758,"tx_bytes":6177916,"rx_bytes":7245064,"tx_packets":57641,"tx_retries":0,"wifi_tx_attempts":57641,"rx_packets":59938,"bytes-r":409,"tx_bytes-r":161,"rx_bytes-r":248,"authorized":true,"qos_policy_applied":true,"_uptime_by_uap":19759,"_last_seen_by_uap":1616658840,"_is_guest_by_uap":false,"ap_mac":"xxxx","channel":6,"radio":"ng","radio_name":"ra0","essid":"HoekHuis","bssid":"74:83:c2:da:2b:b8","powersave_enabled":true,"is_11r":false,"ccq":0,"rssi":32,"noise":-96,"signal":-64,"tx_rate":72000,"rx_rate":65000,"tx_power":0,"idletime":0,"dhcpend_time":750,"satisfaction":89,"anomalies":0,"vlan":0,"radio_proto":"ng","_uptime_by_usw":148,"_last_seen_by_usw":1616658806,"_is_guest_by_usw":false,"sw_mac":"xxxx","sw_depth":-1,"sw_port":4},{"site_id":"5ebbc931903a37906ea3c3e4","assoc_time":1616636818,"latest_assoc_time":1616658756,"oui":"Google","user_id":"5ebd2ec2b1487100163d66b6","_id":"5ebd2ec2b1487100163d66b6","mac":"xxxx","is_guest":false,"first_seen":1589456577,"last_seen":1616658788,"is_wired":false,"hostname":"Chromecast","fingerprint_override":true,"dev_id_override":39,"note":"Samsung TV","usergroup_id":"","name":"Chromecast-Video-Huiskamer","noted":true,"use_fixedip":true,"network_id":"5ebbc933903a37906ea3c3f3","fixed_ip":"192.168.0.18","_uptime_by_uap":21973,"_last_seen_by_uap":1616658788,"_is_guest_by_uap":false,"ap_mac":"xxxx","channel":48,"radio":"na","radio_name":"wifi0","essid":"HoekHuis","bssid":"74:83:c2:77:48:9b","powersave_enabled":false,"is_11r":false,"ccq":333,"rssi":39,"noise":-105,"signal":-57,"tx_rate":200000,"rx_rate":200000,"tx_power":38,"idletime":0,"ip":"192.168.0.18","dhcpend_time":1660,"satisfaction":99,"anomalies":0,"vlan":0,"radio_proto":"ac","uptime":21970,"tx_bytes":114132677,"rx_bytes":8899627,"tx_packets":112474,"tx_retries":42190,"wifi_tx_attempts":154698,"rx_packets":100378,"bytes-r":307,"tx_bytes-r":162,"rx_bytes-r":145,"authorized":true,"qos_policy_applied":true,"_uptime_by_ugw":45,"_last_seen_by_ugw":1616658801,"_is_guest_by_ugw":false,"gw_mac":"xxxx","network":"LAN"},{"site_id":"5ebbc931903a37906ea3c3e4","assoc_time":1616101340,"latest_assoc_time":1616658716,"oui":"","user_id":"6011e63a118501001573b24c","_id":"6011e63a118501001573b24c","mac":"xxxx","is_guest":false,"first_seen":1611785786,"last_seen":1616658840,"is_wired":false,"hostname":"iPad-van-Dorien","_uptime_by_uap":557506,"_last_seen_by_uap":1616658840,"_is_guest_by_uap":false,"ap_mac":"xxxx","channel":40,"radio":"na","radio_name":"rai0","essid":"HoekHuis","bssid":"74:83:c2:da:2b:b9","powersave_enabled":true,"is_11r":true,"ccq":0,"rssi":36,"noise":-96,"signal":-60,"tx_rate":360000,"rx_rate":400000,"tx_power":0,"idletime":6,"ip":"192.168.0.211","dhcpend_time":2490,"satisfaction":96,"anomalies":0,"vlan":0,"radio_proto":"ac","uptime":557500,"tx_bytes":13719460319,"rx_bytes":18
2021-03-25 08:54:01.524 Status: dzVents: > isSystem: false
2021-03-25 08:54:01.524 Status: dzVents: > headers:
2021-03-25 08:54:01.524 Status: dzVents: > Date: Thu, 25 Mar 2021 07:54:01 GMT
2021-03-25 08:54:01.524 Status: dzVents: > X-Frame-Options: DENY
2021-03-25 08:54:01.524 Status: dzVents: > Content-Encoding: gzip
2021-03-25 08:54:01.524 Status: dzVents: > Content-Type: application/json;charset=UTF-8
2021-03-25 08:54:01.524 Status: dzVents: > Access-Control-Allow-Credentials: true
2021-03-25 08:54:01.524 Status: dzVents: > Transfer-Encoding: chunked
2021-03-25 08:54:01.524 Status: dzVents: > Access-Control-Expose-Headers: Access-Control-Allow-Origin,Access-Control-Allow-Credentials
2021-03-25 08:54:01.524 Status: dzVents: > vary: accept-encoding,origin,accept-encoding
2021-03-25 08:54:01.524 Status: dzVents: > protocol: HTTP/1.1
2021-03-25 08:54:01.524 Status: dzVents: > isVariable: false
2021-03-25 08:54:01.525 Status: dzVents: > isSecurity: false
2021-03-25 08:54:01.525 Status: dzVents: > isGroup: false
2021-03-25 08:54:01.525 Status: dzVents: > isXML: false
2021-03-25 08:54:01.525 Status: dzVents: > isScene: false
2021-03-25 08:54:01.525 Status: dzVents: > radix_separator: .
2021-03-25 08:54:01.525 Status: dzVents: > longitude: 4.288035
2021-03-25 08:54:01.525 Status: dzVents: > testmode: false
2021-03-25 08:54:01.525 Status: dzVents: > dzVents_log_level: 1
2021-03-25 08:54:01.525 Status: dzVents: > isTimeEvent: false
2021-03-25 08:54:01.525 Status: dzVents: > latitude: 52.115007
2021-03-25 08:54:01.525 Status: dzVents: > group_separator:
2021-03-25 08:54:01.525 Status: dzVents: > runtime_path: /home/pi/domoticz/dzVents/runtime/
2021-03-25 08:54:01.525 Status: dzVents: > domoticz_title: HoekHuisHome
2021-03-25 08:54:01.525 Status: dzVents: > script_path: /home/pi/domoticz/scripts/dzVents/
2021-03-25 08:54:01.525 Status: dzVents: > Security: Disarmed
2021-03-25 08:54:01.525 Status: dzVents: > domoticz_listening_port: 80
2021-03-25 08:54:01.525 Status: dzVents: > currentTime: 2021-03-25 08:54:01.372
2021-03-25 08:54:01.525 Status: dzVents: > dzVents_version: 3.0.2
2021-03-25 08:54:01.525 Status: dzVents: > domoticz_version: 2020.2
2021-03-25 08:54:01.525 Status: dzVents: > systemUptime: 766075
2021-03-25 08:54:01.525 Status: dzVents: > domoticz_start_time: 2021-03-16 14:57:13
2021-03-25 08:54:01.525 Status: dzVents: > domoticz_webroot:
2021-03-25 08:54:01.526 Status: dzVents: Info: CheckiPhoneAtHome: ------ Finished CheckiPhoneAtHome
Problem that I see is that the data is truncated. Seems that not all data is available.

My iPhone has the name Rene in it and I cannot find it in the log.
I had to test with a different iPhone name as the other iPhone is not at home at the moment.

When I run the api/s/default/stat/sta URL I get the response data and in that data I can find the "Rene" text.
Screenshot 2021-03-25 at 09.05.07.png
Screenshot 2021-03-25 at 09.05.07.png (161 KiB) Viewed 1546 times
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Presence detection using UniFi Controller and DzVents

Post by waaren »

rgroothuis wrote: Thursday 25 March 2021 9:06 This is the log created:
Problem that I see is that the data is truncated. Seems that not all data is available.
Yes, some important part seems missing. Can you try to log to an OS file?



The domoticz logfile location and other settings are defined in /etc/init.d/domoticz.sh
the relevant settings are in set to the DAEMON_ARGS var.

with an editor of choice

Code: Select all

DAEMON_ARGS="$DAEMON_ARGS -log /var/log/domoticz.log" # or any other OS file
#DAEMON_ARGS="$DAEMON_ARGS -loglevel  normal,status,error, debug" # debug disabled for now
DAEMON_ARGS="$DAEMON_ARGS -loglevel  normal,status,error" # these loglevels will make it to the logfile
#DAEMON_ARGS="$DAEMON_ARGS -debuglevel normal,hardware,received,webserver,eventsystem,python,thread_id"

Code: Select all

sudo systemctl daemon-reload
sudo service domoticz stop
sudo service domoticz start
sudo tail -f  /var/log/domoticz.log
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
rgroothuis
Posts: 347
Joined: Friday 03 April 2015 17:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Presence detection using UniFi Controller and DzVents

Post by rgroothuis »

Now the correct Isis iphone was at home, another piece of the log:

Code: Select all

2021-03-25 09:43:01.565 Status: dzVents: > rx_bytes: 67801732
2021-03-25 09:43:01.565 Status: dzVents: > tx_bytes: 52573370
2021-03-25 09:43:01.565 Status: dzVents: > name: Philips-Hue
2021-03-25 09:43:01.565 Status: dzVents: > dev_id_override: 2014
2021-03-25 09:43:01.565 Status: dzVents: > _last_seen_by_usw: 1616661771
2021-03-25 09:43:01.565 Status: dzVents: > authorized: true
2021-03-25 09:43:01.565 Status: dzVents: > is_guest: false
2021-03-25 09:43:01.565 Status: dzVents: > _uptime_by_ugw: 1
2021-03-25 09:43:01.565 Status: dzVents: > rx_bytes-r: 0
2021-03-25 09:43:01.565 Status: dzVents: > noted: true
2021-03-25 09:43:01.565 Status: dzVents: > wired-rx_packets: 19603102
2021-03-25 09:43:01.565 Status: dzVents: > wired-tx_packets: 45222779
2021-03-25 09:43:01.565 Status: dzVents: > wired-rx_bytes: 14284698996
2021-03-25 09:43:01.565 Status: dzVents: > use_fixedip: true
2021-03-25 09:43:01.565 Status: dzVents: > wired-tx_bytes: 6411714013
2021-03-25 09:43:01.565 Status: dzVents: > uptime: 6618500
2021-03-25 09:43:01.565 Status: dzVents: > latest_assoc_time: 1616661757
2021-03-25 09:43:01.565 Status: dzVents: > assoc_time: 1610043271
2021-03-25 09:43:01.565 Status: dzVents: > anomalies: 0
2021-03-25 09:43:01.565 Status: dzVents: > usergroup_id:
2021-03-25 09:43:01.565 Status: dzVents: > network: LAN
2021-03-25 09:43:01.565 Status: dzVents: > fixed_ip: 192.168.0.99
2021-03-25 09:43:01.565 Status: dzVents: > _id: 5f00dc3be9c15b00151d3c55
2021-03-25 09:43:01.565 Status: dzVents: > hostname: Philips-hue
2021-03-25 09:43:01.565 Status: dzVents: > sw_mac: xxxx
2021-03-25 09:43:01.565 Status: dzVents: > 23:
2021-03-25 09:43:01.565 Status: dzVents: > _is_guest_by_ugw: false
2021-03-25 09:43:01.565 Status: dzVents: > qos_policy_applied: true
2021-03-25 09:43:01.565 Status: dzVents: > last_seen: 1616661771
2021-03-25 09:43:01.565 Status: dzVents: > assoc_time: 1613738779
2021-03-25 09:43:01.565 Status: dzVents: > user_id: 602fb3251185010015780920
2021-03-25 09:43:01.565 Status: dzVents: > sw_port: 3
2021-03-25 09:43:01.565 Status: dzVents: > bytes-r: 15
2021-03-25 09:43:01.565 Status: dzVents: > is_wired: true
2021-03-25 09:43:01.565 Status: dzVents: > tx_retries: 0
2021-03-25 09:43:01.565 Status: dzVents: > sw_depth: 2
2021-03-25 09:43:01.565 Status: dzVents: > oui: Sonos
2021-03-25 09:43:01.565 Status: dzVents: > first_seen: 1613738789
2021-03-25 09:43:01.565 Status: dzVents: > tx_bytes: 7185201359
2021-03-25 09:43:01.565 Status: dzVents: > _last_seen_by_ugw: 1616661758
2021-03-25 09:43:01.565 Status: dzVents: > site_id: 5ebbc931903a37906ea3c3e4
2021-03-25 09:43:01.565 Status: dzVents: > ip: 192.168.0.240
2021-03-25 09:43:01.565 Status: dzVents: > _uptime_by_ugw: 3246
2021-03-25 09:43:01.565 Status: dzVents: > tx_packets: 6027024
2021-03-25 09:43:01.565 Status: dzVents: > gw_mac: xxxx
2021-03-25 09:43:01.565 Status: dzVents: > network_id: 5ebbc933903a37906ea3c3f3
2021-03-25 09:43:01.565 Status: dzVents: > tx_bytes-r: 1
2021-03-25 09:43:01.565 Status: dzVents: > _last_seen_by_usw: 1616661771
2021-03-25 09:43:01.565 Status: dzVents: > authorized: true
2021-03-25 09:43:01.565 Status: dzVents: > is_guest: false
2021-03-25 09:43:01.565 Status: dzVents: > rx_bytes-r: 14
2021-03-25 09:43:01.565 Status: dzVents: > hostname: SonosZP
2021-03-25 09:43:01.565 Status: dzVents: > rx_packets: 5694466
2021-03-25 09:43:01.565 Status: dzVents: > _uptime_by_usw: 44286
2021-03-25 09:43:01.565 Status: dzVents: > mac: xxxx
2021-03-25 09:43:01.565 Status: dzVents: > _is_guest_by_usw: false
2021-03-25 09:43:01.565 Status: dzVents: > latest_assoc_time: 1616658512
2021-03-25 09:43:01.565 Status: dzVents: > wifi_tx_attempts: 0
2021-03-25 09:43:01.565 Status: dzVents: > anomalies: 0
2021-03-25 09:43:01.565 Status: dzVents: > satisfaction: 100
2021-03-25 09:43:01.565 Status: dzVents: > network: LAN
2021-03-25 09:43:01.566 Status: dzVents: > rx_bytes: 410681559
2021-03-25 09:43:01.566 Status: dzVents: > _id: 602fb3251185010015780920
2021-03-25 09:43:01.566 Status: dzVents: > uptime: 2922992
2021-03-25 09:43:01.566 Status: dzVents: > sw_mac: xxxx
2021-03-25 09:43:01.566 Status: dzVents: > meta:
2021-03-25 09:43:01.566 Status: dzVents: > rc: ok
2021-03-25 09:43:01.566 Status: dzVents: > isVariable: false
2021-03-25 09:43:01.566 Status: dzVents: > protocol: HTTP/1.1
2021-03-25 09:43:01.566 Status: dzVents: > statusCode: 200
2021-03-25 09:43:01.566 Status: dzVents: > data: {"meta":{"rc":"ok"},"data":[{"site_id":"5ebbc931903a37906ea3c3e4","assoc_time":1616661687,"latest_assoc_time":1616661768,"oui":"","user_id":"6048cea011850100157b58c3","_id":"6048cea011850100157b58c3","mac":"xxxx:1f:1b:ae","is_guest":false,"first_seen":1615384224,"last_seen":1616661779,"is_wired":false,"hostname":"iPhone-van-Isis","_uptime_by_uap":11,"_last_seen_by_uap":1616661779,"_is_guest_by_uap":false,"ap_mac":"xxxx:77:48:99","channel":48,"radio":"na","radio_name":"wifi0","essid":"HoekHuis","bssid":"74:83:c2:77:48:9b","powersave_enabled":false,"is_11r":true,"ccq":411,"rssi":36,"noise":-105,"signal":-60,"tx_rate":180000,"rx_rate":300000,"tx_power":38,"idletime":0,"ip":"192.168.0.232","dhcpend_time":0,"satisfaction":100,"anomalies":0,"vlan":0,"radio_proto":"ac","uptime":92,"tx_bytes":999131,"rx_bytes":313215,"tx_packets":1597,"tx_retries":430,"wifi_tx_attempts":2056,"rx_packets":1460,"bytes-r":29777,"tx_bytes-r":22648,"rx_bytes-r":7129,"authorized":true,"qos_policy_applied":true,"_uptime_by_ugw":652,"_last_seen_by_ugw":1616661758,"_is_guest_by_ugw":false,"gw_mac":"xxxx:85:0f:55","network":"LAN","network_id":"5ebbc933903a37906ea3c3f3","roam_count":1},{"site_id":"5ebbc931903a37906ea3c3e4","assoc_time":1610043705,"latest_assoc_time":1616661699,"oui":"Sonos","user_id":"5efe3c9f401fee0015a90ca7","_id":"5efe3c9f401fee0015a90ca7","mac":"xxxx:1d:d4:bc","is_guest":false,"first_seen":1593719967,"last_seen":1616661771,"is_wired":true,"hostname":"SonosZB","usergroup_id":"","name":"SonosBase","noted":true,"use_fixedip":true,"network_id":"5ebbc933903a37906ea3c3f3","fixed_ip":"192.168.0.239","_uptime_by_usw":758,"_last_seen_by_usw":1616661771,"_is_guest_by_usw":false,"sw_mac":"xxxx:ce:af:8c","sw_depth":2,"sw_port":3,"network":"LAN","satisfaction":100,"anomalies":0,"uptime":6618066,"ip":"192.168.0.239","_uptime_by_ugw":1191,"_last_seen_by_ugw":1616661460,"_is_guest_by_ugw":false,"gw_mac":"xxxx:85:0f:55","tx_bytes":2803766,"rx_bytes":52794499,"tx_packets":3196,"tx_retries":0,"wifi_tx_attempts":0,"rx_packets":145068,"bytes-r":0,"tx_bytes-r":0,"rx_bytes-r":0,"authorized":true,"qos_policy_applied":true,"wired-tx_bytes":1112019,"wired-rx_bytes":54322,"wired-tx_packets":11356,"wired-rx_packets":799,"wired-tx_bytes-r":80,"wired-rx_bytes-r":64},{"site_id":"5ebbc931903a37906ea3c3e4","assoc_time":1615827362,"latest_assoc_time":1616658671,"oui":"Espressi","user_id":"5f68814b25f690001531bf17","_id":"5f68814b25f690001531bf17","mac":"xxxx:d3:89:c8","is_guest":false,"first_seen":1600684363,"last_seen":1616661781,"is_wired":false,"hostname":"Nuki_Bridge_1D04C002","use_fixedip":true,"network_id":"5ebbc933903a37906ea3c3f3","fixed_ip":"192.168.0.98","noted":true,"usergroup_id":"","name":"Nuki Bridge","fingerprint_override":true,"dev_id_override":3593,"_uptime_by_ugw":543030,"_last_seen_by_ugw":1616661758,"_is_guest_by_ugw":false,"gw_mac":"xxxx:85:0f:55","network":"LAN","ip":"192.168.0.98","uptime":834419,"tx_bytes":4845230,"rx_bytes":9844251,"tx_packets":69278,"tx_retries":0,"wifi_tx_attempts":69278,"rx_packets":91811,"bytes-r":0,"tx_bytes-r":0,"rx_bytes-r":0,"authorized":true,"qos_policy_applied":true,"_uptime_by_uap":834421,"_last_seen_by_uap":1616661781,"_is_guest_by_uap":false,"ap_mac":"xxxxx:da:24:3d","channel":1,"radio":"ng","radio_name":"ra0","essid":"HoekHuis","bssid":"74:83:c2:da:24:3e","powersave_enabled":false,"is_11r":false,"ccq":0,"rssi":57,"noise":-96,"signal":-39,"tx_rate":65000,"rx_rate":72000,"tx_power":0,"idletime":10,"dhcpend_time":400,"satisfaction":100,"anomalies":0,"vlan":0,"radio_proto":"ng","_uptime_by_usw":3030,"_last_seen_by_usw":1616661701,"_is_guest_by_usw":false,"sw_mac":"xxxx:ce:af:8c","sw_depth":-1,"sw_port":1},{"site_id":"5ebbc931903a37906ea3c3e4","assoc_time":1616639082,"latest_assoc_time":1616661758,"oui":"Google","user_id":"5ec54987b1487100163e01a4","_id":"5ec54987b1487100163e01a4","mac":"xxxx:34:47:14","is_guest":false,"first_seen":1589987719,"last_seen":1616661774,"is_wired":false,"hostname":"Google-Nest-Mini","name":"Google-Home-Mini-Noor","usergroup_id":"","use_fixedip":true,"noted":true,"fingerprint_override":true,"dev_id_override":3419,"network_id":"5ebbc933903a37906ea3c3f3","fixed_ip":"192.168.0.19","_uptime_by_ugw":0,"_last_seen_by_ugw":1616661758,"_is_guest_by_ugw":false,"gw_mac":"xxxxx:85:0f:55","network":"LAN","ip":"192.168.0.19","uptime":22692,"tx_bytes":8396293,"rx_bytes":8448900,"tx_packets":68352,"tx_retries":0,"wifi_tx_attempts":68352,"rx_packets":70319,"bytes-r":390,"tx_bytes-r":144,"rx_bytes-r":246,"authorized":true,"qos_policy_applied":true,"_uptime_by_uap":22693,"_last_seen_by_uap":1616661774,"_is_guest_by_uap":false,"ap_mac":"xxxxx:da:2b:b7","channel":6,"radio":"ng","radio_name":"ra0","essid":"HoekHuis","bssid":"74:83:c2:da:2b:b8","powersave_enabled":true,"is_11r":false,"ccq":0,"rssi":30,"noise":-96,"signal":-66,"tx_rate":72000,"rx_rate":65000,"tx_power":0,"idletime":0,"dhcpend_time":750,"satisfaction":75,"anomalies":8,"vlan":0,"radio_proto":"ng","_uptime_by_usw":3043,"_last_seen_by_usw":1616661701,"_is_guest_by_usw":false,"sw_mac":"xxxxx:af:8c","sw_depth":-1,"sw_port":4},{"site_id":"5ebbc931903a37906ea3c3e4","assoc_time":1616661771,"latest_assoc_time":1616661772,"oui":"Apple","user_id":"5ef9bdf1a193850016bc6f16","_id":"5ef9bdf1a193850016bc6f16","mac":"xxxxx:88:91:57","is_guest":false,"first_seen":1593425393,"last_seen":1616661781,"is_wired":false,"hostname":"MBP-van-Isis-2","usergroup_id":"","name":"Apple MacBook Isis","noted":true,"fingerprint_override":true,"dev_id_override":2138,"_uptime_by_uap":9,"_last_seen_by_uap":1616661781,"_is_guest_by_uap":false,"ap_mac":"xxxxx:da:24:3d","channel":40,"radio":"na","radio_name":"rai0","essid":"HoekHuis","bssid":"74:83:c2:da:24:3f","powersave_enabled":true,"is_11r":false,"ccq":0,"rssi":36,"noise":-96,"signal":-60,"tx_rate":200000,"rx_rate":200000,"tx_power":0,"idletime":0,"ip":"192.168.0.245","dhcpend_time":2380,"satisfaction":98,"anomalies":0,"vlan":0,"radio_proto":"ac","uptime":10,"tx_bytes":882286,"rx_bytes":265149,"tx_packets":1239,"tx_retries":0,"wifi_tx_attempts":1269,"rx_packets":1
2021-03-25 09:43:01.566 Status: dzVents: > isCustomEvent: false
2021-03-25 09:43:01.566 Status: dzVents: > isDevice: false
2021-03-25 09:43:01.566 Status: dzVents: > isHardware: false
2021-03-25 09:43:01.566 Status: dzVents: > isSystem: false
2021-03-25 09:43:01.566 Status: dzVents: > isTimer: false
2021-03-25 09:43:01.566 Status: dzVents: > _contentType: application/json;charset=UTF-8
2021-03-25 09:43:01.566 Status: dzVents: > trigger: unifi_data
2021-03-25 09:43:01.566 Status: dzVents: > isScene: false
2021-03-25 09:43:01.566 Status: dzVents: > callback: unifi_data
2021-03-25 09:43:01.566 Status: dzVents: > isHTTPResponse: true
2021-03-25 09:43:01.566 Status: dzVents: > isTimeEvent: false
2021-03-25 09:43:01.566 Status: dzVents: > currentTime: 2021-03-25 09:43:01.458
2021-03-25 09:43:01.566 Status: dzVents: > domoticz_title: HoekHuisHome
2021-03-25 09:43:01.566 Status: dzVents: > longitude: 4.288035
2021-03-25 09:43:01.566 Status: dzVents: > domoticz_version: 2020.2
2021-03-25 09:43:01.566 Status: dzVents: > Security: Disarmed
2021-03-25 09:43:01.566 Status: dzVents: > testmode: false
2021-03-25 09:43:01.566 Status: dzVents: > domoticz_webroot:
2021-03-25 09:43:01.566 Status: dzVents: > dzVents_log_level: 1
2021-03-25 09:43:01.566 Status: dzVents: > domoticz_listening_port: 80
2021-03-25 09:43:01.566 Status: dzVents: > systemUptime: 769016
2021-03-25 09:43:01.566 Status: dzVents: > latitude: 52.115007
2021-03-25 09:43:01.566 Status: dzVents: > script_path: /home/pi/domoticz/scripts/dzVents/
2021-03-25 09:43:01.566 Status: dzVents: > radix_separator: .
2021-03-25 09:43:01.566 Status: dzVents: > dzVents_version: 3.0.2
2021-03-25 09:43:01.566 Status: dzVents: > group_separator:
2021-03-25 09:43:01.566 Status: dzVents: > runtime_path: /home/pi/domoticz/dzVents/runtime/
2021-03-25 09:43:01.566 Status: dzVents: > domoticz_start_time: 2021-03-16 14:57:13
2021-03-25 09:43:01.567 Status: dzVents: Info: CheckiPhoneAtHome: ------ Finished CheckiPhoneAtHome
Will look into the other log files later. Thanks for the support
rgroothuis
Posts: 347
Joined: Friday 03 April 2015 17:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Presence detection using UniFi Controller and DzVents

Post by rgroothuis »

In this last debug info/log I can find: ""hostname":"iPhone-van-Isis"" in the data field. So the iPhone name in the URL response is there, but it is not detected somehow. I guess the

Code: Select all

local isPresent = string.find(string.lower(item.data), mac)
is not working correctly.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Presence detection using UniFi Controller and DzVents

Post by waaren »

rgroothuis wrote: Thursday 25 March 2021 9:47 Now the correct Isis iphone was at home, another piece of the log:

Will look into the other log files later. Thanks for the support
What I try to find out with the log is the structure of the JSON. That will help me to check if the values you are looking for are in the return in a more structured way then using a string.find
For that I need the complete log.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
rgroothuis
Posts: 347
Joined: Friday 03 April 2015 17:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Presence detection using UniFi Controller and DzVents

Post by rgroothuis »

waaren wrote: Thursday 25 March 2021 10:35
rgroothuis wrote: Thursday 25 March 2021 9:47 Now the correct Isis iphone was at home, another piece of the log:

Will look into the other log files later. Thanks for the support
What I try to find out with the log is the structure of the JSON. That will help me to check if the values you are looking for are in the return in a more structured way then using a string.find
For that I need the complete log.
Ok, understood. I will try to generate that log file, will be done later today or tomorrow, I will get back to you.
rgroothuis
Posts: 347
Joined: Friday 03 April 2015 17:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Presence detection using UniFi Controller and DzVents

Post by rgroothuis »

@waaren: just sent you a PM with the log file info.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Presence detection using UniFi Controller and DzVents

Post by waaren »

rgroothuis wrote: Thursday 25 March 2021 11:18 @waaren: just sent you a PM with the log file info.
I have not received it.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest