Controlling OPNsense Firewall Rules from HomeAssistant #24
Replies: 7 comments 10 replies
-
Hello, |
Beta Was this translation helpful? Give feedback.
-
HI @FuzzyMistborn Everything is fine on the firewall side and I can make the adjustments, but there is a problem with your script. Here is my error message. Since I use SSL I have added another line, but even without and only with your information in the configuration.yaml the following happens at the restart/reload Home AssistCannot quick reload all YAML configurations because the configuration is not valid: Invalid config for [rest_command]: expected a dictionary for dictionary value @ data['rest_command']['method']. Got 'post' expected a dictionary for dictionary value @ data['rest_command']['password']. Got 'LgxXQxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxlcGRIK' expected a dictionary for dictionary value @ data['rest_command']['ssh_rule_apply']. Got None expected a dictionary for dictionary value @ data['rest_command']['ssh_rule_toggle']. Got None expected a dictionary for dictionary value @ data['rest_command']['url']. Got 'http://OPNSENSE_URL/api/firewall/filter/apply' expected a dictionary for dictionary value @ data['rest_command']['username']. Got 'XxxxxxxxxxxxxxxxxxxxxxxxxxiCrq' expected a dictionary for dictionary value @ data['rest_command']['verify_ssl']. Got False. (See /config/configuration.yaml, line 18).resr_command starts at line 18.... regards |
Beta Was this translation helpful? Give feedback.
-
interesting.. now it´s worked for me rest_command: ssh_rule_apply: binary_sensor:
script: switch:
|
Beta Was this translation helpful? Give feedback.
-
You don't need any of this if you use this HA integration: https://github.com/travisghansen/hass-opnsense You can automate many things, Filter Rules included, they will be available as binary switches in HA. :) |
Beta Was this translation helpful? Give feedback.
-
Hello alexdelprete, you are right that HA has this plugin. I also use it, but more to display the status of my OPNsense. Unfortunately, I can't use the plugin the way I need it. The aim is to switch an automated filter off or on, which is not possible. Here there are firewall rules that are as clear as I do not want to switch. Thanks for your suggestion. |
Beta Was this translation helpful? Give feedback.
-
I don't understand why you use Automation Filter rules when you have HA and a full integration (hass-opnsense). :) If I remember correctly, the Automation Filter rules were part of Now that you have a FULL integration that integrates all needed APIs (and more, via XMLRPC if API is not available), you can simply use standard Filter Rules and automate them through HA, since they will be exposed as HA entities. You can enable/disable anything through HA, without having to define rules in the automation section of OPNsense, simply define the rules in the standard rules section of OPNsense, and they will be available in HA as entities. Alessandro |
Beta Was this translation helpful? Give feedback.
-
;) thanks for your tip. |
Beta Was this translation helpful? Give feedback.
-
Controlling OPNsense Firewall Rules from HomeAssistant
I’ve been running OPNsense for a few months now and absolutely love it. It can do basically everything I want/need and does it with a relatively easy to understand interface (with some exceptions). It also has a good API. I talked more about OPNsense in a previous post so I’m not going to revisit a discussion again of OPNsense itself. But in this post, we’re going to talk about being able to remote turn on and off firewall rules…from HomeAssistant!
https://blog.fuzzymistborn.com/opnsense-firewall/
Beta Was this translation helpful? Give feedback.
All reactions