tomaae / homeassistant-mikrotik_router

Mikrotik router integration for Home Assistant
Apache License 2.0
300 stars 50 forks source link

[Feature] New sensor that counts devices per interface #233

Open gelokatil opened 2 years ago

gelokatil commented 2 years ago

Describe the solution you'd like

Currently there is a sensor that indicates the clients connected to all the Wireless SSIDs that the device has.

Is it possible that there is another sensor that can count the number of clients connected to a given SSID/interface? As many sensors as the SSID the device has configured.

Thank you very much

Describe alternatives you've considered

In the Registration section within the Wireless section you can see the list of devices and the interface to which they belong.

imagen

tomaae commented 2 years ago

What would be a purpouse for such sensor?

gelokatil commented 2 years ago

The purpose of the sensor would be for statistical and monitoring purposes.

In the same way that we can now know the number of clients that we have connected to our Mikrotik device by LAN and by Wifi, I find it useful to be able to break down the information with more granularity.

tomaae commented 2 years ago

ok, but on that screenshot, there is no radio name, just physical interface. can you provide print terse?

gelokatil commented 2 years ago

The specific SSID associated with the physical interface does not appear in the Registration section.

imagen

To obtain this value, you must go to the Wifi Interfaces section, which appears there in the SSID column.

imagen

tomaae commented 2 years ago

I see, so mikrotik creates additional virtual interface for multiple SSID. thats doable then. Can you give me print terse from wireless interfaces?

gelokatil commented 2 years ago

Exactly, by default you only have the physical interfaces wlan1 and wlan2 for the 2.4Ghz and 5Ghz wireless networks, as you can see, you can create additional virtual SSIDs linked to the physical interfaces you have, being able to have more than 2 simultaneous SSIDs

Here is the output of the command.

interface wireless print terse

0 R name=wlan1 mtu=1500 l2mtu=1600 mac-address=2C:C8:1B:38:D6:1C arp=enabled disable-running-check=no interface-type=IPQ4019 radio-name=2CC81B38D61C mode=ap-bridge ssid=TATAD area= frequency-mode=regulatory-domain country=spain installation=indoor antenna-gain=2 frequency=auto band=2ghz-b/g/n channel-width=20/40mhz-XX secondary-frequency= scan-list=default wireless-protocol=802.11 rate-set=default supported-rates-b=1Mbps,2Mbps,5.5Mbps,11Mbps supported-rates-a/g=6Mbps,9Mbps,12Mbps,18Mbps,24Mbps,36Mbps,48Mbps,54Mbps basic-rates-b=1Mbps basic-rates-a/g=6Mbps max-station-count=2007 distance=indoors tx-power-mode=default vlan-mode=use-tag vlan-id=12 wds-mode=disabled wds-default-bridge=none wds-default-cost=100 wds-cost-range=50-150 wds-ignore-ssid=no update-stats-interval=disabled bridge-mode=enabled default-authentication=yes default-forwarding=yes default-ap-tx-limit=0 default-client-tx-limit=0 wmm-support=disabled hide-ssid=no security-profile=default wps-mode=disabled station-roaming=disabled disconnect-timeout=3s on-fail-retry-time=100ms preamble-mode=both compression=no allow-sharedkey=no station-bridge-clone-mac=00:00:00:00:00:00 ampdu-priorities=0 ampdu-subframes=default guard-interval=any ht-supported-mcs=mcs-0,mcs-1,mcs-2,mcs-3,mcs-4,mcs-5,mcs-6,mcs-7,mcs-8,mcs-9,mcs-10,mcs-11,mcs-12,mcs-13,mcs-14,mcs-15,mcs-16,mcs-17,mcs-18,mcs-19,mcs-20,mcs-21,mcs-22,mcs-23 ht-basic-mcs=mcs-0,mcs-1,mcs-2,mcs-3,mcs-4,mcs-5,mcs-6,mcs-7 tx-chains=0,1 rx-chains=0,1 amsdu-limit=8192 amsdu-threshold=8192 tdma-debug=0 tdma-test-mode=0 tdma-hw-test-mode= tdma-override-rate=disabled tdma-override-size=0 tdma-period-size=2 nv2-queue-count=2 nv2-qos=default nv2-cell-radius=30 nv2-security=disabled nv2-preshared-key= nv2-mode=dynamic-downlink nv2-downlink-ratio=50 nv2-sync-secret= hw-retries=7 frame-lifetime=0 adaptive-noise-immunity=none hw-fragmentation-threshold=disabled hw-protection-mode=none hw-protection-threshold=0 frequency-offset=0 rate-selection=advanced multicast-helper=default multicast-buffering=enabled keepalive-frames=enabled skip-dfs-channels=disabled
1 R name=wlan2 mtu=1500 l2mtu=1600 mac-address=2C:C8:1B:38:D6:1D arp=enabled disable-running-check=no interface-type=IPQ4019 radio-name=2CC81B38D61D mode=ap-bridge ssid=TATA area= frequency-mode=regulatory-domain country=spain installation=indoor antenna-gain=3 frequency=5240 band=5ghz-a/n/ac channel-width=20/40/80mhz-XXXX secondary-frequency= scan-list=default wireless-protocol=802.11 rate-set=default supported-rates-a/g=6Mbps,9Mbps,12Mbps,18Mbps,24Mbps,36Mbps,48Mbps,54Mbps basic-rates-a/g=6Mbps max-station-count=2007 distance=indoors tx-power-mode=default vlan-mode=use-tag vlan-id=10 wds-mode=disabled wds-default-bridge=none wds-default-cost=100 wds-cost-range=50-150 wds-ignore-ssid=no update-stats-interval=disabled bridge-mode=enabled default-authentication=yes default-forwarding=yes default-ap-tx-limit=0 default-client-tx-limit=0 wmm-support=disabled hide-ssid=no security-profile=default wps-mode=disabled station-roaming=disabled disconnect-timeout=3s on-fail-retry-time=100ms preamble-mode=both compression=no allow-sharedkey=no station-bridge-clone-mac=00:00:00:00:00:00 ampdu-priorities=0 ampdu-subframes=default guard-interval=any ht-supported-mcs=mcs-0,mcs-1,mcs-2,mcs-3,mcs-4,mcs-5,mcs-6,mcs-7,mcs-8,mcs-9,mcs-10,mcs-11,mcs-12,mcs-13,mcs-14,mcs-15,mcs-16,mcs-17,mcs-18,mcs-19,mcs-20,mcs-21,mcs-22,mcs-23 ht-basic-mcs=mcs-0,mcs-1,mcs-2,mcs-3,mcs-4,mcs-5,mcs-6,mcs-7 vht-supported-mcs=mcs0-9,mcs0-9,mcs0-9 vht-basic-mcs=mcs0-7 tx-chains=0,1 rx-chains=0,1 amsdu-limit=8192 amsdu-threshold=8192 tdma-debug=0 tdma-test-mode=0 tdma-hw-test-mode= tdma-override-rate=disabled tdma-override-size=0 tdma-period-size=2 nv2-queue-count=2 nv2-qos=default nv2-cell-radius=30 nv2-security=disabled nv2-preshared-key= nv2-mode=dynamic-downlink nv2-downlink-ratio=50 nv2-sync-secret= hw-retries=7 frame-lifetime=0 adaptive-noise-immunity=none hw-fragmentation-threshold=disabled hw-protection-mode=none hw-protection-threshold=0 frequency-offset=0 rate-selection=advanced multicast-helper=default multicast-buffering=enabled keepalive-frames=enabled skip-dfs-channels=disabled
2   name=wlan3 mtu=1500 l2mtu=1600 mac-address=2E:C8:1B:38:D6:1C arp=enabled disable-running-check=no interface-type=virtual master-interface=wlan1 mode=ap-bridge ssid=TATAX area= max-station-count=2007 vlan-mode=use-tag vlan-id=5 wds-mode=disabled wds-default-bridge=none wds-default-cost=0 wds-cost-range=0 wds-ignore-ssid=no update-stats-interval=disabled bridge-mode=enabled default-authentication=yes default-forwarding=yes default-ap-tx-limit=0 default-client-tx-limit=0 wmm-support=disabled hide-ssid=no security-profile=default wps-mode=disabled station-roaming=disabled station-bridge-clone-mac=00:00:00:00:00:00 multicast-helper=default multicast-buffering=disabled keepalive-frames=disabled
gelokatil commented 2 years ago

