Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 45 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ UniFi Network Rules is a custom integration for Home Assistant that integrates w
- Traffic/firewall rules (non-zone-based firewall)
- Port Forwarding rules
- Traffic Routes & Traffic Route Kill Switch
- Static Routes (network routing configurations)
- QoS rules
- OpenVPN Client and Server configurations
- WireGuard Client and Server configurations
Expand Down Expand Up @@ -208,6 +209,7 @@ UniFi Network Rules provides a **unified trigger system** powered by intelligent
- **Firewall Policies** (`firewall_policy`): Zone-based firewall rules
- **Port Forwards** (`port_forward`): Port forwarding rules
- **Traffic Routes** (`traffic_route`): Network routing rules
- **Static Routes** (`route`): Static network routing configurations
- **Traffic Rules** (`traffic_rule`): Legacy firewall rules
- **QoS Rules** (`qos_rule`): Quality of Service rules
- **VPN Clients** (`vpn_client`): VPN client configurations
Expand Down Expand Up @@ -764,6 +766,39 @@ actions:
mode: parallel
```

### 7. Static Route Management - Network Connectivity Monitoring

Monitor static route changes and ensure critical network paths remain active:

```yaml
alias: Critical Route Monitor
description: Alert when critical static routes are disabled
triggers:
- trigger: unifi_network_rules
type: unr_changed
change_type: route
change_action: disabled
name_filter: "Critical"
conditions: []
actions:
- action: notify.admin_team
data:
title: "⚠️ Critical Network Route Disabled"
message: >
ALERT: Critical network route "{{ trigger.entity_name }}" was disabled.
Destination: {{ trigger.old_state.destination if trigger.old_state else "Unknown" }}
This may affect network connectivity to critical services.
data:
priority: high
category: network
- action: persistent_notification.create
data:
title: "Network Route Alert"
message: >
Critical route {{ trigger.entity_name }} was disabled at {{ trigger.timestamp }}
mode: single
```

### Advanced Filtering Examples

#### Filter by Multiple Rule Types
Expand All @@ -778,6 +813,10 @@ triggers:
type: unr_changed
change_type: vpn_client
change_action: [enabled, disabled, modified]
- trigger: unifi_network_rules
type: unr_changed
change_type: route
change_action: [enabled, disabled, modified]
```

#### Filter by Specific Rule Names
Expand Down Expand Up @@ -975,13 +1014,15 @@ The UniFi Network Rules integration supports several types of rules:
- The main switch that enables/disables the route
- A child "kill switch" that blocks all traffic if the route is down (prevents data leakage if your VPN disconnects)

4. **QoS Rules (qos_rule)**: Quality of Service rules that prioritize certain types of traffic on your network. These rules can ensure critical applications (like video conferencing) get bandwidth priority over less time-sensitive applications.
4. **Static Routes (route)**: Configure static network routes that define how traffic is routed between different network segments. These are fundamental routing table entries that determine network paths and can be enabled/disabled for network management and troubleshooting.

5. **QoS Rules (qos_rule)**: Quality of Service rules that prioritize certain types of traffic on your network. These rules can ensure critical applications (like video conferencing) get bandwidth priority over less time-sensitive applications.

5. **Port Profiles (port_profile)**: Switch port configurations that define how network ports are configured, including VLAN assignments, PoE settings, and operational modes. These control the behavior of individual switch ports.
6. **Port Profiles (port_profile)**: Switch port configurations that define how network ports are configured, including VLAN assignments, PoE settings, and operational modes. These control the behavior of individual switch ports.

6. **Networks (network)**: Network configurations that define VLANs and network segments in your UniFi environment. These control the fundamental network infrastructure and IP addressing schemes.
7. **Networks (network)**: Network configurations that define VLANs and network segments in your UniFi environment. These control the fundamental network infrastructure and IP addressing schemes.

