Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions homeassistant/components/device_automation/condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ def __init__(self, hass: HomeAssistant, config: ConfigType) -> None:
self._hass = hass

@classmethod
async def async_validate_condition_config(
async def async_validate_config(
cls, hass: HomeAssistant, config: ConfigType
) -> ConfigType:
"""Validate device condition config."""
return await async_validate_device_automation_config(
hass, config, cv.DEVICE_CONDITION_SCHEMA, DeviceAutomationType.CONDITION
)

async def async_condition_from_config(self) -> condition.ConditionCheckerType:
async def async_get_checker(self) -> condition.ConditionCheckerType:
"""Test a device condition."""
platform = await async_get_device_automation_platform(
self._hass, self._config[CONF_DOMAIN], DeviceAutomationType.CONDITION
Expand Down
3 changes: 3 additions & 0 deletions homeassistant/components/matter/icons.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
"esa_opt_out_state": {
"default": "mdi:home-lightning-bolt"
},
"esa_state": {
"default": "mdi:home-lightning-bolt"
},
"evse_state": {
"default": "mdi:ev-station"
},
Expand Down
11 changes: 0 additions & 11 deletions homeassistant/components/matter/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,6 @@ async def async_pause(self) -> None:
def _update_from_device(self) -> None:
"""Update from device."""
self._calculate_features()
# optional battery level
if VacuumEntityFeature.BATTERY & self._attr_supported_features:
self._attr_battery_level = self.get_matter_attribute_value(
clusters.PowerSource.Attributes.BatPercentRemaining
)
# derive state from the run mode + operational state
run_mode_raw: int = self.get_matter_attribute_value(
clusters.RvcRunMode.Attributes.CurrentMode
Expand Down Expand Up @@ -188,11 +183,6 @@ def _calculate_features(self) -> None:
supported_features |= VacuumEntityFeature.STATE
supported_features |= VacuumEntityFeature.STOP

# optional battery attribute = battery feature
if self.get_matter_attribute_value(
clusters.PowerSource.Attributes.BatPercentRemaining
):
supported_features |= VacuumEntityFeature.BATTERY
# optional identify cluster = locate feature (value must be not None or 0)
if self.get_matter_attribute_value(clusters.Identify.Attributes.IdentifyType):
supported_features |= VacuumEntityFeature.LOCATE
Expand Down Expand Up @@ -230,7 +220,6 @@ def _calculate_features(self) -> None:
clusters.RvcRunMode.Attributes.CurrentMode,
clusters.RvcOperationalState.Attributes.OperationalState,
),
optional_attributes=(clusters.PowerSource.Attributes.BatPercentRemaining,),
device_type=(device_types.RoboticVacuumCleaner,),
allow_none_value=True,
),
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/reolink/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async def async_get_config_entry_diagnostics(
IPC_cam[ch]["hardware version"] = api.camera_hardware_version(ch)
IPC_cam[ch]["firmware version"] = api.camera_sw_version(ch)
IPC_cam[ch]["encoding main"] = await api.get_encoding(ch)
if (signal := api.wifi_signal(ch)) is not None:
if (signal := api.wifi_signal(ch)) is not None and api.wifi_connection(ch):
IPC_cam[ch]["WiFi signal"] = signal

chimes: dict[int, dict[str, Any]] = {}
Expand All @@ -43,7 +43,7 @@ async def async_get_config_entry_diagnostics(
"HTTP(S) port": api.port,
"Baichuan port": api.baichuan.port,
"Baichuan only": api.baichuan_only,
"WiFi connection": api.wifi_connection,
"WiFi connection": api.wifi_connection(),
"WiFi signal": api.wifi_signal(),
"RTMP enabled": api.rtmp_enabled,
"RTSP enabled": api.rtsp_enabled,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/reolink/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
"iot_class": "local_push",
"loggers": ["reolink_aio"],
"quality_scale": "platinum",
"requirements": ["reolink-aio==0.14.5"]
"requirements": ["reolink-aio==0.14.6"]
}
2 changes: 1 addition & 1 deletion homeassistant/components/reolink/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class ReolinkHostSensorEntityDescription(
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
entity_registry_enabled_default=False,
value=lambda api: api.wifi_signal(),
supported=lambda api: api.supported(None, "wifi") and api.wifi_connection,
supported=lambda api: api.supported(None, "wifi") and api.wifi_connection(),
),
ReolinkHostSensorEntityDescription(
key="cpu_usage",
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/sun/condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ def __init__(self, hass: HomeAssistant, config: ConfigType) -> None:
self._hass = hass

@classmethod
async def async_validate_condition_config(
async def async_validate_config(
cls, hass: HomeAssistant, config: ConfigType
) -> ConfigType:
"""Validate config."""
return _CONDITION_SCHEMA(config) # type: ignore[no-any-return]

async def async_condition_from_config(self) -> ConditionCheckerType:
async def async_get_checker(self) -> ConditionCheckerType:
"""Wrap action method with sun based condition."""
before = self._config.get("before")
after = self._config.get("after")
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/template/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@
"data_description": {
"device_id": "[%key:component::template::common::device_id_description%]",
"state": "[%key:component::template::config::step::sensor::data_description::state%]",
"unit_of_measurement": "[%key:component::template::config::step::sensor::data_description::state%]"
"unit_of_measurement": "[%key:component::template::config::step::sensor::data_description::unit_of_measurement%]"
},
"sections": {
"advanced_options": {
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/zone/condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ def __init__(self, hass: HomeAssistant, config: ConfigType) -> None:
self._config = config

@classmethod
async def async_validate_condition_config(
async def async_validate_config(
cls, hass: HomeAssistant, config: ConfigType
) -> ConfigType:
"""Validate config."""
return _CONDITION_SCHEMA(config) # type: ignore[no-any-return]

async def async_condition_from_config(self) -> ConditionCheckerType:
async def async_get_checker(self) -> ConditionCheckerType:
"""Wrap action method with zone based condition."""
entity_ids = self._config.get(CONF_ENTITY_ID, [])
zone_entity_ids = self._config.get(CONF_ZONE, [])
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/zwave_js/triggers/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,13 @@ def __init__(self, hass: HomeAssistant, config: ConfigType) -> None:
self._hass = hass

@classmethod
async def async_validate_trigger_config(
async def async_validate_config(
cls, hass: HomeAssistant, config: ConfigType
) -> ConfigType:
"""Validate config."""
return await async_validate_trigger_config(hass, config)

async def async_attach_trigger(
async def async_attach(
self,
action: TriggerActionType,
trigger_info: TriggerInfo,
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/zwave_js/triggers/value_updated.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,13 @@ def __init__(self, hass: HomeAssistant, config: ConfigType) -> None:
self._hass = hass

@classmethod
async def async_validate_trigger_config(
async def async_validate_config(
cls, hass: HomeAssistant, config: ConfigType
) -> ConfigType:
"""Validate config."""
return await async_validate_trigger_config(hass, config)

async def async_attach_trigger(
async def async_attach(
self,
action: TriggerActionType,
trigger_info: TriggerInfo,
Expand Down
10 changes: 5 additions & 5 deletions homeassistant/helpers/condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,14 @@ def __init__(self, hass: HomeAssistant, config: ConfigType) -> None:

@classmethod
@abc.abstractmethod
async def async_validate_condition_config(
async def async_validate_config(
cls, hass: HomeAssistant, config: ConfigType
) -> ConfigType:
"""Validate config."""

@abc.abstractmethod
async def async_condition_from_config(self) -> ConditionCheckerType:
"""Evaluate state based on configuration."""
async def async_get_checker(self) -> ConditionCheckerType:
"""Get the condition checker."""


class ConditionProtocol(Protocol):
Expand Down Expand Up @@ -346,7 +346,7 @@ def disabled_condition(
if platform is not None:
condition_descriptors = await platform.async_get_conditions(hass)
condition_instance = condition_descriptors[condition](hass, config)
return await condition_instance.async_condition_from_config()
return await condition_instance.async_get_checker()

for fmt in (ASYNC_FROM_CONFIG_FORMAT, FROM_CONFIG_FORMAT):
factory = getattr(sys.modules[__name__], fmt.format(condition), None)
Expand Down Expand Up @@ -974,7 +974,7 @@ async def async_validate_condition_config(
condition_descriptors = await platform.async_get_conditions(hass)
if not (condition_class := condition_descriptors.get(condition)):
raise vol.Invalid(f"Invalid condition '{condition}' specified")
return await condition_class.async_validate_condition_config(hass, config)
return await condition_class.async_validate_config(hass, config)
if platform is None and condition in ("numeric_state", "state"):
validator = cast(
Callable[[HomeAssistant, ConfigType], ConfigType],
Expand Down
10 changes: 5 additions & 5 deletions homeassistant/helpers/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,18 @@ def __init__(self, hass: HomeAssistant, config: ConfigType) -> None:

@classmethod
@abc.abstractmethod
async def async_validate_trigger_config(
async def async_validate_config(
cls, hass: HomeAssistant, config: ConfigType
) -> ConfigType:
"""Validate config."""

@abc.abstractmethod
async def async_attach_trigger(
async def async_attach(
self,
action: TriggerActionType,
trigger_info: TriggerInfo,
) -> CALLBACK_TYPE:
"""Attach a trigger."""
"""Attach the trigger."""


class TriggerProtocol(Protocol):
Expand Down Expand Up @@ -390,7 +390,7 @@ async def async_validate_trigger_config(
)
if not (trigger := trigger_descriptors.get(relative_trigger_key)):
raise vol.Invalid(f"Invalid trigger '{trigger_key}' specified")
conf = await trigger.async_validate_trigger_config(hass, conf)
conf = await trigger.async_validate_config(hass, conf)
elif hasattr(platform, "async_validate_trigger_config"):
conf = await platform.async_validate_trigger_config(hass, conf)
else:
Expand Down Expand Up @@ -495,7 +495,7 @@ async def async_initialize_triggers(
platform_domain, trigger_key
)
trigger = trigger_descriptors[relative_trigger_key](hass, conf)
coro = trigger.async_attach_trigger(action_wrapper, info)
coro = trigger.async_attach(action_wrapper, info)
else:
coro = platform.async_attach_trigger(hass, conf, action_wrapper, info)

Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion requirements_test_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/components/reolink/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def _init_host_mock(host_mock: MagicMock) -> None:
host_mock.session_active = True
host_mock.timeout = 60
host_mock.renewtimer.return_value = 600
host_mock.wifi_connection = False
host_mock.wifi_connection.return_value = False
host_mock.wifi_signal.return_value = -45
host_mock.whiteled_mode_list.return_value = []
host_mock.post_recording_time_list.return_value = []
Expand Down
2 changes: 1 addition & 1 deletion tests/components/reolink/snapshots/test_diagnostics.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
'ONVIF enabled': True,
'RTMP enabled': True,
'RTSP enabled': True,
'WiFi connection': False,
'WiFi connection': True,
'WiFi signal': -45,
'abilities': dict({
'abilityChn': list([
Expand Down
2 changes: 2 additions & 0 deletions tests/components/reolink/test_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ async def test_entry_diagnostics(
snapshot: SnapshotAssertion,
) -> None:
"""Test Reolink diagnostics."""
reolink_host.wifi_connection.return_value = True

assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
diag = await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
Expand Down
2 changes: 1 addition & 1 deletion tests/components/reolink/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async def test_sensors(
) -> None:
"""Test sensor entities."""
reolink_host.ptz_pan_position.return_value = 1200
reolink_host.wifi_connection = True
reolink_host.wifi_connection.return_value = True
reolink_host.wifi_signal.return_value = -55
reolink_host.hdd_list = [0]
reolink_host.hdd_storage.return_value = 95
Expand Down
8 changes: 4 additions & 4 deletions tests/components/zwave_js/test_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ async def test_zwave_js_event_invalid_config_entry_id(
async def test_invalid_trigger_configs(hass: HomeAssistant) -> None:
"""Test invalid trigger configs."""
with pytest.raises(vol.Invalid):
await TRIGGERS["event"].async_validate_trigger_config(
await TRIGGERS["event"].async_validate_config(
hass,
{
"platform": f"{DOMAIN}.event",
Expand All @@ -988,7 +988,7 @@ async def test_invalid_trigger_configs(hass: HomeAssistant) -> None:
)

with pytest.raises(vol.Invalid):
await TRIGGERS["value_updated"].async_validate_trigger_config(
await TRIGGERS["value_updated"].async_validate_config(
hass,
{
"platform": f"{DOMAIN}.value_updated",
Expand Down Expand Up @@ -1026,7 +1026,7 @@ async def test_zwave_js_trigger_config_entry_unloaded(
await hass.config_entries.async_unload(integration.entry_id)

# Test full validation for both events
assert await TRIGGERS["value_updated"].async_validate_trigger_config(
assert await TRIGGERS["value_updated"].async_validate_config(
hass,
{
"platform": f"{DOMAIN}.value_updated",
Expand All @@ -1036,7 +1036,7 @@ async def test_zwave_js_trigger_config_entry_unloaded(
},
)

assert await TRIGGERS["event"].async_validate_trigger_config(
assert await TRIGGERS["event"].async_validate_config(
hass,
{
"platform": f"{DOMAIN}.event",
Expand Down
6 changes: 3 additions & 3 deletions tests/helpers/test_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -2089,7 +2089,7 @@ def __init__(self, hass: HomeAssistant, config: ConfigType) -> None:
"""Initialize condition."""

@classmethod
async def async_validate_condition_config(
async def async_validate_config(
cls, hass: HomeAssistant, config: ConfigType
) -> ConfigType:
"""Validate config."""
Expand All @@ -2098,14 +2098,14 @@ async def async_validate_condition_config(
class MockCondition1(MockCondition):
"""Mock condition 1."""

async def async_condition_from_config(self) -> condition.ConditionCheckerType:
async def async_get_checker(self) -> condition.ConditionCheckerType:
"""Evaluate state based on configuration."""
return lambda hass, vars: True

class MockCondition2(MockCondition):
"""Mock condition 2."""

async def async_condition_from_config(self) -> condition.ConditionCheckerType:
async def async_get_checker(self) -> condition.ConditionCheckerType:
"""Evaluate state based on configuration."""
return lambda hass, vars: False

Expand Down
6 changes: 3 additions & 3 deletions tests/helpers/test_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def __init__(self, hass: HomeAssistant, config: ConfigType) -> None:
"""Initialize trigger."""

@classmethod
async def async_validate_trigger_config(
async def async_validate_config(
cls, hass: HomeAssistant, config: ConfigType
) -> ConfigType:
"""Validate config."""
Expand All @@ -470,7 +470,7 @@ async def async_validate_trigger_config(
class MockTrigger1(MockTrigger):
"""Mock trigger 1."""

async def async_attach_trigger(
async def async_attach(
self,
action: TriggerActionType,
trigger_info: TriggerInfo,
Expand All @@ -481,7 +481,7 @@ async def async_attach_trigger(
class MockTrigger2(MockTrigger):
"""Mock trigger 2."""

async def async_attach_trigger(
async def async_attach(
self,
action: TriggerActionType,
trigger_info: TriggerInfo,
Expand Down
Loading