Avoid logging tracebacks for auth failures in philips js (#80381)

Avoid logging tracebacks for auth failures
This commit is contained in:
Joakim Plate 2022-10-16 17:13:32 +02:00 committed by GitHub
parent fa24529d98
commit 5d09fe8dc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,7 +7,7 @@ from datetime import timedelta
import logging import logging
from typing import Any from typing import Any
from haphilipsjs import ConnectionFailure, PhilipsTV from haphilipsjs import AutenticationFailure, ConnectionFailure, PhilipsTV
from haphilipsjs.typing import SystemType from haphilipsjs.typing import SystemType
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
@ -21,7 +21,7 @@ from homeassistant.const import (
from homeassistant.core import Context, HassJob, HomeAssistant, callback from homeassistant.core import Context, HassJob, HomeAssistant, callback
from homeassistant.helpers.debounce import Debouncer from homeassistant.helpers.debounce import Debouncer
from homeassistant.helpers.trigger import TriggerActionType from homeassistant.helpers.trigger import TriggerActionType
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from .const import CONF_ALLOW_NOTIFY, CONF_SYSTEM, DOMAIN from .const import CONF_ALLOW_NOTIFY, CONF_SYSTEM, DOMAIN
@ -169,7 +169,11 @@ class PhilipsTVDataUpdateCoordinator(DataUpdateCoordinator[None]):
async def _notify_task(self): async def _notify_task(self):
while self._notify_wanted: while self._notify_wanted:
res = await self.api.notifyChange(130) try:
res = await self.api.notifyChange(130)
except (ConnectionFailure, AutenticationFailure):
res = None
if res: if res:
self.async_set_updated_data(None) self.async_set_updated_data(None)
elif res is None: elif res is None:
@ -203,3 +207,5 @@ class PhilipsTVDataUpdateCoordinator(DataUpdateCoordinator[None]):
self._async_notify_schedule() self._async_notify_schedule()
except ConnectionFailure: except ConnectionFailure:
pass pass
except AutenticationFailure as exception:
raise UpdateFailed(str(exception)) from exception