DouweM / homebridge-unifi-occupancy

Homebridge plugin that adds HomeKit occupancy sensors for selected devices (and people) on your UniFi network to the iOS Home app: quickly see who's where and automate accordingly.
Apache License 2.0
41 stars 1 forks source link

Just want to see smartphones and smart watches and the room they are in ? #15

Closed nodecentral closed 1 year ago

nodecentral commented 1 year ago

Describe Your Problem:

Hi, I have just installed Homebridge and this Unifi plugin, and have just selected smartphones and smart watches - as they are all i want to be able to see, and the room they are in (based on the Access Point they are connect to)

I’ve tried to create rooms, on both my iPhone and via Homebridge, but they are not retained and just vanish.

My expectation is that my Unifi Accesspoint can be associated withe Room, and then when a smartphone or smart watch are seen on the network, they are associated with the room, the access point their using is in ?

Any help you can give me in achieving this would be amazing..

Logs:

[3/12/2023, 1:44:22 PM] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null
[3/12/2023, 1:44:27 PM] [HB Supervisor] Restarting Homebridge...
[3/12/2023, 1:44:27 PM] [HB Supervisor] Starting Homebridge with extra flags: -I -P /var/lib/homebridge/node_modules --strict-plugin-resolution
[3/12/2023, 1:44:27 PM] [HB Supervisor] Started Homebridge v1.6.0 with PID: 3114
[3/12/2023, 1:44:28 PM] Loaded config.json with 0 accessories and 2 platforms.
[3/12/2023, 1:44:28 PM] Loaded 0 cached accessories from cachedAccessories.
[3/12/2023, 1:44:28 PM] ---
[3/12/2023, 1:44:29 PM] Loaded plugin: homebridge-unifi-occupancy@1.2.4
[3/12/2023, 1:44:29 PM] Registering platform 'homebridge-unifi-occupancy.UnifiOccupancy'
[3/12/2023, 1:44:29 PM] ---
[3/12/2023, 1:44:29 PM] Loaded plugin: homebridge-vieramatic@4.0.50
[3/12/2023, 1:44:29 PM] Registering platform 'homebridge-vieramatic.PanasonicVieraTV'
[3/12/2023, 1:44:29 PM] ---
[3/12/2023, 1:44:29 PM] Loading 2 platforms...
[3/12/2023, 1:44:29 PM] [UnifiOccupancy] Initializing UnifiOccupancy platform...
[3/12/2023, 1:44:29 PM] [UnifiOccupancy] Initializing child bridge 0E:61:18:xx:xxx:x:36
Setup Payload:
X-HM://0023P1HxxxxBNP
Enter this code with your HomeKit app on your iOS device to pair with Homebridge:

    ┌────────────┐     
    │ xxx-xx-xxx │     
    └────────────┘     

[3/12/2023, 1:44:29 PM] Homebridge v1.6.0 (HAP v0.11.0) (Homebridge 2815) is running on port 51618.
[3/12/2023, 1:44:30 PM] [homebridge-unifi-occupancy] Launched child bridge with PID 3125
[3/12/2023, 1:44:31 PM] Registering platform 'homebridge-unifi-occupancy.UnifiOccupancy'
[3/12/2023, 1:44:31 PM] [homebridge-unifi-occupancy] Loaded homebridge-unifi-occupancy v1.2.4 child bridge successfully
[3/12/2023, 1:44:31 PM] Loaded 2 cached accessories from cachedAccessories.0E6118xxx2C936.
[3/12/2023, 1:44:31 PM] Homebridge v1.6.0 (HAP v0.11.0) (homebridge-unifi-occupancy) is running on port 48328.
[3/12/2023, 1:44:33 PM] [homebridge-unifi-occupancy] Updated accessory status: "Anywhere Guest: 26:42:xx:9b:ec:xx" active
[3/12/2023, 1:44:33 PM] [homebridge-unifi-occupancy] Updated accessory status: "Anywhere xxxxxx" active

Plugin Config:


