HTTP Binding: Access to OPNsense API

  • Create new user on OPNsense, give the necessary access permissions
  • Create and download API key (key is username, secret is password)
  • Create new thing with channels to the API calls you want to trigger (example is write-only, WoL with predefined host)
UID: http:url:opnsense-api
label: OPNSense HTTP API
thingTypeUID: http:url
configuration:
  authMode: BASIC_PREEMPTIVE
  ignoreSSLErrors: false
  baseURL: https://opnsense/api/
  password: blub
  delay: 0
  stateMethod: GET
  refresh: 30
  commandMethod: POST
  contentType: application/json
  timeout: 3000
  bufferSize: 2048
  username: bla
channels:
  - id: last-failure
    channelTypeUID: http:request-date-time
    label: Last Failure
    configuration: {}
  - id: last-success
    channelTypeUID: http:request-date-time
    label: Last Success
    configuration: {}
  - id: wol
    channelTypeUID: http:string
    label: Wol
    description: Wake-On-LAN
    configuration:
      mode: WRITEONLY
      commandTransformation:
        - 'JINJA:{"uuid": "{{value}}"}'
      stateExtension: wol/wol/get
      commandExtension: wol/wol/set
  • Create item to be used in rules
1 Like

This pairs nicely with Simple AdGuard Home Integration using the HTTP Binding since AdGuard is the most popular ad blocking plug-in for OPNSense.

Thanks for posting this. I might look into it to get the Nut status for the UPS my OPNsense machine is plugged into and maybe to get an alert if ACME fails to renew my certificate.

2 Likes