Fix: OPNsense rest_commands use JSON payload (alias_util API requires JSON not form-encoded)
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
# =============================================================
|
# =============================================================
|
||||||
|
|
||||||
# Config stored across 12 chunks (12 × 255 = 3060 chars max)
|
# Config stored across 12 chunks (12 × 255 = 3060 chars max)
|
||||||
# Enough for 5 users with several devices each
|
|
||||||
input_text:
|
input_text:
|
||||||
parental_config_0: {name: "Parental Config 0", max: 255, icon: mdi:shield-account}
|
parental_config_0: {name: "Parental Config 0", max: 255, icon: mdi:shield-account}
|
||||||
parental_config_1: {name: "Parental Config 1", max: 255, icon: mdi:shield-account}
|
parental_config_1: {name: "Parental Config 1", max: 255, icon: mdi:shield-account}
|
||||||
@@ -19,25 +18,7 @@ input_text:
|
|||||||
parental_config_11: {name: "Parental Config 11", max: 255, icon: mdi:shield-account}
|
parental_config_11: {name: "Parental Config 11", max: 255, icon: mdi:shield-account}
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
# OPNsense DHCP lease sensor — device discovery + MAC→IP
|
# OPNsense firewall API — JSON payload required by alias_util API
|
||||||
# Requires opnsense_leases_url and opnsense_basic_auth in secrets.yaml
|
|
||||||
# ------------------------------------------------------------------
|
|
||||||
rest:
|
|
||||||
- resource: !secret opnsense_leases_url
|
|
||||||
scan_interval: 60
|
|
||||||
headers:
|
|
||||||
Authorization: !secret opnsense_basic_auth
|
|
||||||
verify_ssl: false
|
|
||||||
sensor:
|
|
||||||
- name: "OPNsense DHCP Leases"
|
|
||||||
unique_id: parental_controls_dhcp_leases
|
|
||||||
value_template: "{{ value_json.total | default(value_json.rowCount) | default(0) }}"
|
|
||||||
icon: mdi:lan
|
|
||||||
json_attributes:
|
|
||||||
- rows
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
|
||||||
# OPNsense firewall API calls
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
rest_command:
|
rest_command:
|
||||||
|
|
||||||
@@ -46,8 +27,8 @@ rest_command:
|
|||||||
method: post
|
method: post
|
||||||
headers:
|
headers:
|
||||||
Authorization: !secret opnsense_basic_auth
|
Authorization: !secret opnsense_basic_auth
|
||||||
payload: "address={{ address }}"
|
Content-Type: application/json
|
||||||
content_type: "application/x-www-form-urlencoded"
|
payload: '{"address": "{{ address }}"}'
|
||||||
verify_ssl: false
|
verify_ssl: false
|
||||||
|
|
||||||
parental_unblock_ip:
|
parental_unblock_ip:
|
||||||
@@ -55,8 +36,8 @@ rest_command:
|
|||||||
method: post
|
method: post
|
||||||
headers:
|
headers:
|
||||||
Authorization: !secret opnsense_basic_auth
|
Authorization: !secret opnsense_basic_auth
|
||||||
payload: "address={{ address }}"
|
Content-Type: application/json
|
||||||
content_type: "application/x-www-form-urlencoded"
|
payload: '{"address": "{{ address }}"}'
|
||||||
verify_ssl: false
|
verify_ssl: false
|
||||||
|
|
||||||
parental_apply_firewall:
|
parental_apply_firewall:
|
||||||
@@ -64,8 +45,8 @@ rest_command:
|
|||||||
method: post
|
method: post
|
||||||
headers:
|
headers:
|
||||||
Authorization: !secret opnsense_basic_auth
|
Authorization: !secret opnsense_basic_auth
|
||||||
payload: "{}"
|
Content-Type: application/json
|
||||||
content_type: "application/json"
|
payload: '{}'
|
||||||
verify_ssl: false
|
verify_ssl: false
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user