Adguard integration - multiple instances on HA Core?

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

2 Likes
  • 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.
2 Likes

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

Hi, any hints/links on how to get this?

https://github.com/AdguardTeam/AdGuardHome/tree/master/openapi

The authorization token is the base64data of the username password combo. I put them in an online encoder and used whatever spit out as the header token.

The link above point to another? zwift?

I have problems…

I have 2 adguards,
01 on 192.168.1.90
02 on 192.168.1.91

What is the correct API port? is this open by default?

I get errors in the log. Can I check the API in any way?

Using:

switch:
  - platform: command_line
    switches:
      adguard_01:
        command_on: >-
          curl -H 'Authorization: Basic <<base64datahash>>'  -d '{"protection_enabled": true}' http://192.168.1.90:8280/control/dns_config    
        command_off: >-
          curl -H 'Authorization: Basic <<base64datahash>>'  -d '{"protection_enabled": false}' http://192.168.1.90:8280/control/dns_config
        friendly_name: "Adguard 01"
        command_state:  >-
          curl -H 'Authorization: Basic <<base64datahash>>'   http://192.168.1.90:8280/control/dns_info
        value_template: "{{ value_json is defined and value_json.protection_enabled }}"
      adguard_02:
        command_on: >-
          curl -H 'Authorization: Basic <<base64datahash>>'  -d '{"protection_enabled": true}' http://192.168.1.91:3000/control/dns_config    
        command_off: >-
          curl -H 'Authorization: Basic <<base64datahash>>'  -d '{"protection_enabled": false}' http://192.168.1.91:3000/control/dns_config
        friendly_name: "Adguard 02"
        command_state:  >-
          curl -H 'Authorization: Basic <<base64datahash>>'   http://192.168.1.91: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_01', 'on') or is_state('switch.adguard_02', 'on')}}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.adguard_pi, switch.adguard_01
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.adguard_pi, switch.adguard_01

Hi, is there any chance or any source where I could get some help with this? Thank you!

Can we just get the option to add two instances please?

5 Likes

any update?

1 Like

There seems to be some movement on the multiple instances:

1 Like

Just ran into this issue today switching from pi-hole… Any updates by any chance?

1 Like