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,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config: ConfigType,
|
||||||
variables: TemplateVarsType,
|
variables: TemplateVarsType,
|
||||||
context: Context,
|
context: Context | None,
|
||||||
domain: str,
|
domain: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Change state based on configuration."""
|
"""Change state based on configuration."""
|
||||||
|
|
|
@ -137,7 +137,7 @@ class HumidifierEntity(ToggleEntity):
|
||||||
def capability_attributes(self) -> dict[str, Any]:
|
def capability_attributes(self) -> dict[str, Any]:
|
||||||
"""Return capability attributes."""
|
"""Return capability attributes."""
|
||||||
supported_features = self.supported_features or 0
|
supported_features = self.supported_features or 0
|
||||||
data = {
|
data: dict[str, int | list[str] | None] = {
|
||||||
ATTR_MIN_HUMIDITY: self.min_humidity,
|
ATTR_MIN_HUMIDITY: self.min_humidity,
|
||||||
ATTR_MAX_HUMIDITY: self.max_humidity,
|
ATTR_MAX_HUMIDITY: self.max_humidity,
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ class HumidifierEntity(ToggleEntity):
|
||||||
def state_attributes(self) -> dict[str, Any]:
|
def state_attributes(self) -> dict[str, Any]:
|
||||||
"""Return the optional state attributes."""
|
"""Return the optional state attributes."""
|
||||||
supported_features = self.supported_features or 0
|
supported_features = self.supported_features or 0
|
||||||
data = {}
|
data: dict[str, int | str | None] = {}
|
||||||
|
|
||||||
if self.target_humidity is not None:
|
if self.target_humidity is not None:
|
||||||
data[ATTR_HUMIDITY] = self.target_humidity
|
data[ATTR_HUMIDITY] = self.target_humidity
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
"""Provides device actions for Humidifier."""
|
"""Provides device actions for Humidifier."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.device_automation import toggle_entity
|
from homeassistant.components.device_automation import toggle_entity
|
||||||
|
@ -70,7 +72,10 @@ async def async_get_actions(
|
||||||
|
|
||||||
|
|
||||||
async def async_call_action_from_config(
|
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:
|
) -> None:
|
||||||
"""Execute a device action."""
|
"""Execute a device action."""
|
||||||
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
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:
|
def test_is_state(hass: HomeAssistant, variables: TemplateVarsType) -> bool:
|
||||||
"""Test if an entity is a certain state."""
|
"""Test if an entity is a certain state."""
|
||||||
state = hass.states.get(config[ATTR_ENTITY_ID])
|
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
|
return test_is_state
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,9 @@ async def _async_reproduce_states(
|
||||||
if cur_state.state != STATE_ON:
|
if cur_state.state != STATE_ON:
|
||||||
await call_service(SERVICE_TURN_ON, [])
|
await call_service(SERVICE_TURN_ON, [])
|
||||||
# refetch the state as turning on might allow us to see some more values
|
# 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
|
# Then set the mode before target humidity, because switching modes
|
||||||
# may invalidate target humidity
|
# may invalidate target humidity
|
||||||
|
|
3
mypy.ini
3
mypy.ini
|
@ -1958,9 +1958,6 @@ ignore_errors = true
|
||||||
[mypy-homeassistant.components.honeywell.*]
|
[mypy-homeassistant.components.honeywell.*]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
[mypy-homeassistant.components.humidifier.*]
|
|
||||||
ignore_errors = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.iaqualink.*]
|
[mypy-homeassistant.components.iaqualink.*]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,6 @@ IGNORED_MODULES: Final[list[str]] = [
|
||||||
"homeassistant.components.homekit.*",
|
"homeassistant.components.homekit.*",
|
||||||
"homeassistant.components.homekit_controller.*",
|
"homeassistant.components.homekit_controller.*",
|
||||||
"homeassistant.components.honeywell.*",
|
"homeassistant.components.honeywell.*",
|
||||||
"homeassistant.components.humidifier.*",
|
|
||||||
"homeassistant.components.iaqualink.*",
|
"homeassistant.components.iaqualink.*",
|
||||||
"homeassistant.components.icloud.*",
|
"homeassistant.components.icloud.*",
|
||||||
"homeassistant.components.image.*",
|
"homeassistant.components.image.*",
|
||||||
|
|
Loading…
Reference in New Issue