diff --git a/homeassistant/components/device_automation/toggle_entity.py b/homeassistant/components/device_automation/toggle_entity.py index c09d297a1cf..e664a639fbf 100644 --- a/homeassistant/components/device_automation/toggle_entity.py +++ b/homeassistant/components/device_automation/toggle_entity.py @@ -109,7 +109,7 @@ async def async_call_action_from_config( hass: HomeAssistant, config: ConfigType, variables: TemplateVarsType, - context: Context, + context: Context | None, domain: str, ) -> None: """Change state based on configuration.""" diff --git a/homeassistant/components/humidifier/__init__.py b/homeassistant/components/humidifier/__init__.py index bf3a45d6e91..8eda2589417 100644 --- a/homeassistant/components/humidifier/__init__.py +++ b/homeassistant/components/humidifier/__init__.py @@ -137,7 +137,7 @@ class HumidifierEntity(ToggleEntity): def capability_attributes(self) -> dict[str, Any]: """Return capability attributes.""" supported_features = self.supported_features or 0 - data = { + data: dict[str, int | list[str] | None] = { ATTR_MIN_HUMIDITY: self.min_humidity, ATTR_MAX_HUMIDITY: self.max_humidity, } @@ -161,7 +161,7 @@ class HumidifierEntity(ToggleEntity): def state_attributes(self) -> dict[str, Any]: """Return the optional state attributes.""" supported_features = self.supported_features or 0 - data = {} + data: dict[str, int | str | None] = {} if self.target_humidity is not None: data[ATTR_HUMIDITY] = self.target_humidity diff --git a/homeassistant/components/humidifier/device_action.py b/homeassistant/components/humidifier/device_action.py index 3ad4b22dcec..d8f13d31b55 100644 --- a/homeassistant/components/humidifier/device_action.py +++ b/homeassistant/components/humidifier/device_action.py @@ -1,6 +1,8 @@ """Provides device actions for Humidifier.""" from __future__ import annotations +from typing import Any + import voluptuous as vol from homeassistant.components.device_automation import toggle_entity @@ -70,7 +72,10 @@ async def async_get_actions( async def async_call_action_from_config( - hass: HomeAssistant, config: dict, variables: dict, context: Context | None + hass: HomeAssistant, + config: dict[str, Any], + variables: dict[str, Any], + context: Context | None, ) -> None: """Execute a device action.""" service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]} diff --git a/homeassistant/components/humidifier/device_condition.py b/homeassistant/components/humidifier/device_condition.py index c8204c91a29..a8baf4f4910 100644 --- a/homeassistant/components/humidifier/device_condition.py +++ b/homeassistant/components/humidifier/device_condition.py @@ -77,7 +77,9 @@ def async_condition_from_config( def test_is_state(hass: HomeAssistant, variables: TemplateVarsType) -> bool: """Test if an entity is a certain state.""" state = hass.states.get(config[ATTR_ENTITY_ID]) - return state and state.attributes.get(attribute) == config[attribute] + return ( + state is not None and state.attributes.get(attribute) == config[attribute] + ) return test_is_state diff --git a/homeassistant/components/humidifier/reproduce_state.py b/homeassistant/components/humidifier/reproduce_state.py index e6d4fddafbc..b0e9a29cacc 100644 --- a/homeassistant/components/humidifier/reproduce_state.py +++ b/homeassistant/components/humidifier/reproduce_state.py @@ -62,7 +62,9 @@ async def _async_reproduce_states( if cur_state.state != STATE_ON: await call_service(SERVICE_TURN_ON, []) # refetch the state as turning on might allow us to see some more values - cur_state = hass.states.get(state.entity_id) + if (cur_state := hass.states.get(state.entity_id)) is None: + _LOGGER.warning("Unable to find entity %s", state.entity_id) + return # Then set the mode before target humidity, because switching modes # may invalidate target humidity diff --git a/mypy.ini b/mypy.ini index 389e4b13829..c3679e8cc9c 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1958,9 +1958,6 @@ ignore_errors = true [mypy-homeassistant.components.honeywell.*] ignore_errors = true -[mypy-homeassistant.components.humidifier.*] -ignore_errors = true - [mypy-homeassistant.components.iaqualink.*] ignore_errors = true diff --git a/script/hassfest/mypy_config.py b/script/hassfest/mypy_config.py index 80e2022243d..9a5e0ad948d 100644 --- a/script/hassfest/mypy_config.py +++ b/script/hassfest/mypy_config.py @@ -49,7 +49,6 @@ IGNORED_MODULES: Final[list[str]] = [ "homeassistant.components.homekit.*", "homeassistant.components.homekit_controller.*", "homeassistant.components.honeywell.*", - "homeassistant.components.humidifier.*", "homeassistant.components.iaqualink.*", "homeassistant.components.icloud.*", "homeassistant.components.image.*",