Skip to content

Commit 34eaa2c

Browse files
authored
Merge pull request #119 from sirkirby/feature/static-routes
2 parents 09f24e3 + 8df65ac commit 34eaa2c

17 files changed

Lines changed: 1297 additions & 204 deletions

README.md

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ UniFi Network Rules is a custom integration for Home Assistant that integrates w
2020
- Traffic/firewall rules (non-zone-based firewall)
2121
- Port Forwarding rules
2222
- Traffic Routes & Traffic Route Kill Switch
23+
- Static Routes (network routing configurations)
2324
- QoS rules
2425
- OpenVPN Client and Server configurations
2526
- WireGuard Client and Server configurations
@@ -208,6 +209,7 @@ UniFi Network Rules provides a **unified trigger system** powered by intelligent
208209
- **Firewall Policies** (`firewall_policy`): Zone-based firewall rules
209210
- **Port Forwards** (`port_forward`): Port forwarding rules
210211
- **Traffic Routes** (`traffic_route`): Network routing rules
212+
- **Static Routes** (`route`): Static network routing configurations
211213
- **Traffic Rules** (`traffic_rule`): Legacy firewall rules
212214
- **QoS Rules** (`qos_rule`): Quality of Service rules
213215
- **VPN Clients** (`vpn_client`): VPN client configurations
@@ -764,6 +766,39 @@ actions:
764766
mode: parallel
765767
```
766768

769+
### 7. Static Route Management - Network Connectivity Monitoring
770+
771+
Monitor static route changes and ensure critical network paths remain active:
772+
773+
```yaml
774+
alias: Critical Route Monitor
775+
description: Alert when critical static routes are disabled
776+
triggers:
777+
- trigger: unifi_network_rules
778+
type: unr_changed
779+
change_type: route
780+
change_action: disabled
781+
name_filter: "Critical"
782+
conditions: []
783+
actions:
784+
- action: notify.admin_team
785+
data:
786+
title: "⚠️ Critical Network Route Disabled"
787+
message: >
788+
ALERT: Critical network route "{{ trigger.entity_name }}" was disabled.
789+
Destination: {{ trigger.old_state.destination if trigger.old_state else "Unknown" }}
790+
This may affect network connectivity to critical services.
791+
data:
792+
priority: high
793+
category: network
794+
- action: persistent_notification.create
795+
data:
796+
title: "Network Route Alert"
797+
message: >
798+
Critical route {{ trigger.entity_name }} was disabled at {{ trigger.timestamp }}
799+
mode: single
800+
```
801+
767802
### Advanced Filtering Examples
768803

769804
#### Filter by Multiple Rule Types
@@ -778,6 +813,10 @@ triggers:
778813
type: unr_changed
779814
change_type: vpn_client
780815
change_action: [enabled, disabled, modified]
816+
- trigger: unifi_network_rules
817+
type: unr_changed
818+
change_type: route
819+
change_action: [enabled, disabled, modified]
781820
```
782821

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

978-
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.
1017+
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.
1018+
1019+
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.
9791020

980-
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.
1021+
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.
9811022

982-
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.
1023+
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.
9831024

984-
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.
1025+
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.
9851026

9861027
## Local Development
9871028

custom_components/unifi_network_rules/constants/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@
8686
API_ENDPOINT_QOS_RULES_BATCH,
8787
API_ENDPOINT_NETWORK_CONF,
8888
API_ENDPOINT_NETWORK_CONF_DETAIL,
89+
API_ENDPOINT_STATIC_ROUTES,
90+
API_ENDPOINT_STATIC_ROUTE_DETAIL,
8991
API_ENDPOINT_OBJECTS,
9092
API_ENDPOINT_OBJECT_DETAIL,
9193
API_ENDPOINT_PORT_PROFILES,
@@ -118,6 +120,8 @@
118120
API_PATH_QOS_RULES_BATCH_DELETE,
119121
API_PATH_NETWORK_CONF,
120122
API_PATH_NETWORK_CONF_DETAIL,
123+
API_PATH_STATIC_ROUTES,
124+
API_PATH_STATIC_ROUTE_DETAIL,
121125
API_PATH_PORT_PROFILES,
122126
API_PATH_PORT_PROFILE_DETAIL,
123127
API_PATH_WLAN_RATE_PROFILES,
@@ -222,6 +226,8 @@
222226
"API_ENDPOINT_QOS_RULES_BATCH",
223227
"API_ENDPOINT_NETWORK_CONF",
224228
"API_ENDPOINT_NETWORK_CONF_DETAIL",
229+
"API_ENDPOINT_STATIC_ROUTES",
230+
"API_ENDPOINT_STATIC_ROUTE_DETAIL",
225231
"API_ENDPOINT_OBJECTS",
226232
"API_ENDPOINT_OBJECT_DETAIL",
227233
"API_ENDPOINT_PORT_PROFILES",
@@ -254,6 +260,8 @@
254260
"API_PATH_QOS_RULES_BATCH_DELETE",
255261
"API_PATH_NETWORK_CONF",
256262
"API_PATH_NETWORK_CONF_DETAIL",
263+
"API_PATH_STATIC_ROUTES",
264+
"API_PATH_STATIC_ROUTE_DETAIL",
257265
"API_PATH_PORT_PROFILES",
258266
"API_PATH_PORT_PROFILE_DETAIL",
259267
"API_PATH_WLAN_RATE_PROFILES",

custom_components/unifi_network_rules/constants/api_endpoints.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
API_ENDPOINT_NETWORK_CONF: Final = "/proxy/network/api/s/{site}/rest/networkconf"
2727
API_ENDPOINT_NETWORK_CONF_DETAIL: Final = "/proxy/network/api/s/{site}/rest/networkconf/{network_id}"
2828

29+
# Static Routes (V1 API)
30+
API_ENDPOINT_STATIC_ROUTES: Final = "/proxy/network/api/s/{site}/rest/routing"
31+
API_ENDPOINT_STATIC_ROUTE_DETAIL: Final = "/proxy/network/api/s/{site}/rest/routing/{route_id}"
32+
2933
# Objects and Profiles
3034
API_ENDPOINT_OBJECTS: Final = "/proxy/network/v2/api/site/{site}/objects"
3135
API_ENDPOINT_OBJECT_DETAIL: Final = "/proxy/network/v2/api/site/{site}/objects/{object_id}"
@@ -62,6 +66,10 @@
6266
API_PATH_NETWORK_CONF: Final = "/rest/networkconf"
6367
API_PATH_NETWORK_CONF_DETAIL: Final = "/rest/networkconf/{network_id}"
6468

69+
# Static Routes (aiounifi path fragments - V1 API)
70+
API_PATH_STATIC_ROUTES: Final = "/rest/routing"
71+
API_PATH_STATIC_ROUTE_DETAIL: Final = "/rest/routing/{route_id}"
72+
6573
# Objects and Profiles (aiounifi path fragments)
6674
API_PATH_PORT_PROFILES: Final = "/rest/portconf"
6775
API_PATH_PORT_PROFILE_DETAIL: Final = "/rest/portconf/{profile_id}"

0 commit comments

Comments
 (0)