ok, but on that screenshot, there is no radio name, just physical interface. can you provide print terse?

I had forgotten to send you the output of the command, here it is.

interface wireless registration-table print terse

 0 interface=wlan2 mac-address=4C:A5:6D:03:9A:19 ap=no wds=no bridge=no
 1 interface=wlan1 mac-address=C4:4F:33:8D:D3:44 ap=no wds=no bridge=no
 2 interface=wlan1 mac-address=04:CF:8C:AB:98:F7 ap=no wds=no bridge=no
 3 interface=wlan1 mac-address=4C:11:AE:E6:EE:4C ap=no wds=no bridge=no
 4 interface=wlan1 mac-address=28:6D:CD:49:AE:D8 ap=no wds=no bridge=no
 5 interface=wlan1 mac-address=08:ED:ED:92:8E:EB ap=no wds=no bridge=no
 6 interface=wlan1 mac-address=44:5D:5E:02:26:FE ap=no wds=no bridge=no
 7 interface=wlan1 mac-address=44:5D:5E:01:BC:12 ap=no wds=no bridge=no
 8 interface=wlan1 mac-address=44:5D:5E:43:38:0C ap=no wds=no bridge=no
 9 interface=wlan1 mac-address=44:5D:5E:01:DA:F2 ap=no wds=no bridge=no
10 interface=wlan1 mac-address=C4:DD:57:34:3D:7A ap=no wds=no bridge=no
11 interface=wlan1 mac-address=F4:AF:E7:93:CF:4B ap=no wds=no bridge=no
12 interface=wlan1 mac-address=98:CD:AC:1E:45:7E ap=no wds=no bridge=no
13 interface=wlan1 mac-address=28:56:5A:82:94:D2 ap=no wds=no bridge=no
14 interface=wlan1 mac-address=DC:A6:32:3F:8E:2A ap=no wds=no bridge=no
15 interface=wlan1 mac-address=A0:BD:1D:BE:71:A3 ap=no wds=no bridge=no
16 interface=wlan1 mac-address=08:ED:ED:8F:F2:DE ap=no wds=no bridge=no
tomaae commented 2 years ago

thanks, I think thats all I will need

gelokatil commented 2 years ago

Perfect, let me know if you need anything else. Thank you very much.

caiohsilveira commented 5 months ago

I think this has stopped in time, but I'd like to add a request. When we don't use native mikrotik wifi radios but use other common routers as access points, they are usually configured in a bridge, so this same information of how many and which clients are on each interface is displayed in the hosts tab of the bridge. It would be relevant to have it this way too. After all, it's more common to have access points from other manufacturers.