Skip to content

Commit

Permalink
Add logging to SamsungTV turn-on (home-assistant#117962)
Browse files Browse the repository at this point in the history
* Add logging to SamsungTV turn-on

* Apply suggestions from code review

Co-authored-by: J. Nick Koston <nick@koston.org>

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
  • Loading branch information
epenet and bdraco authored May 24, 2024
1 parent f896c75 commit a6ca5c5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion homeassistant/components/samsungtv/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from homeassistant.helpers.trigger import PluggableAction
from homeassistant.helpers.update_coordinator import CoordinatorEntity

from .const import CONF_MANUFACTURER, DOMAIN
from .const import CONF_MANUFACTURER, DOMAIN, LOGGER
from .coordinator import SamsungTVDataUpdateCoordinator
from .triggers.turn_on import async_get_turn_on_trigger

Expand Down Expand Up @@ -89,10 +89,21 @@ async def _async_turn_off(self) -> None:
async def _async_turn_on(self) -> None:
"""Turn the remote on."""
if self._turn_on_action:
LOGGER.debug("Attempting to turn on %s via automation", self.entity_id)
await self._turn_on_action.async_run(self.hass, self._context)
elif self._mac:
LOGGER.info(
"Attempting to turn on %s via Wake-On-Lan; if this does not work, "
"please ensure that Wake-On-Lan is available for your device or use "
"a turn_on automation",
self.entity_id,
)
await self.hass.async_add_executor_job(self._wake_on_lan)
else:
LOGGER.error(
"Unable to turn on %s, as it does not have an automation configured",
self.entity_id,
)
raise HomeAssistantError(
f"Entity {self.entity_id} does not support this service."
)

0 comments on commit a6ca5c5

Please sign in to comment.