mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Remove unnecessary try-else (1) (#86158)
This commit is contained in:
parent
6d336ec136
commit
1cc8feabb7
@ -152,5 +152,5 @@ class AirzoneZoneEntity(AirzoneEntity):
|
|||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
f"Failed to set zone {self.name}: {error}"
|
f"Failed to set zone {self.name}: {error}"
|
||||||
) from error
|
) from error
|
||||||
else:
|
|
||||||
self.coordinator.async_set_updated_data(self.coordinator.airzone.data())
|
self.coordinator.async_set_updated_data(self.coordinator.airzone.data())
|
||||||
|
@ -76,17 +76,16 @@ class BroadlinkUpdateManager(ABC):
|
|||||||
)
|
)
|
||||||
raise UpdateFailed(err) from err
|
raise UpdateFailed(err) from err
|
||||||
|
|
||||||
else:
|
if self.available is False:
|
||||||
if self.available is False:
|
_LOGGER.warning(
|
||||||
_LOGGER.warning(
|
"Connected to %s (%s at %s)",
|
||||||
"Connected to %s (%s at %s)",
|
self.device.name,
|
||||||
self.device.name,
|
self.device.api.model,
|
||||||
self.device.api.model,
|
self.device.api.host[0],
|
||||||
self.device.api.host[0],
|
)
|
||||||
)
|
self.available = True
|
||||||
self.available = True
|
self.last_update = dt.utcnow()
|
||||||
self.last_update = dt.utcnow()
|
return data
|
||||||
return data
|
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
async def async_fetch_data(self):
|
async def async_fetch_data(self):
|
||||||
|
@ -747,8 +747,8 @@ class CameraImageView(CameraView):
|
|||||||
)
|
)
|
||||||
except (HomeAssistantError, ValueError) as ex:
|
except (HomeAssistantError, ValueError) as ex:
|
||||||
raise web.HTTPInternalServerError() from ex
|
raise web.HTTPInternalServerError() from ex
|
||||||
else:
|
|
||||||
return web.Response(body=image.content, content_type=image.content_type)
|
return web.Response(body=image.content, content_type=image.content_type)
|
||||||
|
|
||||||
|
|
||||||
class CameraMjpegStream(CameraView):
|
class CameraMjpegStream(CameraView):
|
||||||
|
@ -131,12 +131,11 @@ def get_data(hass: HomeAssistant, config: Mapping[str, Any]) -> CO2SignalRespons
|
|||||||
_LOGGER.exception("Unexpected exception")
|
_LOGGER.exception("Unexpected exception")
|
||||||
raise UnknownError from err
|
raise UnknownError from err
|
||||||
|
|
||||||
else:
|
if "error" in data:
|
||||||
if "error" in data:
|
raise UnknownError(data["error"])
|
||||||
raise UnknownError(data["error"])
|
|
||||||
|
|
||||||
if data.get("status") != "ok":
|
if data.get("status") != "ok":
|
||||||
_LOGGER.exception("Unexpected response: %s", data)
|
_LOGGER.exception("Unexpected response: %s", data)
|
||||||
raise UnknownError
|
raise UnknownError
|
||||||
|
|
||||||
return cast(CO2SignalResponse, data)
|
return cast(CO2SignalResponse, data)
|
||||||
|
@ -285,15 +285,15 @@ class EmonCmsData:
|
|||||||
except requests.exceptions.RequestException as exception:
|
except requests.exceptions.RequestException as exception:
|
||||||
_LOGGER.error(exception)
|
_LOGGER.error(exception)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if req.status_code == HTTPStatus.OK:
|
||||||
|
self.data = req.json()
|
||||||
else:
|
else:
|
||||||
if req.status_code == HTTPStatus.OK:
|
_LOGGER.error(
|
||||||
self.data = req.json()
|
(
|
||||||
else:
|
"Please verify if the specified configuration value "
|
||||||
_LOGGER.error(
|
"'%s' is correct! (HTTP Status_code = %d)"
|
||||||
(
|
),
|
||||||
"Please verify if the specified configuration value "
|
CONF_URL,
|
||||||
"'%s' is correct! (HTTP Status_code = %d)"
|
req.status_code,
|
||||||
),
|
)
|
||||||
CONF_URL,
|
|
||||||
req.status_code,
|
|
||||||
)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user