clyra / unifics

Unifi Counter Sensor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unifics reports 0 clients until reloaded - intermittent

c11umw opened this issue · comments

Core 2024.1.2
Supervisor 2023.12.0
Operating System 11.4
Frontend 20240104.0
Latest unifics installed
Connects to UDM SE UniFi OS v3.2.7
Unifi Network v8.0.26

Installed about 6 months ago via HACS + Devices/Services

Recently I'd noticed that unifics sometimes returns unavailable and sometimes available, but just a 0 count on clients.
I set up an automation yesterday to watch for it and reload it and it comes back normal again, but you can see in the screenshot that it keeps dropping to 0

image

This is a bit of a problem as I have automations that watch the # of people on the guest network, so when it thinks there's 0 then it affects the behaviour of other automations (mainly light timers).

For ref, my "reload" automation

alias: Reload Unifics
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.unifics
    to: unavailable
    for:
      hours: 0
      minutes: 0
      seconds: 15
  - platform: state
    entity_id:
      - sensor.unifics
    to: unknown
    for:
      hours: 0
      minutes: 0
      seconds: 15
  - platform: template
    value_template: "{{ states('sensor.unifics') | float(\"no\") == 0 }}"
    for:
      hours: 0
      minutes: 0
      seconds: 30
    alias: Unifics = 0 for 30s
condition: []
action:
  - repeat:
      sequence:
        - delay:
            hours: 0
            minutes: 1
            seconds: 30
            milliseconds: 0
        - service: homeassistant.reload_config_entry
          target:
            entity_id: sensor.unifics
          data: {}
        - delay:
            hours: 0
            minutes: 0
            seconds: 30
            milliseconds: 0
      until:
        - alias: unifics is displaying a number
          condition: template
          value_template: "{{ states('sensor.unifics') | float(\"no\") is number }}"
        - alias: unifics is returning > 0
          condition: template
          value_template: "{{ states('sensor.unifics') | float(0) > 0 }}"
    alias: Repeat the Reload until a number is returned
mode: single

Hi,

Please, send the logs. This behaviour happens when the integration fails to poll the controller. I'm working on a related issue and may change this as well, perhaps making the integration return unavaible or just ignoring a failed attempt.

Hi,

try the last version plz.

I am having the same issue. Unifics appears to be up to date. The state will remain 0 until reloaded.

logs, please.

Installed latest version of unifics
Will monitor and attach logs if I see a repeat of the issue

Since installing the latest version (988b859), the issue appears to be resolved 👍
image

Ok guys, closing this issue

Ok guys, closing this issue.