diff --git a/homeassistant/components/agent_dvr/camera.py b/homeassistant/components/agent_dvr/camera.py index 7904f98216b..24cd5dbb92c 100644 --- a/homeassistant/components/agent_dvr/camera.py +++ b/homeassistant/components/agent_dvr/camera.py @@ -102,10 +102,10 @@ class AgentCamera(MjpegCamera): _LOGGER.debug("%s reacquired", self._name) self._removed = False except AgentError: - if self.device.client.is_available: # server still available - camera error - if not self._removed: - _LOGGER.error("%s lost", self._name) - self._removed = True + # server still available - camera error + if self.device.client.is_available and not self._removed: + _LOGGER.error("%s lost", self._name) + self._removed = True @property def extra_state_attributes(self): diff --git a/homeassistant/components/alarmdecoder/config_flow.py b/homeassistant/components/alarmdecoder/config_flow.py index a82b84b60d1..08c8052c04b 100644 --- a/homeassistant/components/alarmdecoder/config_flow.py +++ b/homeassistant/components/alarmdecoder/config_flow.py @@ -349,12 +349,18 @@ def _device_already_added(current_entries, user_input, protocol): entry_path = entry.data.get(CONF_DEVICE_PATH) entry_baud = entry.data.get(CONF_DEVICE_BAUD) - if protocol == PROTOCOL_SOCKET: - if user_host == entry_host and user_port == entry_port: - return True + if ( + protocol == PROTOCOL_SOCKET + and user_host == entry_host + and user_port == entry_port + ): + return True - if protocol == PROTOCOL_SERIAL: - if user_baud == entry_baud and user_path == entry_path: - return True + if ( + protocol == PROTOCOL_SERIAL + and user_baud == entry_baud + and user_path == entry_path + ): + return True return False diff --git a/homeassistant/components/alexa/handlers.py b/homeassistant/components/alexa/handlers.py index dce4f9f2210..cee4cda562d 100644 --- a/homeassistant/components/alexa/handlers.py +++ b/homeassistant/components/alexa/handlers.py @@ -653,10 +653,9 @@ def temperature_from_object(hass, temp_obj, interval=False): if temp_obj["scale"] == "FAHRENHEIT": from_unit = TEMP_FAHRENHEIT - elif temp_obj["scale"] == "KELVIN": + elif temp_obj["scale"] == "KELVIN" and not interval: # convert to Celsius if absolute temperature - if not interval: - temp -= 273.15 + temp -= 273.15 return convert_temperature(temp, from_unit, to_unit, interval) diff --git a/homeassistant/components/apprise/notify.py b/homeassistant/components/apprise/notify.py index 95bf11ddc09..5f4a6b66643 100644 --- a/homeassistant/components/apprise/notify.py +++ b/homeassistant/components/apprise/notify.py @@ -42,11 +42,10 @@ def get_service(hass, config, discovery_info=None): _LOGGER.error("Invalid Apprise config url provided") return None - if config.get(CONF_URL): - # Ordered list of URLs - if not a_obj.add(config[CONF_URL]): - _LOGGER.error("Invalid Apprise URL(s) supplied") - return None + # Ordered list of URLs + if config.get(CONF_URL) and not a_obj.add(config[CONF_URL]): + _LOGGER.error("Invalid Apprise URL(s) supplied") + return None return AppriseNotificationService(a_obj) diff --git a/homeassistant/components/asuswrt/router.py b/homeassistant/components/asuswrt/router.py index 550e4c8fc16..c5880ea11bb 100644 --- a/homeassistant/components/asuswrt/router.py +++ b/homeassistant/components/asuswrt/router.py @@ -341,9 +341,8 @@ class AsusWrtRouter: async def close(self) -> None: """Close the connection.""" - if self._api is not None: - if self._protocol == PROTOCOL_TELNET: - self._api.connection.disconnect() + if self._api is not None and self._protocol == PROTOCOL_TELNET: + self._api.connection.disconnect() self._api = None for func in self._on_close: diff --git a/homeassistant/components/cast/media_player.py b/homeassistant/components/cast/media_player.py index 540f3263e1e..7c2a696027f 100644 --- a/homeassistant/components/cast/media_player.py +++ b/homeassistant/components/cast/media_player.py @@ -706,15 +706,15 @@ class CastDevice(MediaPlayerEntity): support = SUPPORT_CAST media_status = self._media_status()[0] - if self.cast_status: - if self.cast_status.volume_control_type != VOLUME_CONTROL_TYPE_FIXED: - support |= SUPPORT_VOLUME_MUTE | SUPPORT_VOLUME_SET + if ( + self.cast_status + and self.cast_status.volume_control_type != VOLUME_CONTROL_TYPE_FIXED + ): + support |= SUPPORT_VOLUME_MUTE | SUPPORT_VOLUME_SET if media_status: if media_status.supports_queue_next: - support |= SUPPORT_PREVIOUS_TRACK - if media_status.supports_queue_next: - support |= SUPPORT_NEXT_TRACK + support |= SUPPORT_PREVIOUS_TRACK | SUPPORT_NEXT_TRACK if media_status.supports_seek: support |= SUPPORT_SEEK diff --git a/homeassistant/components/climacell/weather.py b/homeassistant/components/climacell/weather.py index e6485f90936..b9da5431dd0 100644 --- a/homeassistant/components/climacell/weather.py +++ b/homeassistant/components/climacell/weather.py @@ -274,13 +274,12 @@ class ClimaCellWeatherEntity(ClimaCellEntity, WeatherEntity): ), temp_low, ) - elif self.forecast_type == NOWCAST: + elif self.forecast_type == NOWCAST and precipitation: # Precipitation is forecasted in CONF_TIMESTEP increments but in a # per hour rate, so value needs to be converted to an amount. - if precipitation: - precipitation = ( - precipitation / 60 * self._config_entry.options[CONF_TIMESTEP] - ) + precipitation = ( + precipitation / 60 * self._config_entry.options[CONF_TIMESTEP] + ) forecasts.append( _forecast_dict(