Complete strict typing to Humidifier entity platform (#61021)
parent
d7b080b285
commit
2fe08d2b9b
|
@ -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."""
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
3
mypy.ini
3
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
|
||||
|
||||
|
|
|
@ -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.*",
|
||||
|
|
Loading…
Reference in New Issue