You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Home-AssistantConfig/config/packages/wireless.yaml

132 lines
4.6 KiB

######################################################################
# @CCOSTAN - Follow Me on X
# For more info visit https://www.vcloudinfo.com/click-here
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
# -------------------------------------------------------------------
# Wireless AP Alerts - Unifi client monitoring and repair triggers
# Opens/clears Spook repairs and dispatches Joanna when APs stay at 0 clients.
# -------------------------------------------------------------------
# Notes: Discussion context: https://github.com/CCOSTAN/Home-AssistantConfig/issues/1534
# Notes: Joanna remediation requests default to investigate + recommend (no auto reset/power-cycle).
######################################################################
automation:
- id: unifi_ap_no_clients_repair_combined
alias: "Unifi AP Create Repair Issue after 5m of 0 Clients"
mode: single
trigger:
- platform: state
entity_id: sensor.unifi_ap_office_clients
to: "0"
for: { minutes: 5 }
- platform: state
entity_id: sensor.unifi_ap_study_clients
to: "0"
for: { minutes: 5 }
- platform: state
entity_id: sensor.unifi_ap_garage_clients
to: "0"
for: { minutes: 5 }
variables:
ap_name: >
{% if trigger.entity_id == 'sensor.unifi_ap_office_clients' %}
Office
{% elif trigger.entity_id == 'sensor.unifi_ap_study_clients' %}
Study
{% else %}
Garage
{% endif %}
uptime_sensor: >
{% if trigger.entity_id == 'sensor.unifi_ap_office_clients' %}
sensor.unifi_ap_office_uptime
{% elif trigger.entity_id == 'sensor.unifi_ap_study_clients' %}
sensor.unifi_ap_study_uptime
{% else %}
sensor.unifi_ap_garage_uptime
{% endif %}
issue_id: >
{{ ap_name | lower }}_ap_no_clients
client_sensor: "{{ trigger.entity_id }}"
client_count: "{{ states(trigger.entity_id) }}"
uptime_value: "{{ states(uptime_sensor) }}"
trigger_context: "HA automation unifi_ap_no_clients_repair_combined (Unifi AP Create Repair Issue after 5m of 0 Clients)"
action:
- service: repairs.create
data:
issue_id: "{{ issue_id }}"
fixable: false
severity: error
title: "{{ ap_name }} AP has 0 Wi-Fi Clients"
description: >
The {{ ap_name }} Unifi AP has reported 0 connected clients for
at least 5 minutes.
Current uptime: {{ uptime_value }}.
View and manage this AP here:
https://unifi.ui.com
- service: script.send_to_logbook
data:
topic: "WIRELESS"
message: >-
{{ ap_name }} AP has 0 clients for 5 minutes. Repair {{ issue_id }} opened and Joanna investigation requested.
- service: script.joanna_dispatch
data:
trigger_context: "{{ trigger_context }}"
source: "home_assistant_automation.unifi_ap_no_clients_repair_combined"
summary: "{{ ap_name }} Unifi AP reported 0 clients for 5 minutes"
entity_ids:
- "{{ client_sensor }}"
- "{{ uptime_sensor }}"
diagnostics: >-
issue_id={{ issue_id }},
ap_name={{ ap_name }},
client_sensor={{ client_sensor }},
client_count={{ client_count }},
uptime_sensor={{ uptime_sensor }},
uptime={{ uptime_value }}
request: >-
Investigate Unifi controller and AP health, then recommend remediation.
Do not run automated reset or power-cycle actions unless explicitly requested.
- id: unifi_ap_no_clients_repair_resolved_combined
alias: "Unifi AP Resolve Repair Issue When Clients Return"
mode: single
trigger:
- platform: numeric_state
entity_id:
- sensor.unifi_ap_office_clients
- sensor.unifi_ap_study_clients
- sensor.unifi_ap_garage_clients
above: 0
variables:
ap_name: >
{% if trigger.entity_id == 'sensor.unifi_ap_office_clients' %}
Office
{% elif trigger.entity_id == 'sensor.unifi_ap_study_clients' %}
Study
{% else %}
Garage
{% endif %}
issue_id: >
{{ ap_name | lower }}_ap_no_clients
action:
- service: repairs.remove
continue_on_error: true
data:
issue_id: "{{ issue_id }}"
- service: script.send_to_logbook
data:
topic: "WIRELESS"
message: "{{ ap_name }} AP clients recovered above 0. Repair {{ issue_id }} cleared."

Powered by TurnKey Linux.