clyra / unifics

[DEPRECATED] Unifi Counter Sensor
GNU General Public License v3.0
13 stars 4 forks source link

Specify a wifi network to show clients #32

Open veeds2 opened 9 months ago

veeds2 commented 9 months ago

Problem: There is currently no way to select the wifi network from which to display connected clients.

Unifi APs can broadcast multiple wifi SSIDs. For Example the Chime being assigned to "Unifi Wireless". Is there some way to select the wifi network name at initial configuration so that all other clients connected to the AP but sit on a different wifi network are ignored?

Thank you

clyra commented 9 months ago

Hi,

The sensor shows the number of clients per ssid and per Access Points as attributes. You may display all of them with a entity-attribute card, for example:

entities:
  - sensor.unifi
  - entity: sensor.unifi
    filter:
      include:
        - sensor.unifi.<ssid foo>
        - sensor.unifi.<ssid bar>
        - sensor.unifi.<ssid guest>
        - key: sensor.unifi.ap*
    heading_name: Attributes
    heading_state: States
    type: custom:entity-attributes-card
title: Unifi
type: entities

Another option is just create a template sensor and use something like "{{ state_attr('sensor.unifi', '') }} as the "value_template".

veeds2 commented 7 months ago

Thank you for the reply.

I the debug of NodeRED I dont see anyway to filter on SSID. How can you filter on SSID via NOde RED Config?

This is what I see in the attributes debug notes

entity_id: "sensor.unifi_couter_sensor" state: 59 attributes: object AP C1 - F1: 9 AP C1 - F2: 0 AP C2 - F1: 6 AP C2 - F2: 2 AP C3 - F1: 10 AP C3 - F2: 4 AP C4 - F1: 2 AP C4 - F2: 2 UnifiWifi: 32 wired: 24 UniFi Wireless: 3 unit_of_measurement: "devices" friendly_name: "Unifi Couter Sensor" context: object parent_id: null user_id: null last_changed: "2024-03-22T18:05:52.967Z" last_updated: "2024-03-22T18:05:52.967Z" timeSinceChangedMs: 192127 original_state: "59" topic: "sensor.unifi_couter_sensor"

veeds2 commented 4 months ago

I am using node RED, and I dont see a way to filter on SSID so that all APs only show counts for that SSID and not all SSIDs. Is that possible?

veeds2 commented 4 months ago

I am trying to implement presence tracking when clients connect to SSID: Home but I have IOT devices on a different network connected to the same APs. In nodeRED i only want to see counts on APs for the SSID:home network only and then use that data for action.

veeds2 commented 4 months ago

Patched it by adding client.get('essid') to the AP name, not it lists clients per AP per SSID!

if client.get('ap_mac') is not None: ap_name = "AP " + ap_names.get(client.get('ap_mac', 'noname')) + client.get('essid') self._attr[ap_name] = self._attr.get(ap_name, 0) + 1