diff --git a/homeassistant/components/homematic/climate.py b/homeassistant/components/homematic/climate.py index 2b0306809b0..16c345c5635 100644 --- a/homeassistant/components/homematic/climate.py +++ b/homeassistant/components/homematic/climate.py @@ -140,8 +140,10 @@ class HMThermostat(HMDevice, ClimateEntity): def set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" - if (temperature := kwargs.get(ATTR_TEMPERATURE)) is not None: - self._hmdevice.writeNodeData(self._state, float(temperature)) + if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None: + return None + + self._hmdevice.writeNodeData(self._state, float(temperature)) def set_hvac_mode(self, hvac_mode: HVACMode) -> None: """Set new target hvac mode.""" diff --git a/homeassistant/components/nest/media_source.py b/homeassistant/components/nest/media_source.py index 1260474ad88..6c481806e4f 100644 --- a/homeassistant/components/nest/media_source.py +++ b/homeassistant/components/nest/media_source.py @@ -227,9 +227,10 @@ class NestEventMediaStore(EventMediaStore): filename = self.get_media_filename(media_key) def remove_media(filename: str) -> None: - if os.path.exists(filename): - _LOGGER.debug("Removing event media from disk store: %s", filename) - os.remove(filename) + if not os.path.exists(filename): + return None + _LOGGER.debug("Removing event media from disk store: %s", filename) + os.remove(filename) try: await self._hass.async_add_executor_job(remove_media, filename) diff --git a/homeassistant/components/telnet/switch.py b/homeassistant/components/telnet/switch.py index 8aae49f8730..805f037dbae 100644 --- a/homeassistant/components/telnet/switch.py +++ b/homeassistant/components/telnet/switch.py @@ -142,9 +142,10 @@ class TelnetSwitch(SwitchEntity): response = self._telnet_command(self._command_state) if response and self._value_template: rendered = self._value_template.render_with_possible_json_value(response) - self._attr_is_on = rendered == "True" else: _LOGGER.warning("Empty response for command: %s", self._command_state) + return None + self._attr_is_on = rendered == "True" def turn_on(self, **kwargs: Any) -> None: """Turn the device on.""" diff --git a/homeassistant/components/tradfri/switch.py b/homeassistant/components/tradfri/switch.py index 88126f1ffce..4ad1424aa9a 100644 --- a/homeassistant/components/tradfri/switch.py +++ b/homeassistant/components/tradfri/switch.py @@ -72,10 +72,12 @@ class TradfriSwitch(TradfriBaseEntity, SwitchEntity): async def async_turn_off(self, **kwargs: Any) -> None: """Instruct the switch to turn off.""" - if self._device_control: - await self._api(self._device_control.set_state(False)) + if not self._device_control: + return None + await self._api(self._device_control.set_state(False)) async def async_turn_on(self, **kwargs: Any) -> None: """Instruct the switch to turn on.""" - if self._device_control: - await self._api(self._device_control.set_state(True)) + if not self._device_control: + return None + await self._api(self._device_control.set_state(True))