Adguard integration - multiple instances on HA Core?

Tags: #<Tag:0x00007f739647ba60>

Hi

Is there no way to add two Adguard home instances to HA core? It is not possible via the GUI integration method and I cannot see anything about manual configuration in the documentation.

I ran two Piholes for many years but decided to try out Adguard after seeing it was HA’s new choice of adblocker addon.

I really like it, but only being able to view/control one instance is a bit of a backwards step. It also means if I need to fully disable ad-filtering, I have to disable the primary instance via the Adguard filter switch and stop the secondary adguard container via HA as a workaround.

Thanks

1 Like
  • one for this
    Just moved from having two PiHole to two AdGuard Home installations. One being the add-on and the other running on docker on another RPI.
    Only one integration to control AdGuard Home from Home Assistant is allowed which is annoying.
1 Like

The api is public. You could call command line switches with curl commands to enable/disable The filtering. You must need to know how to encode the authorization header. I’m on mobile but when I get to a computer I’ll see what I can link to you.

I just completed this and works like a charm.

I realize I’m a bit late to this party…

Here is how i implement multiple instance switches of aguard. the integration is flaky for me so i just hard coded some rest switches to turn on/off the protection, and then combine them into a template switch.

link to adguard api: https://github.com/AdguardTeam/AdGuardHome/blob/1e2e965ea78317ac28b3d8c51b7990c1714f76e2/openapi/openapi.yaml

switch:
  - platform: command_line
    switches:
      adguard_gonzo:
        command_on: >-
          curl -H 'Authorization: Basic <<redacted authorization token>>'  -d '{"protection_enabled": true}' http://ipaddressofgonzo:8280/control/dns_config    
        command_off: >-
          curl -H 'Authorization: Basic <<redacted authorization token>>'  -d '{"protection_enabled": false}' http://ipaddressofgonzo:8280/control/dns_config
        friendly_name: "Adguard Gonzo"
        command_state:  >-
          curl -H 'Authorization: Basic <<redacted authorization token>>'   http://ipaddressofgonzo:8280/control/dns_info
        value_template: "{{ value_json is defined and value_json.protection_enabled }}"
      adguard_pi:
        command_on: >-
          curl -H 'Authorization: Basic <<redacted authorization token>>'  -d '{"protection_enabled": true}' http://ipaddressofpi:3000/control/dns_config    
        command_off: >-
          curl -H 'Authorization: Basic <<redacted authorization token>>'  -d '{"protection_enabled": false}' http://ipaddressofpi:3000/control/dns_config
        friendly_name: "Adguard Pi"
        command_state:  >-
          curl -H 'Authorization: Basic <<redacted authorization token>>'   http://10.9.209.182:3000/control/dns_info
        value_template: "{{ value_json is defined and value_json.protection_enabled }}"
  - platform: template
    switches:
      adguard:
        friendly_name: "adguard"
        value_template: "{{ is_state('switch.adguard_pi', 'on') or is_state('switch.adguard_gonzo', 'on')}}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.adguard_pi, switch.adguard_gonzo
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.adguard_pi, switch.adguard_gonzo