From 48ae3bece8a1720b773a64cab3c0285c7eb3ff4b Mon Sep 17 00:00:00 2001 From: jjlawren Date: Mon, 31 Jan 2022 12:21:21 -0600 Subject: [PATCH] Send notification to alert of Sonos networking issues (#65084) * Send notification to alert of Sonos networking issues * Add links to documentation --- homeassistant/components/sonos/entity.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/sonos/entity.py b/homeassistant/components/sonos/entity.py index 74d310d40ec..53768431a1d 100644 --- a/homeassistant/components/sonos/entity.py +++ b/homeassistant/components/sonos/entity.py @@ -9,6 +9,7 @@ import soco.config as soco_config from soco.core import SoCo from soco.exceptions import SoCoException +from homeassistant.components import persistent_notification import homeassistant.helpers.device_registry as dr from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity import DeviceInfo, Entity @@ -22,6 +23,8 @@ from .const import ( ) from .speaker import SonosSpeaker +SUB_FAIL_URL = "https://www.home-assistant.io/integrations/sonos/#network-requirements" + _LOGGER = logging.getLogger(__name__) @@ -70,10 +73,15 @@ class SonosEntity(Entity): listener_msg = f"{self.speaker.subscription_address} (advertising as {soco_config.EVENT_ADVERTISE_IP})" else: listener_msg = self.speaker.subscription_address - _LOGGER.warning( - "%s cannot reach %s, falling back to polling, functionality may be limited", - self.speaker.zone_name, - listener_msg, + message = f"{self.speaker.zone_name} cannot reach {listener_msg}, falling back to polling, functionality may be limited" + log_link_msg = f", see {SUB_FAIL_URL} for more details" + notification_link_msg = f'.\n\nSee Sonos documentation for more details.' + _LOGGER.warning(message + log_link_msg) + persistent_notification.async_create( + self.hass, + message + notification_link_msg, + "Sonos networking issue", + "sonos_subscriptions_failed", ) self.speaker.subscriptions_failed = True await self.speaker.async_unsubscribe()