mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Improve Sonos alarm logging (#51212)
This commit is contained in:
parent
19c16e079f
commit
4b2831ddde
@ -104,7 +104,7 @@ class SonosAlarmEntity(SonosEntity, SwitchEntity):
|
|||||||
if self.alarm_id in self.hass.data[DATA_SONOS].alarms:
|
if self.alarm_id in self.hass.data[DATA_SONOS].alarms:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
_LOGGER.debug("The alarm is removed from hass because it has been deleted")
|
_LOGGER.debug("%s has been deleted", self.entity_id)
|
||||||
|
|
||||||
entity_registry = er.async_get(self.hass)
|
entity_registry = er.async_get(self.hass)
|
||||||
if entity_registry.async_get(self.entity_id):
|
if entity_registry.async_get(self.entity_id):
|
||||||
@ -119,7 +119,7 @@ class SonosAlarmEntity(SonosEntity, SwitchEntity):
|
|||||||
|
|
||||||
def update_alarm(self):
|
def update_alarm(self):
|
||||||
"""Update the state of the alarm."""
|
"""Update the state of the alarm."""
|
||||||
_LOGGER.debug("Updating the state of the alarm")
|
_LOGGER.debug("Updating alarm: %s", self.entity_id)
|
||||||
if self.speaker.soco.uid != self.alarm.zone.uid:
|
if self.speaker.soco.uid != self.alarm.zone.uid:
|
||||||
self.speaker = self.hass.data[DATA_SONOS].discovered.get(
|
self.speaker = self.hass.data[DATA_SONOS].discovered.get(
|
||||||
self.alarm.zone.uid
|
self.alarm.zone.uid
|
||||||
@ -150,7 +150,7 @@ class SonosAlarmEntity(SonosEntity, SwitchEntity):
|
|||||||
connections={(dr.CONNECTION_NETWORK_MAC, self.speaker.mac_address)},
|
connections={(dr.CONNECTION_NETWORK_MAC, self.speaker.mac_address)},
|
||||||
)
|
)
|
||||||
if not entity_registry.async_get(self.entity_id).device_id == new_device.id:
|
if not entity_registry.async_get(self.entity_id).device_id == new_device.id:
|
||||||
_LOGGER.debug("The alarm is switching the sonos player")
|
_LOGGER.debug("%s is moving to %s", self.entity_id, new_device.name)
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
entity_registry._async_update_entity(
|
entity_registry._async_update_entity(
|
||||||
self.entity_id, device_id=new_device.id
|
self.entity_id, device_id=new_device.id
|
||||||
@ -199,10 +199,8 @@ class SonosAlarmEntity(SonosEntity, SwitchEntity):
|
|||||||
async def async_handle_switch_on_off(self, turn_on: bool) -> None:
|
async def async_handle_switch_on_off(self, turn_on: bool) -> None:
|
||||||
"""Handle turn on/off of alarm switch."""
|
"""Handle turn on/off of alarm switch."""
|
||||||
try:
|
try:
|
||||||
_LOGGER.debug("Switching the state of the alarm")
|
_LOGGER.debug("Toggling the state of %s", self.entity_id)
|
||||||
self.alarm.enabled = turn_on
|
self.alarm.enabled = turn_on
|
||||||
await self.hass.async_add_executor_job(self.alarm.save)
|
await self.hass.async_add_executor_job(self.alarm.save)
|
||||||
except SoCoUPnPException as exc:
|
except SoCoUPnPException as exc:
|
||||||
_LOGGER.warning(
|
_LOGGER.error("Could not update %s: %s", self.entity_id, exc, exc_info=True)
|
||||||
"Home Assistant couldn't switch the alarm %s", exc, exc_info=True
|
|
||||||
)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user