Skip to content

Implement new firewall api and deprecate plugin#489

Merged
Snuffy2 merged 15 commits intotravisghansen:mainfrom
Snuffy2:Implement-new-firewall-api
Feb 7, 2026
Merged

Implement new firewall api and deprecate plugin#489
Snuffy2 merged 15 commits intotravisghansen:mainfrom
Snuffy2:Implement-new-firewall-api

Conversation

@Snuffy2
Copy link
Collaborator

@Snuffy2 Snuffy2 commented Feb 7, 2026

Summary

This PR modernizes the OPNsense integration by migrating to the new native OPNsense APIs added in firmware 26.1 and deprecating the legacy plugin-based approach.

Key Changes

API Migration

  • Implements support for OPNsense's native firewall APIs (/api/firewall/*)
  • Deprecates the custom plugin dependency (os-homeassistant-maxit) and its get_config endpoint
  • Updates authentication and API client to work with standard OPNsense API endpoints
  • Improves error handling and logging for API interactions

Switch Platform Overhaul

  • New Switches: Adds native firewall rule toggle switches that directly control OPNsense firewall rules via the new API
  • Removed Switches: Deprecates plugin-dependent switches (services, filters, NAT rules) that relied on get_config
  • Switches now provide better state management and real-time updates without requiring the plugin

Architecture Improvements

  • Refactors data coordinator to fetch firewall state through native APIs
  • Updates configuration flow to validate against new API endpoints
  • Enhances entity registration and unique ID generation for firewall rules
  • Improves typing annotations and code structure throughout

Migration Path

  • Existing users will need to remove the os-homeassistant-maxit plugin after upgrading
  • Switches controlling firewall rules will continue working with the new implementation
  • Service and filter switches will be removed; users should migrate to firewall rule switches

Note: This PR also includes pre-commit hook configuration updates and comprehensive docstring improvements across the codebase.

Fixes #485
Partially addresses #488

@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2026

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  custom_components/opnsense
  __init__.py 376, 387-388
  config_flow.py 273-274, 291-292
  const.py
  coordinator.py
  switch.py 136, 189, 194, 376, 429, 475, 516, 521, 562, 567, 608, 613, 678, 701-706, 887, 894-897, 900-902, 905-908, 922, 930, 935, 943, 948-950, 1022, 1034-1035, 1039-1041, 1044-1047, 1061, 1069, 1074, 1082, 1087-1089, 1147, 1151, 1179, 1189, 1201, 1270, 1312, 1318, 1328, 1334, 1412
  custom_components/opnsense/pyopnsense
  __init__.py 703-709, 876, 878, 896, 1078, 1080, 1093, 1099, 1125-1128, 1130, 1132, 1145, 1151, 1366-1367
Project Total  

This report was generated by python-coverage-comment-action

@Snuffy2 Snuffy2 merged commit 684a85e into travisghansen:main Feb 7, 2026
5 checks passed
@Snuffy2 Snuffy2 deleted the Implement-new-firewall-api branch February 7, 2026 00:47
@Snuffy2 Snuffy2 added enhancement Enhancing existing functionality bugfix Fix something that isn't working breaking-change feature Adding a new feature and removed enhancement Enhancing existing functionality labels Feb 7, 2026
@jata1
Copy link

jata1 commented Feb 7, 2026

Thanks @Snuffy2 - this sounds great. Will there be a new HA integration release with this soon?

Let me know if you need any assistance testing etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change bugfix Fix something that isn't working feature Adding a new feature

Projects

None yet

2 participants