Temporary fix for opnsense >21

Tags: #<Tag:0x00007f3260d999e8>

Since version 21, opnsense takes a long time to react to API requests:


Because of this, Home Assistant (more specifically the underlying library pyopnsense) fails to receive a response in time and the integration setup fails.
As a temporary fix:

SSH into your opnsense installation, open a shell and enter

opnsense-patch dd2231e

Source: https://github.com/opnsense/core/issues/4666#issuecomment-782834649

Alternatively, but really not recommended:

shitty solution
  • Go to https://downgit.github.io/#/home

  • Enter the URL https://github.com/home-assistant/core/tree/dev/homeassistant/components/opnsense

  • Click “Download”

  • Unpack the “opnsense” folder in the .zip file into config/custom_components

  • Repeat this process with this URL https://github.com/home-assistant/core/tree/dev/homeassistant/components/device_tracker

  • Open config/custom_components/opnsense/manifest.json in a text editor

  • Look for this line: "requirements": ["pyopnsense==0.2.0"],

  • Change it to "requirements": ["git+https://github.com/xorbital/pyopnsense.git"],

  • Open config/custom_components/device_tracker/const.py in a text editor

  • Look for this line: SCAN_INTERVAL = timedelta(seconds=12)

  • Change it to SCAN_INTERVAL = timedelta(seconds=120)

  • Restart Home Assistant.

This will force Home Assistant to pull my fork of the pyopnsense library with the timeout increased to 30 seconds. You can also fork the library yourself and change the line in pyopnsense/client.py.
Be aware that this changes the scan interval of all device trackers to two minutes, so you might want to adjust that. OPNsense currently takes about 15-20s to respond to an API call.

2 Likes