7. **Legacy Rules**: For older UniFi OS versions, there are also legacy_firewall and legacy_traffic rule types, which are mapped to "policy" when using the service.
8. **Legacy Rules**: For older UniFi OS versions, there are also legacy_firewall and legacy_traffic rule types, which are mapped to "policy" when using the service.

## Local Development

Expand Down
8 changes: 8 additions & 0 deletions custom_components/unifi_network_rules/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
API_ENDPOINT_QOS_RULES_BATCH,
API_ENDPOINT_NETWORK_CONF,
API_ENDPOINT_NETWORK_CONF_DETAIL,
API_ENDPOINT_STATIC_ROUTES,
API_ENDPOINT_STATIC_ROUTE_DETAIL,
API_ENDPOINT_OBJECTS,
API_ENDPOINT_OBJECT_DETAIL,
API_ENDPOINT_PORT_PROFILES,
Expand Down Expand Up @@ -118,6 +120,8 @@
API_PATH_QOS_RULES_BATCH_DELETE,
API_PATH_NETWORK_CONF,
API_PATH_NETWORK_CONF_DETAIL,
API_PATH_STATIC_ROUTES,
API_PATH_STATIC_ROUTE_DETAIL,
API_PATH_PORT_PROFILES,
API_PATH_PORT_PROFILE_DETAIL,
API_PATH_WLAN_RATE_PROFILES,
Expand Down Expand Up @@ -222,6 +226,8 @@
"API_ENDPOINT_QOS_RULES_BATCH",
"API_ENDPOINT_NETWORK_CONF",
"API_ENDPOINT_NETWORK_CONF_DETAIL",
"API_ENDPOINT_STATIC_ROUTES",
"API_ENDPOINT_STATIC_ROUTE_DETAIL",
"API_ENDPOINT_OBJECTS",
"API_ENDPOINT_OBJECT_DETAIL",
"API_ENDPOINT_PORT_PROFILES",
Expand Down Expand Up @@ -254,6 +260,8 @@
"API_PATH_QOS_RULES_BATCH_DELETE",
"API_PATH_NETWORK_CONF",
"API_PATH_NETWORK_CONF_DETAIL",
"API_PATH_STATIC_ROUTES",
"API_PATH_STATIC_ROUTE_DETAIL",
"API_PATH_PORT_PROFILES",
"API_PATH_PORT_PROFILE_DETAIL",
"API_PATH_WLAN_RATE_PROFILES",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
API_ENDPOINT_NETWORK_CONF: Final = "/proxy/network/api/s/{site}/rest/networkconf"
API_ENDPOINT_NETWORK_CONF_DETAIL: Final = "/proxy/network/api/s/{site}/rest/networkconf/{network_id}"

# Static Routes (V1 API)
API_ENDPOINT_STATIC_ROUTES: Final = "/proxy/network/api/s/{site}/rest/routing"
API_ENDPOINT_STATIC_ROUTE_DETAIL: Final = "/proxy/network/api/s/{site}/rest/routing/{route_id}"

# Objects and Profiles
API_ENDPOINT_OBJECTS: Final = "/proxy/network/v2/api/site/{site}/objects"
API_ENDPOINT_OBJECT_DETAIL: Final = "/proxy/network/v2/api/site/{site}/objects/{object_id}"
Expand Down Expand Up @@ -62,6 +66,10 @@
API_PATH_NETWORK_CONF: Final = "/rest/networkconf"
API_PATH_NETWORK_CONF_DETAIL: Final = "/rest/networkconf/{network_id}"

# Static Routes (aiounifi path fragments - V1 API)
API_PATH_STATIC_ROUTES: Final = "/rest/routing"
API_PATH_STATIC_ROUTE_DETAIL: Final = "/rest/routing/{route_id}"

# Objects and Profiles (aiounifi path fragments)
API_PATH_PORT_PROFILES: Final = "/rest/portconf"
API_PATH_PORT_PROFILE_DETAIL: Final = "/rest/portconf/{profile_id}"
Expand Down
Loading