zachcheatham / ha-omada

Home Assistant TP-Link Omada Integration
196 stars 28 forks source link

Add device tracker for wired connections #13

Open mielverkerken opened 2 years ago

mielverkerken commented 2 years ago

Currently, only device trackers are created for wireless clients. It could be useful to also add a device tracker for wired clients. For instance, to check if a desktop computer is turned on or certain UTP sockets are in use.

Maybe an extra option could be added to the configuration to enable/disable this feature.

ghost commented 2 years ago

There's a slightly different data structure for wired clients.

On the /clients-endpoint, wired connections have a networkName-key, whereas all wireless connections contain an ssid-key:

E.g.:

{
    "10": {
        "mac": "BC-11-22-33-44-55",
        "name": "desktop",
        "hostName": "desktop",
        "deviceType": "pc",
        "ip": "192.168.0.10",
        "connectType": 2,
        "connectDevType": "gateway",
        "wireless": false,
        "gatewayMac": "28-11-22-33-44-55",
        "gatewayName": "router",
        "vid": 1,
        "networkName": "LAN",
        "activity": 0,
        "trafficDown": 23775005,
        "trafficUp": 2062754,
        "uptime": 8018,
        "lastSeen": 1643744150277,
        "authStatus": 0,
        "guest": false,
        "active": true,
        "manager": true,
        "downPacket": 22836,
        "upPacket": 10157
    }
}
{
    "7": {
        "mac": "B0-11-22-33-44-55",
        "name": "chromecast-living",
        "hostName": "Chromecast",
        "deviceType": "tv",
        "ip": "192.168.0.6",
        "connectType": 1,
        "connectDevType": "ap",
        "wireless": true,
        "ssid": "Wi-Fi",
        "signalLevel": 85,
        "signalRank": 5,
        "wifiMode": 5,
        "apName": "accesspoint-living",
        "apMac": "D8-07-B6-55-55-55",
        "radioId": 1,
        "channel": 48,
        "rxRate": 433000,
        "txRate": 433000,
        "powerSave": false,
        "rssi": -56,
        "activity": 324,
        "trafficDown": 1434293099,
        "trafficUp": 132468568,
        "uptime": 230217,
        "lastSeen": 1643744125121,
        "authStatus": 0,
        "guest": false,
        "active": true,
        "manager": false,
        "downPacket": 1722454,
        "upPacket": 1279910
    }
}

I attempted to get both wireless and wired connections in the device tracker against a Omada v4.4.8-controller running on Debian.

Some progression:

Home Assistant TP-Link Omada v0.2.1 Configuration

And some puzzles: when both networks are selected, only the 'devices' and the 'disconnected' clients are shown. Instead of both type of networks.

But hey, at least they're now available as devices: Home Assistant TP Link Omada v0.2.1 Device Tracker Entities

Any idea how to fix this?

Gerben321 commented 2 years ago

Any update on this? I only have wired clients so it seems I can't use this integration :(

Gerben321 commented 1 year ago

So does it work when you select one of these options in your MR? In that case I could just use that, since I have no wireless clients.