diff --git a/homeassistant/components/kostal_plenticore/helper.py b/homeassistant/components/kostal_plenticore/helper.py index 51544e49409..cb43486dbe0 100644 --- a/homeassistant/components/kostal_plenticore/helper.py +++ b/homeassistant/components/kostal_plenticore/helper.py @@ -145,8 +145,8 @@ class DataUpdateCoordinatorMixin: await client.set_setting_values(module_id, value) except ApiException: return False - else: - return True + + return True class PlenticoreUpdateCoordinator(DataUpdateCoordinator[_DataT]): diff --git a/homeassistant/components/media_extractor/__init__.py b/homeassistant/components/media_extractor/__init__.py index 081375e8e08..a0c542d72a5 100644 --- a/homeassistant/components/media_extractor/__init__.py +++ b/homeassistant/components/media_extractor/__init__.py @@ -140,18 +140,16 @@ class MediaExtractor: except MEQueryException: _LOGGER.error("Wrong query format: %s", stream_query) return - else: - data = {k: v for k, v in self.call_data.items() if k != ATTR_ENTITY_ID} - data[ATTR_MEDIA_CONTENT_ID] = stream_url - if entity_id: - data[ATTR_ENTITY_ID] = entity_id + data = {k: v for k, v in self.call_data.items() if k != ATTR_ENTITY_ID} + data[ATTR_MEDIA_CONTENT_ID] = stream_url - self.hass.async_create_task( - self.hass.services.async_call( - MEDIA_PLAYER_DOMAIN, SERVICE_PLAY_MEDIA, data - ) - ) + if entity_id: + data[ATTR_ENTITY_ID] = entity_id + + self.hass.async_create_task( + self.hass.services.async_call(MEDIA_PLAYER_DOMAIN, SERVICE_PLAY_MEDIA, data) + ) def get_stream_query_for_entity(self, entity_id): """Get stream format query for entity.""" diff --git a/homeassistant/components/metoffice/helpers.py b/homeassistant/components/metoffice/helpers.py index ecef7e5ddcb..cdd506790ef 100644 --- a/homeassistant/components/metoffice/helpers.py +++ b/homeassistant/components/metoffice/helpers.py @@ -35,18 +35,18 @@ def fetch_data(connection: datapoint.Manager, site: Site, mode: str) -> MetOffic except (ValueError, datapoint.exceptions.APIException) as err: _LOGGER.error("Check Met Office connection: %s", err.args) raise UpdateFailed from err - else: - time_now = utcnow() - return MetOfficeData( - now=forecast.now(), - forecast=[ - timestep - for day in forecast.days - for timestep in day.timesteps - if timestep.date > time_now - and ( - mode == MODE_3HOURLY or timestep.date.hour > 6 - ) # ensures only one result per day in MODE_DAILY - ], - site=site, - ) + + time_now = utcnow() + return MetOfficeData( + now=forecast.now(), + forecast=[ + timestep + for day in forecast.days + for timestep in day.timesteps + if timestep.date > time_now + and ( + mode == MODE_3HOURLY or timestep.date.hour > 6 + ) # ensures only one result per day in MODE_DAILY + ], + site=site, + ) diff --git a/homeassistant/components/modbus/modbus.py b/homeassistant/components/modbus/modbus.py index 0c4215f4dbd..fb30d245850 100644 --- a/homeassistant/components/modbus/modbus.py +++ b/homeassistant/components/modbus/modbus.py @@ -371,10 +371,10 @@ class ModbusHub: except ModbusException as exception_error: self._log_error(str(exception_error), error_state=False) return False - else: - message = f"modbus {self.name} communication open" - _LOGGER.info(message) - return True + + message = f"modbus {self.name} communication open" + _LOGGER.info(message) + return True def _pymodbus_call( self, unit: int | None, address: int, value: int | list[int], use_call: str diff --git a/homeassistant/components/modem_callerid/config_flow.py b/homeassistant/components/modem_callerid/config_flow.py index 2bc857a16f4..537fe81da11 100644 --- a/homeassistant/components/modem_callerid/config_flow.py +++ b/homeassistant/components/modem_callerid/config_flow.py @@ -111,5 +111,5 @@ class PhoneModemFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): await api.test(dev_path) except EXCEPTIONS: return {"base": "cannot_connect"} - else: - return None + + return None diff --git a/homeassistant/components/motion_blinds/__init__.py b/homeassistant/components/motion_blinds/__init__.py index 378a2f1f03d..e53b006ddd8 100644 --- a/homeassistant/components/motion_blinds/__init__.py +++ b/homeassistant/components/motion_blinds/__init__.py @@ -71,8 +71,8 @@ class DataUpdateCoordinatorMotionBlinds(DataUpdateCoordinator): except (timeout, ParseException): # let the error be logged and handled by the motionblinds library return {ATTR_AVAILABLE: False} - else: - return {ATTR_AVAILABLE: True} + + return {ATTR_AVAILABLE: True} def update_blind(self, blind): """Fetch data from a blind.""" @@ -84,8 +84,8 @@ class DataUpdateCoordinatorMotionBlinds(DataUpdateCoordinator): except (timeout, ParseException): # let the error be logged and handled by the motionblinds library return {ATTR_AVAILABLE: False} - else: - return {ATTR_AVAILABLE: True} + + return {ATTR_AVAILABLE: True} async def _async_update_data(self): """Fetch the latest data from the gateway and blinds."""