Skip to content

Commit

Permalink
OPNsense-ify the project
Browse files Browse the repository at this point in the history
Signed-off-by: Travis Glenn Hansen <travisghansen@yahoo.com>
  • Loading branch information
travisghansen committed Nov 13, 2021
1 parent b05babb commit c219ad6
Show file tree
Hide file tree
Showing 16 changed files with 1,194 additions and 406 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Release

on:
push:
tags:
- "v*.*.*"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Release
uses: softprops/action-gh-release@v1
111 changes: 73 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,52 @@
# hass-pfsense
[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Ftravisghansen%2Fhass-opnsense%2Fbadge%3Fref%3Dmain&style=for-the-badge)](https://actions-badge.atrox.dev/travisghansen/hass-opnsense/goto?ref=main)
[![hacs_badge](https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge)](https://github.com/custom-components/hacs)

Join `pfSense` with `home-assistant`!

`hass-pfsense` uses the built-in `xmlrpc` service of `pfSense` for all
interactions. No special plugins or software needs to be installed to use the
integration.
# hass-opnsense

Initial development was done againt `pfSense` `2.5.2` and `home-assistant`
Join `OPNsense` with `home-assistant`!

`hass-opnsense` uses the built-in `xmlrpc` service of `OPNsense` for all
interactions. This project is currently a proof-of-concept and may fail to work
at any time.

To use the integration you must first login to the console of
your filewall and execute the following:

```
sh
cat << 'EOF' > /usr/local/etc/inc/xmlrpc/hass.inc
<?php
function xmlrpc_publishable_hass()
{
return array(
"exec_php_xmlrpc",
"exec_shell_xmlrpc"
);
}
function exec_php_xmlrpc($code)
{
eval($code);
if ($toreturn)
{
return $toreturn;
}
return true;
}
function exec_shell_xmlrpc($code)
{
mwexec($code);
return true;
}
EOF
chown root:wheel /usr/local/etc/inc/xmlrpc/hass.inc
chmod 644 /usr/local/etc/inc/xmlrpc/hass.inc
```

Initial development was done againt `OPNsense` `21.7` and `home-assistant`
`2021.10`.

# installation
Expand All @@ -19,9 +59,9 @@ the browser.

Configuration is managed entirely from the UI using `config_flow` semantics.
Simply go to `Configuration -> Integrations -> Add Integration` and search for
`pfSense` in the search box.
`OPNsense` in the search box.

## pfSense
## OPNsense

- `System -> Advanced -> Max Processes` - set it 5 or more.
- If using a non `admin` user account ensure the user has the
Expand All @@ -30,27 +70,27 @@ Simply go to `Configuration -> Integrations -> Add Integration` and search for

## config

- `URL` - put the full URL to your `pfSense` UI (ie: `https://192.168.1.1`),
- `URL` - put the full URL to your `OPNsense` UI (ie: `https://192.168.1.1`),
supported format is `<scheme>://<ip or host>[:<port>]`
- `Verify SSL Certificate` - if the SSL certificate should be verified or not
(if you get an SSL error try unchecking this)
- `username` - the username to use for authentication (ie: `admin`)
- `username` - the username to use for authentication (ie: `root`)
- `password` - the password to use for authentication
- `Firewall Name` - a custom name to be used for `entity` naming (default: use
the `pfSense` `hostname`)
the `OPNsense` `hostname`)

## options

- `Scan Interval (seconds)` - scan interval to use for state polling (default:
`30`)
- `Enable Device Tracker` - turn on the device tracker integration using
`pfSense` arp table (default: `false`)
`OPNsense` arp table (default: `false`)
- `Device Tracker Scan Interval (seconds)` - scan interval to use for arp
updates (default: `60`)

# entities

Many `entities` are created by `hass-pfsense` for stats etc. Due to to volume
Many `entities` are created by `hass-opnsense` for stats etc. Due to to volume
of entities many are disabled by default. If something is missing be sure to
review the disabled entities as what you're looking for is probably there.

Expand All @@ -61,18 +101,18 @@ review the disabled entities as what you're looking for is probably there.

## device_tracker

`ScannerEntity` entries are created for the `pfSense` arp table. Disabled by
`ScannerEntity` entries are created for the `OPNsense` arp table. Disabled by
default. Not only is the feature disabled by default but created entities are
currently disabled by default as well. Search the disabled entity list for the
relevant mac addresses and enable as desired.

Note that by default `FreeBSD`/`pfSense` use a max age of 20 minutes for arp
Note that by default `FreeBSD`/`OPNsense` use a max age of 20 minutes for arp
entries (sysctl `net.link.ether.inet.max_age`). You may lower that using
`System -> Advanced -> System Tunables` if desired.

## sensor

- system details (name, version, temp, boottime, etc)
- system details (name, version, ~~temp~~, boottime, etc)
- pfstate details (used, max, etc)
- cpu details (average load, frequency, etc)
- mbuf details
Expand All @@ -82,7 +122,7 @@ entries (sysctl `net.link.ether.inet.max_age`). You may lower that using
`Scan Interval (seconds)` config option))
- gateways details (status, delay, stddev, loss)
- carp interface status
- dhcp stats (total, online, and offline clients)
- ~~dhcp stats (total, online, and offline clients)~~

## switch

Expand All @@ -96,49 +136,44 @@ All of the switches below are disabled by default.
# services

```
service: pfsense.close_notice
service: opnsense.close_notice
data:
entity_id: binary_sensor.pfsense_localdomain_pending_notices_present
entity_id: binary_sensor.opnsense_localdomain_pending_notices_present
# default is to clear all notices
# id: <some id>
service: pfsense.file_notice
service: opnsense.file_notice
data:
entity_id: binary_sensor.pfsense_localdomain_pending_notices_present
id: "hass"
entity_id: binary_sensor.opnsense_localdomain_pending_notices_present
notice: "hello world"
# category: "HASS"
# url: ""
# priority: 1
# local_only: false
service: pfsense.system_halt
service: opnsense.system_halt
data:
entity_id: binary_sensor.pfsense_localdomain_pending_notices_present
entity_id: binary_sensor.opnsense_localdomain_pending_notices_present
service: pfsense.system_reboot
service: opnsense.system_reboot
data:
entity_id: binary_sensor.pfsense_localdomain_pending_notices_present
entity_id: binary_sensor.opnsense_localdomain_pending_notices_present
service: pfsense.start_service
service: opnsense.start_service
data:
entity_id: binary_sensor.pfsense_localdomain_pending_notices_present
entity_id: binary_sensor.opnsense_localdomain_pending_notices_present
service_name: "dpinger"
service: pfsense.stop_service
service: opnsense.stop_service
data:
entity_id: binary_sensor.pfsense_localdomain_pending_notices_present
entity_id: binary_sensor.opnsense_localdomain_pending_notices_present
service_name: "dpinger"
service: pfsense.restart_service
service: opnsense.restart_service
data:
entity_id: binary_sensor.pfsense_localdomain_pending_notices_present
entity_id: binary_sensor.opnsense_localdomain_pending_notices_present
service_name: "dpinger"
# only_if_running: false
service: pfsense.send_wol
service: opnsense.send_wol
data:
entity_id: binary_sensor.pfsense_localdomain_pending_notices_present
entity_id: binary_sensor.opnsense_localdomain_pending_notices_present
interface: lan
mac: "B9:7B:A6:46:B3:8B"
```
Loading

0 comments on commit c219ad6

Please sign in to comment.