{
    "unifi": {
        "controller": "https://xx.168.xx.11",
        "username": "XXX.XXX@XXXXXX.co.uk",
        "password": "Xxxxxxx",
        "site": "default",
        "secure": false
    },
    "interval": 180,
    "showAsOwner": "smartphone",
    "deviceType": {
        "smartphone": {
            "enabled": false,
            "homeAccessory": true,
            "roomCatchallAccessory": false,
            "homeCatchallAccessory": false,
            "lazy": false
        },
        "smart_watch": {
            "enabled": false,
            "homeAccessory": true,
            "roomCatchallAccessory": false,
            "homeCatchallAccessory": false,
            "lazy": false
        },
        "laptop": {
            "enabled": false,
            "homeAccessory": false,
            "roomCatchallAccessory": false,
            "homeCatchallAccessory": false,
            "lazy": false
        },
        "tablet": {
            "enabled": false,
            "homeAccessory": false,
            "roomCatchallAccessory": false,
            "homeCatchallAccessory": false,
            "lazy": false
        },
        "ereader": {
            "enabled": false,
            "homeAccessory": false,
            "roomCatchallAccessory": false,
            "homeCatchallAccessory": false,
            "lazy": false
        },
        "game_console": {
            "enabled": false,
            "homeAccessory": false,
            "roomCatchallAccessory": false,
            "homeCatchallAccessory": false,
            "lazy": false
        },
        "handheld": {
            "enabled": false,
            "homeAccessory": false,
            "roomCatchallAccessory": false,
            "homeCatchallAccessory": false,
            "lazy": false
        },
        "other": {
            "enabled": false,
            "homeAccessory": false,
            "lazy": false
        },
        "wired": {
            "enabled": false
        }
    },
    "clientRules": [
        {
            "roomAccessory": false,
            "homeAccessory": false,
            "roomCatchallAccessory": false,
            "homeCatchallAccessory": false,
            "lazy": false
        }
    ],
    "platform": "UnifiOccupancy",
    "_bridge": {
        "username": "0E:61:XX:XX:C9:36",
        "port": 48328
    }
}

Screenshots:

Environment:

DouweM commented 1 year ago

Are you using Homebridge UI X to configure or just the JSON config? Either way, you currently have homeAccessory enabled for phones and watches, but you want enabled (the first checkbox in the UI) which is for the per-room accessories. With that change, you should start seeing accessories for each device on each AP.

If you want to map the AP names to HomeKit room names, you can do that in settings too. Are you saying you've tried that but they're not being retained? Does it work to add accessPointsAliases directly to the JSON config (see example in README)?

nodecentral commented 1 year ago

Hi @DouweM , thanks for responding, just to check your first section, I had it set to anywhere, so I’ve changed it to the first one (see below) 1171CDF7-2DF1-429F-81C9-52C5EBCED8BB

nodecentral commented 1 year ago

Moving onto the second one, mapping my Unifi APs to Rooms - I struggled with this as it didn’t seem clear (to me) exactly what to do in the UI setting, so any help you can give would be great. I’m happy to work either via the UI or the JSON

Ultimately what I want to avoid is seeing all my Unifi infrastructure items, secure gateway, Switches and access points as devices - I only want to see specific people’s personal devices, and ideally which room they are in / connected to)

DouweM commented 1 year ago

@nodecentral My Rooms config looks like this, with APs on the left and the rooms they map to on the right:

Captura de pantalla 2023-03-13 a la(s) 18 06 46

Does that help?

If you have multiple network devices in one room, some of which may never actually have clients connected to them (like a switch that only has other network devices attached), you can map them all to the same room, so you'll only see "[Room] [Client]" sensors for real rooms, instead of one for each AP/switch even ones that client would never connect to.

nodecentral commented 1 year ago

Thanks @DouweM , really appreciate the help..

I have the AP to Room mapping set up like you above, but all my sensors appears under the Default Room ? For example I have a sensor device called Landing Joe (based on the [Room] [Device] setting) but it’s not being placed in the Landing room within Home ? Shouldn’t the mapping do that automatically ?

DouweM commented 1 year ago

Ah - no, unfortunately that can't be done by Homebridge. Per the readme:

Note that the accessories still need to be manually assigned to the corresponding room in the Home app, which will then automatically hide the room name prefix in the sensor name.