Include advertise_addr in Sonos logs when used (#53617)

This commit is contained in:
jjlawren 2021-07-28 12:19:09 -05:00 committed by GitHub
parent 1b96288799
commit 9111fb60d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,7 @@ from __future__ import annotations
import datetime
import logging
import soco.config as soco_config
from soco.core import SoCo
from soco.exceptions import SoCoException
@ -65,10 +66,14 @@ class SonosEntity(Entity):
async def async_poll(self, now: datetime.datetime) -> None:
"""Poll the entity if subscriptions fail."""
if not self.speaker.subscriptions_failed:
if soco_config.EVENT_ADVERTISE_IP:
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",
"%s cannot reach %s, falling back to polling, functionality may be limited",
self.speaker.zone_name,
self.speaker.subscription_address,
listener_msg,
)
self.speaker.subscriptions_failed = True
await self.speaker.async_unsubscribe()