This component is written to toggle opnSense firewall rules on (enabled) or off (disabled).
One my question why in the world would someone want to do this from HA. Simply put, I only use it to change the vpn use by my chromecast.
FORK from https://github.com/dgshue/home-assistant-custom-components and nagyrobi/home-assistant-custom-components-pfsense-ruleswitch Thanks for their work on that.
- opnsense 21.0+
- install os-firewall in opnsense to allow api commands
- pyopnsense api 0.0.3 installed https://github.com/mtreinish/pyopnsense
- API Key and Secret with appropriate permissions
With the new plugin on version 20.1.5 for the firewall API, it adds a new menu item under the "Firewall" section called "Automation" under that is the "Filter" and "Source NAT" menu items. You create your firewall rule under "Filter", then you need to get the UUID of this rule (I just looked at the config.xml Although there is a search parameter you can use with the API). Now, these firewall rules are above all other rules, even floating. (so the order of execution for the firewall rules goes: Automation->Floating->Interface)
The rules shown here are the one under the automation tab, not the normal rules.
This component will set up the following platforms.
Platform | Description |
---|---|
switch |
Switch firewall rules on or off. |
- Using the tool of choice open the directory (folder) for your HA configuration (where you find
configuration.yaml
). - If you do not have a
custom_components
directory (folder) there, you need to create it. - In the
custom_components
directory (folder) create a new folder calledopnsense_ruleswitch
. - Download all the files from the
custom_components/opnsense_ruleswitch/
directory (folder) in this repository. - Place the files you downloaded in the new directory (folder) you created.
- Restart Home Assistant
- In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "opnsense ruleswitch"
The configuration shall be moved to use flow, in the mean time you need to add that to your configuration.yaml
switch:
- platform: opnsense_rule
host: https://192.168.1.1/api
api_key: PFFA1sdfsdfkjied21
access_token: AectmsfdfsdfdsfsfdsfdsdffdsbZEu6gzboxd5adUbbrejFZae1u5
rule_filter: HomeAssistant
If you want to contribute to this please read the Contribution guidelines
This project was generated from @oncleben31's Home Assistant Custom Component Cookiecutter template.
Code template was mainly taken from @Ludeeus's integration_blueprint template