I just wanted to share how I set up toggles for switching different internet services on and off directly from my mobile dashboard.
You’ll need:
- An Adguard Home instance (e.g. the Adguard Home add-on for HA)Note
- A custom rest_command to toggle the service
- An input_boolean helper for each of the apps you want to block/unblock
- An automation that uses the rest_command to set the state of the services/apps, based on the state of the input_boolean’s.
- Add input_booleans to the front-end.
Note: If using the HA add-on, you need to manually activate port 3000 in the Adguard Add-on config.
REST command:
I’ll start at step 2, since installing the add-on is already well-documented.
To add the rest_command, go to configuration.yaml and add this:
rest_command:
adguard_services:
url: "http://<adguard-ip>:3000/control/blocked_services/set"
method: POST
headers:
Content-Type: 'application/json'
Authorization: 'Basic dXNlcm5hbWU6cGFzc3dvcmQ='
payload: '{{apps}}'
Change the IP address and add your Base64 encoded username:password (Example. Encode your own on https://www.base64encode.org).
Input booleans:
Next, create an input_boolean for each app you want to block/unblock.
The (friendly) name must be called the name of the service. I’ll add a list below with the (currently) available services in adguard.
Modify the entity_id to include “adguard_block_”. This will be used to filter the states in the automation later.
Automation:
Add this automation. Ensure that all your adguard input_booleans are added as triggers.
alias: Adguard toggle services
description: ""
trigger:
- platform: state
entity_id:
- input_boolean.adguard_block_roblox
- input_boolean.adguard_block_youtube
condition: []
action:
- service: rest_command.adguard_services
data:
apps: >
{{states.input_boolean |selectattr('entity_id', 'search',
'adguard_block')
|selectattr('state', 'search', 'on')
|map(attribute='name') |list | tojson }}
mode: single
Front-end:
Add the input_booleans to your frontend. I’m using Mushroom cards:
square: false
type: grid
cards:
- type: custom:mushroom-template-card
entity: input_boolean.adguard_block_youtube
layout: default
name: Youtube
secondary: YouTube
icon: mdi:youtube
tap_action:
action: toggle
icon_color: |
{%if states(config.entity) == "on"%}
grey
{%else%}
red
{%endif%}
badge_icon: |
{%if states(config.entity) == "on"%}
mdi:stop
{%else%}
mdi:web
{%endif%}
badge_color: |
{%if states(config.entity) == "on"%}
deep-orange
{%else%}
green
{%endif%}
card_mod:
style: |
ha-card {
border-radius: 15px;
margin-right: 2px;
margin-left: 15px;
# background-image: linear-gradient(to bottom , var(--primary-background-color), var(--primary-color) );
--card-primary-font-size: 16px;
--card-primary-font-weight: bold;
--card-secondary-font-size: 12px;
font-family: "Montserrat" !important;
}
:host {
--mush-icon-size: 45px;
}
- type: custom:mushroom-template-card
entity: input_boolean.adguard_block_roblox
layout: default
name: Roblox
secondary: Roblox
icon: mdi:gamepad-square
tap_action:
action: toggle
icon_color: |
{%if states(config.entity) == "on"%}
grey
{%else%}
green
{%endif%}
badge_icon: |
{%if states(config.entity) == "on"%}
mdi:stop
{%else%}
mdi:web
{%endif%}
badge_color: |
{%if states(config.entity) == "on"%}
deep-orange
{%else%}
green
{%endif%}
card_mod:
style: |
ha-card {
border-radius: 15px;
margin-right: 15px;
margin-left: 2px;
# background-image: linear-gradient(to bottom , var(--primary-background-color), var(--primary-color) );
--card-primary-font-size: 16px;
--card-primary-font-weight: bold;
--card-secondary-font-size: 12px;
font-family: "Montserrat" !important;
}
:host {
--mush-icon-size: 45px;
}
columns: 2
Information:
Every time one of the input_booleans are toggled, the automation will check the state of all the input_booleans, and send an array of all apps that should be blocked to adguard (“On” means blocked). There is currently no feedback from adguard about which services are blocked, so if you go to adguards own interface and modify, this is not reflected on your dashboard. But if you always manage it from HA, there will be no issues
List of supported services/apps (19th April 2024):
"4chan",
"500px",
"9gag",
"activision_blizzard",
"aliexpress",
"amazon",
"amazon_streaming",
"amino",
"apple_streaming",
"battle_net",
"betano",
"betfair",
"betway",
"bigo_live",
"bilibili",
"blaze",
"blizzard_entertainment",
"bluesky",
"box",
"canais_globo",
"claro",
"cloudflare",
"clubhouse",
"coolapk",
"crunchyroll",
"dailymotion",
"deezer",
"directvgo",
"discord",
"discoveryplus",
"disneyplus",
"douban",
"dropbox",
"ebay",
"electronic_arts",
"epic_games",
"espn",
"facebook",
"fifa",
"flickr",
"globoplay",
"gog",
"hbomax",
"hulu",
"icloud_private_relay",
"iheartradio",
"imgur",
"instagram",
"iqiyi",
"kakaotalk",
"kik",
"kook",
"lazada",
"leagueoflegends",
"line",
"linkedin",
"lionsgateplus",
"looke",
"mail_ru",
"mastodon",
"mercado_libre",
"minecraft",
"nebula",
"netflix",
"nintendo",
"nvidia",
"ok",
"olvid",
"onlyfans",
"origin",
"paramountplus",
"pinterest",
"playstation",
"plenty_of_fish",
"plex",
"pluto_tv",
"privacy",
"qq",
"rakuten_viki",
"reddit",
"riot_games",
"roblox",
"rockstar_games",
"samsung_tv_plus",
"shein",
"shopee",
"signal",
"skype",
"snapchat",
"soundcloud",
"spotify",
"steam",
"telegram",
"temu",
"tidal",
"tiktok",
"tinder",
"tumblr",
"twitch",
"twitter",
"ubisoft",
"valorant",
"viber",
"vimeo",
"vk",
"voot",
"wargaming",
"wechat",
"weibo",
"whatsapp",
"wizz",
"xboxlive",
"xiaohongshu",
"youtube",
"yy",
"zhihu"