diff --git a/homeassistant/components/nextdns/strings.json b/homeassistant/components/nextdns/strings.json index 517e229d0e4..2f15c4cd8e5 100644 --- a/homeassistant/components/nextdns/strings.json +++ b/homeassistant/components/nextdns/strings.json @@ -133,12 +133,18 @@ "block_amazon": { "name": "Block Amazon" }, + "block_bereal": { + "name": "Block BeReal" + }, "block_blizzard": { "name": "Block Blizzard" }, "block_bypass_methods": { "name": "Block bypass methods" }, + "block_chatgpt": { + "name": "Block ChatGPT" + }, "block_csam": { "name": "Block child sexual abuse material" }, @@ -172,6 +178,12 @@ "block_gambling": { "name": "Block gambling" }, + "block_google_chat": { + "name": "Block Google Chat" + }, + "block_hbomax": { + "name": "Block HBO Max" + }, "block_hulu": { "name": "Block Hulu" }, @@ -184,6 +196,9 @@ "block_leagueoflegends": { "name": "Block League of Legends" }, + "block_mastodon": { + "name": "Block Mastodon" + }, "block_messenger": { "name": "Block Messenger" }, @@ -196,6 +211,9 @@ "block_nrd": { "name": "Block newly registered domains" }, + "block_online_gaming": { + "name": "Block online gaming" + }, "block_page": { "name": "Block page" }, @@ -208,6 +226,9 @@ "block_piracy": { "name": "Block piracy" }, + "block_playstation_network": { + "name": "Block PlayStation Network" + }, "block_porn": { "name": "Block porn" }, @@ -256,6 +277,9 @@ "block_twitter": { "name": "Block Twitter" }, + "block_video_streaming": { + "name": "Block video streaming" + }, "block_vimeo": { "name": "Block Vimeo" }, diff --git a/homeassistant/components/nextdns/switch.py b/homeassistant/components/nextdns/switch.py index cd584b27713..0a310bc29e7 100644 --- a/homeassistant/components/nextdns/switch.py +++ b/homeassistant/components/nextdns/switch.py @@ -204,6 +204,14 @@ SWITCHES = ( icon="mdi:cart-outline", state=lambda data: data.block_amazon, ), + NextDnsSwitchEntityDescription[Settings]( + key="block_bereal", + translation_key="block_bereal", + entity_category=EntityCategory.CONFIG, + entity_registry_enabled_default=False, + icon="mdi:alpha-b-box", + state=lambda data: data.block_bereal, + ), NextDnsSwitchEntityDescription[Settings]( key="block_blizzard", translation_key="block_blizzard", @@ -212,6 +220,14 @@ SWITCHES = ( icon="mdi:sword-cross", state=lambda data: data.block_blizzard, ), + NextDnsSwitchEntityDescription[Settings]( + key="block_chatgpt", + translation_key="block_chatgpt", + entity_category=EntityCategory.CONFIG, + entity_registry_enabled_default=False, + icon="mdi:chat-processing-outline", + state=lambda data: data.block_chatgpt, + ), NextDnsSwitchEntityDescription[Settings]( key="block_dailymotion", translation_key="block_dailymotion", @@ -260,6 +276,22 @@ SWITCHES = ( icon="mdi:tank", state=lambda data: data.block_fortnite, ), + NextDnsSwitchEntityDescription[Settings]( + key="block_google_chat", + translation_key="block_google_chat", + entity_category=EntityCategory.CONFIG, + entity_registry_enabled_default=False, + icon="mdi:forum", + state=lambda data: data.block_google_chat, + ), + NextDnsSwitchEntityDescription[Settings]( + key="block_hbomax", + translation_key="block_hbomax", + entity_category=EntityCategory.CONFIG, + entity_registry_enabled_default=False, + icon="mdi:movie-search-outline", + state=lambda data: data.block_hbomax, + ), NextDnsSwitchEntityDescription[Settings]( key="block_hulu", name="Block Hulu", @@ -292,6 +324,14 @@ SWITCHES = ( icon="mdi:sword", state=lambda data: data.block_leagueoflegends, ), + NextDnsSwitchEntityDescription[Settings]( + key="block_mastodon", + translation_key="block_mastodon", + entity_category=EntityCategory.CONFIG, + entity_registry_enabled_default=False, + icon="mdi:mastodon", + state=lambda data: data.block_mastodon, + ), NextDnsSwitchEntityDescription[Settings]( key="block_messenger", translation_key="block_messenger", @@ -324,6 +364,14 @@ SWITCHES = ( icon="mdi:pinterest", state=lambda data: data.block_pinterest, ), + NextDnsSwitchEntityDescription[Settings]( + key="block_playstation_network", + translation_key="block_playstation_network", + entity_category=EntityCategory.CONFIG, + entity_registry_enabled_default=False, + icon="mdi:sony-playstation", + state=lambda data: data.block_playstation_network, + ), NextDnsSwitchEntityDescription[Settings]( key="block_primevideo", translation_key="block_primevideo", @@ -500,6 +548,14 @@ SWITCHES = ( icon="mdi:slot-machine", state=lambda data: data.block_gambling, ), + NextDnsSwitchEntityDescription[Settings]( + key="block_online_gaming", + translation_key="block_online_gaming", + entity_category=EntityCategory.CONFIG, + entity_registry_enabled_default=False, + icon="mdi:gamepad-variant", + state=lambda data: data.block_online_gaming, + ), NextDnsSwitchEntityDescription[Settings]( key="block_piracy", translation_key="block_piracy", @@ -524,6 +580,14 @@ SWITCHES = ( icon="mdi:facebook", state=lambda data: data.block_social_networks, ), + NextDnsSwitchEntityDescription[Settings]( + key="block_video_streaming", + translation_key="block_video_streaming", + entity_category=EntityCategory.CONFIG, + entity_registry_enabled_default=False, + icon="mdi:video-wireless-outline", + state=lambda data: data.block_video_streaming, + ), ) diff --git a/tests/components/nextdns/test_switch.py b/tests/components/nextdns/test_switch.py index 7739218d92c..ed0ea4e8620 100644 --- a/tests/components/nextdns/test_switch.py +++ b/tests/components/nextdns/test_switch.py @@ -8,7 +8,6 @@ from aiohttp.client_exceptions import ClientConnectorError from nextdns import ApiError import pytest -from homeassistant.components.nextdns.const import DOMAIN from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN from homeassistant.const import ( ATTR_ENTITY_ID, @@ -28,346 +27,12 @@ from . import SETTINGS, init_integration from tests.common import async_fire_time_changed -async def test_switch(hass: HomeAssistant) -> None: +async def test_switch( + hass: HomeAssistant, entity_registry_enabled_by_default: None +) -> None: """Test states of the switches.""" registry = er.async_get(hass) - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_9gag", - suggested_object_id="fake_profile_block_9gag", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_amazon", - suggested_object_id="fake_profile_block_amazon", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_blizzard", - suggested_object_id="fake_profile_block_blizzard", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_dailymotion", - suggested_object_id="fake_profile_block_dailymotion", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_discord", - suggested_object_id="fake_profile_block_discord", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_disneyplus", - suggested_object_id="fake_profile_block_disneyplus", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_ebay", - suggested_object_id="fake_profile_block_ebay", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_facebook", - suggested_object_id="fake_profile_block_facebook", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_fortnite", - suggested_object_id="fake_profile_block_fortnite", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_hulu", - suggested_object_id="fake_profile_block_hulu", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_imgur", - suggested_object_id="fake_profile_block_imgur", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_instagram", - suggested_object_id="fake_profile_block_instagram", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_leagueoflegends", - suggested_object_id="fake_profile_block_league_of_legends", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_messenger", - suggested_object_id="fake_profile_block_messenger", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_minecraft", - suggested_object_id="fake_profile_block_minecraft", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_netflix", - suggested_object_id="fake_profile_block_netflix", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_pinterest", - suggested_object_id="fake_profile_block_pinterest", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_primevideo", - suggested_object_id="fake_profile_block_primevideo", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_reddit", - suggested_object_id="fake_profile_block_reddit", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_roblox", - suggested_object_id="fake_profile_block_roblox", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_signal", - suggested_object_id="fake_profile_block_signal", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_skype", - suggested_object_id="fake_profile_block_skype", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_snapchat", - suggested_object_id="fake_profile_block_snapchat", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_spotify", - suggested_object_id="fake_profile_block_spotify", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_steam", - suggested_object_id="fake_profile_block_steam", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_telegram", - suggested_object_id="fake_profile_block_telegram", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_tiktok", - suggested_object_id="fake_profile_block_tiktok", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_tinder", - suggested_object_id="fake_profile_block_tinder", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_tumblr", - suggested_object_id="fake_profile_block_tumblr", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_twitch", - suggested_object_id="fake_profile_block_twitch", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_twitter", - suggested_object_id="fake_profile_block_twitter", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_vimeo", - suggested_object_id="fake_profile_block_vimeo", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_vk", - suggested_object_id="fake_profile_block_vk", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_whatsapp", - suggested_object_id="fake_profile_block_whatsapp", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_xboxlive", - suggested_object_id="fake_profile_block_xboxlive", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_youtube", - suggested_object_id="fake_profile_block_youtube", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_zoom", - suggested_object_id="fake_profile_block_zoom", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_dating", - suggested_object_id="fake_profile_block_dating", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_gambling", - suggested_object_id="fake_profile_block_gambling", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_piracy", - suggested_object_id="fake_profile_block_piracy", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_porn", - suggested_object_id="fake_profile_block_porn", - disabled_by=None, - ) - - registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - "xyz12_block_social_networks", - suggested_object_id="fake_profile_block_social_networks", - disabled_by=None, - ) - await init_integration(hass) state = hass.states.get("switch.fake_profile_ai_driven_threat_detection") @@ -576,6 +241,14 @@ async def test_switch(hass: HomeAssistant) -> None: assert entry assert entry.unique_id == "xyz12_block_amazon" + state = hass.states.get("switch.fake_profile_block_bereal") + assert state + assert state.state == STATE_ON + + entry = registry.async_get("switch.fake_profile_block_bereal") + assert entry + assert entry.unique_id == "xyz12_block_bereal" + state = hass.states.get("switch.fake_profile_block_blizzard") assert state assert state.state == STATE_ON @@ -584,6 +257,14 @@ async def test_switch(hass: HomeAssistant) -> None: assert entry assert entry.unique_id == "xyz12_block_blizzard" + state = hass.states.get("switch.fake_profile_block_chatgpt") + assert state + assert state.state == STATE_ON + + entry = registry.async_get("switch.fake_profile_block_chatgpt") + assert entry + assert entry.unique_id == "xyz12_block_chatgpt" + state = hass.states.get("switch.fake_profile_block_dailymotion") assert state assert state.state == STATE_ON @@ -600,11 +281,11 @@ async def test_switch(hass: HomeAssistant) -> None: assert entry assert entry.unique_id == "xyz12_block_discord" - state = hass.states.get("switch.fake_profile_block_disneyplus") + state = hass.states.get("switch.fake_profile_block_disney_plus") assert state assert state.state == STATE_ON - entry = registry.async_get("switch.fake_profile_block_disneyplus") + entry = registry.async_get("switch.fake_profile_block_disney_plus") assert entry assert entry.unique_id == "xyz12_block_disneyplus" @@ -632,6 +313,22 @@ async def test_switch(hass: HomeAssistant) -> None: assert entry assert entry.unique_id == "xyz12_block_fortnite" + state = hass.states.get("switch.fake_profile_block_google_chat") + assert state + assert state.state == STATE_ON + + entry = registry.async_get("switch.fake_profile_block_google_chat") + assert entry + assert entry.unique_id == "xyz12_block_google_chat" + + state = hass.states.get("switch.fake_profile_block_hbo_max") + assert state + assert state.state == STATE_ON + + entry = registry.async_get("switch.fake_profile_block_hbo_max") + assert entry + assert entry.unique_id == "xyz12_block_hbomax" + state = hass.states.get("switch.fake_profile_block_hulu") assert state assert state.state == STATE_ON @@ -664,6 +361,14 @@ async def test_switch(hass: HomeAssistant) -> None: assert entry assert entry.unique_id == "xyz12_block_leagueoflegends" + state = hass.states.get("switch.fake_profile_block_mastodon") + assert state + assert state.state == STATE_ON + + entry = registry.async_get("switch.fake_profile_block_mastodon") + assert entry + assert entry.unique_id == "xyz12_block_mastodon" + state = hass.states.get("switch.fake_profile_block_messenger") assert state assert state.state == STATE_ON @@ -696,11 +401,19 @@ async def test_switch(hass: HomeAssistant) -> None: assert entry assert entry.unique_id == "xyz12_block_pinterest" - state = hass.states.get("switch.fake_profile_block_primevideo") + state = hass.states.get("switch.fake_profile_block_playstation_network") assert state assert state.state == STATE_ON - entry = registry.async_get("switch.fake_profile_block_primevideo") + entry = registry.async_get("switch.fake_profile_block_playstation_network") + assert entry + assert entry.unique_id == "xyz12_block_playstation_network" + + state = hass.states.get("switch.fake_profile_block_prime_video") + assert state + assert state.state == STATE_ON + + entry = registry.async_get("switch.fake_profile_block_prime_video") assert entry assert entry.unique_id == "xyz12_block_primevideo" @@ -832,11 +545,11 @@ async def test_switch(hass: HomeAssistant) -> None: assert entry assert entry.unique_id == "xyz12_block_whatsapp" - state = hass.states.get("switch.fake_profile_block_xboxlive") + state = hass.states.get("switch.fake_profile_block_xbox_live") assert state assert state.state == STATE_ON - entry = registry.async_get("switch.fake_profile_block_xboxlive") + entry = registry.async_get("switch.fake_profile_block_xbox_live") assert entry assert entry.unique_id == "xyz12_block_xboxlive" @@ -872,6 +585,14 @@ async def test_switch(hass: HomeAssistant) -> None: assert entry assert entry.unique_id == "xyz12_block_gambling" + state = hass.states.get("switch.fake_profile_block_online_gaming") + assert state + assert state.state == STATE_ON + + entry = registry.async_get("switch.fake_profile_block_online_gaming") + assert entry + assert entry.unique_id == "xyz12_block_online_gaming" + state = hass.states.get("switch.fake_profile_block_piracy") assert state assert state.state == STATE_ON @@ -896,6 +617,14 @@ async def test_switch(hass: HomeAssistant) -> None: assert entry assert entry.unique_id == "xyz12_block_social_networks" + state = hass.states.get("switch.fake_profile_block_video_streaming") + assert state + assert state.state == STATE_ON + + entry = registry.async_get("switch.fake_profile_block_video_streaming") + assert entry + assert entry.unique_id == "xyz12_block_video_streaming" + async def test_switch_on(hass: HomeAssistant) -> None: """Test the switch can be turned on."""