Compare commits

..

1 Commits

Author SHA1 Message Date
Franck Nijhof 43c8fbcf49 Bump version to 2026.7.0dev0 2026-05-27 16:09:42 +00:00
42 changed files with 444 additions and 11769 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ on:
env:
CACHE_VERSION: 3
MYPY_CACHE_VERSION: 1
HA_SHORT_VERSION: "2026.6"
HA_SHORT_VERSION: "2026.7"
ADDITIONAL_PYTHON_VERSIONS: "[]"
# 10.3 is the oldest supported version
# - 10.3.32 is the version currently shipped with Synology (as of 17 Feb 2022)
+4 -2
View File
@@ -92,7 +92,8 @@ def _extract_backup(
):
ostf.tar.extractall(
path=Path(tempdir, "extracted"),
filter="tar",
members=securetar.secure_path(ostf.tar),
filter="fully_trusted",
)
backup_meta_file = Path(tempdir, "extracted", "backup.json")
backup_meta = json.loads(backup_meta_file.read_text(encoding="utf8"))
@@ -118,7 +119,8 @@ def _extract_backup(
) as istf:
istf.extractall(
path=Path(tempdir, "homeassistant"),
filter="tar",
members=securetar.secure_path(istf),
filter="fully_trusted",
)
if restore_content.restore_homeassistant:
keep = list(KEEP_BACKUPS)
@@ -8,5 +8,5 @@
"iot_class": "cloud_polling",
"loggers": ["aioamazondevices"],
"quality_scale": "platinum",
"requirements": ["aioamazondevices==13.8.1"]
"requirements": ["aioamazondevices==13.8.0"]
}
@@ -20,7 +20,7 @@
"bluetooth-adapters==2.3.0",
"bluetooth-auto-recovery==1.6.4",
"bluetooth-data-tools==1.29.18",
"dbus-fast==5.0.16",
"dbus-fast==5.0.15",
"habluetooth==6.7.9"
]
}
@@ -7,6 +7,6 @@
"integration_type": "device",
"iot_class": "local_polling",
"quality_scale": "bronze",
"requirements": ["iometer==1.0.1"],
"requirements": ["iometer==0.4.0"],
"zeroconf": ["_iometer._tcp.local."]
}
@@ -556,48 +556,4 @@ DISCOVERY_SCHEMAS = [
featuremap_contains=clusters.Thermostat.Bitmaps.Feature.kOccupancy,
allow_multi=True,
),
# GeneralDiagnostics active fault sensors
MatterDiscoverySchema(
platform=Platform.BINARY_SENSOR,
entity_description=MatterBinarySensorEntityDescription(
key="GeneralDiagnosticsActiveHardwareFaults",
translation_key="active_hardware_faults",
device_class=BinarySensorDeviceClass.PROBLEM,
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
device_to_ha=bool,
),
entity_class=MatterBinarySensor,
required_attributes=(
clusters.GeneralDiagnostics.Attributes.ActiveHardwareFaults,
),
),
MatterDiscoverySchema(
platform=Platform.BINARY_SENSOR,
entity_description=MatterBinarySensorEntityDescription(
key="GeneralDiagnosticsActiveRadioFaults",
translation_key="active_radio_faults",
device_class=BinarySensorDeviceClass.PROBLEM,
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
device_to_ha=bool,
),
entity_class=MatterBinarySensor,
required_attributes=(clusters.GeneralDiagnostics.Attributes.ActiveRadioFaults,),
),
MatterDiscoverySchema(
platform=Platform.BINARY_SENSOR,
entity_description=MatterBinarySensorEntityDescription(
key="GeneralDiagnosticsActiveNetworkFaults",
translation_key="active_network_faults",
device_class=BinarySensorDeviceClass.PROBLEM,
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
device_to_ha=bool,
),
entity_class=MatterBinarySensor,
required_attributes=(
clusters.GeneralDiagnostics.Attributes.ActiveNetworkFaults,
),
),
]
+1 -8
View File
@@ -457,14 +457,7 @@ class MatterLight(MatterEntity, LightEntity):
self._transitions_disabled = True
LOGGER.warning(
"Detected a device that has been reported to have firmware issues "
"with light transitions. Transitions will be disabled for this "
"light: %s %s (vendor_id: %s, product_id: %s, hw: %s, sw: %s)",
device_info.vendorName,
device_info.productName,
device_info.vendorID,
device_info.productID,
device_info.hardwareVersionString,
device_info.softwareVersionString,
"with light transitions. Transitions will be disabled for this light"
)
-53
View File
@@ -137,17 +137,6 @@ RVC_OPERATIONAL_STATE_ERROR_MAP = {
_rvc_err.kNavigationSensorObscured: ("navigation_sensor_obscured"),
}
BOOT_REASON_MAP = {
clusters.GeneralDiagnostics.Enums.BootReasonEnum.kUnspecified: "unspecified",
clusters.GeneralDiagnostics.Enums.BootReasonEnum.kPowerOnReboot: "power_on_reboot",
clusters.GeneralDiagnostics.Enums.BootReasonEnum.kBrownOutReset: "brown_out_reset",
clusters.GeneralDiagnostics.Enums.BootReasonEnum.kSoftwareWatchdogReset: "software_watchdog_reset",
clusters.GeneralDiagnostics.Enums.BootReasonEnum.kHardwareWatchdogReset: "hardware_watchdog_reset",
clusters.GeneralDiagnostics.Enums.BootReasonEnum.kSoftwareUpdateCompleted: "software_update_completed",
clusters.GeneralDiagnostics.Enums.BootReasonEnum.kSoftwareReset: "software_reset",
clusters.GeneralDiagnostics.Enums.BootReasonEnum.kUnknownEnumValue: None,
}
BOOST_STATE_MAP = {
clusters.WaterHeaterManagement.Enums.BoostStateEnum.kInactive: "inactive",
clusters.WaterHeaterManagement.Enums.BoostStateEnum.kActive: "active",
@@ -1586,46 +1575,4 @@ DISCOVERY_SCHEMAS = [
required_attributes=(clusters.DoorLock.Attributes.DoorClosedEvents,),
featuremap_contains=clusters.DoorLock.Bitmaps.Feature.kDoorPositionSensor,
),
# GeneralDiagnostics cluster sensors
MatterDiscoverySchema(
platform=Platform.SENSOR,
entity_description=MatterSensorEntityDescription(
key="GeneralDiagnosticsRebootCount",
translation_key="reboot_count",
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
state_class=SensorStateClass.TOTAL_INCREASING,
),
entity_class=MatterSensor,
required_attributes=(clusters.GeneralDiagnostics.Attributes.RebootCount,),
),
MatterDiscoverySchema(
platform=Platform.SENSOR,
entity_description=MatterSensorEntityDescription(
key="GeneralDiagnosticsUpTime",
translation_key="uptime",
device_class=SensorDeviceClass.UPTIME,
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
device_to_ha=lambda uptime: dt_util.utcnow() - timedelta(seconds=uptime),
),
entity_class=MatterSensor,
required_attributes=(clusters.GeneralDiagnostics.Attributes.UpTime,),
),
MatterDiscoverySchema(
platform=Platform.SENSOR,
entity_description=MatterSensorEntityDescription(
key="GeneralDiagnosticsBootReason",
translation_key="boot_reason",
device_class=SensorDeviceClass.ENUM,
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
options=[
reason for reason in BOOT_REASON_MAP.values() if reason is not None
],
device_to_ha=BOOT_REASON_MAP.get,
),
entity_class=MatterSensor,
required_attributes=(clusters.GeneralDiagnostics.Attributes.BootReason,),
),
]
@@ -47,15 +47,6 @@
},
"entity": {
"binary_sensor": {
"active_hardware_faults": {
"name": "Hardware faults"
},
"active_network_faults": {
"name": "Network faults"
},
"active_radio_faults": {
"name": "Radio faults"
},
"actuator": {
"name": "Actuator"
},
@@ -417,18 +408,6 @@
"battery_voltage": {
"name": "Battery voltage"
},
"boot_reason": {
"name": "Boot reason",
"state": {
"brown_out_reset": "Brownout reset",
"hardware_watchdog_reset": "Hardware watchdog reset",
"power_on_reboot": "Power-on reboot",
"software_reset": "Software reset",
"software_update_completed": "Software update completed",
"software_watchdog_reset": "Software watchdog reset",
"unspecified": "Unspecified"
}
},
"contamination_state": {
"name": "Contamination state",
"state": {
@@ -597,9 +576,6 @@
"reactive_current": {
"name": "Reactive current"
},
"reboot_count": {
"name": "Reboot count"
},
"rms_current": {
"name": "Effective current"
},
@@ -624,9 +600,6 @@
"medium": "[%key:common::state::medium%]"
}
},
"uptime": {
"name": "Uptime"
},
"valve_position": {
"name": "Valve position"
},
@@ -80,31 +80,31 @@ class ZHAAlarmControlPanel(ZHAEntity, AlarmControlPanelEntity):
"""Whether the code is required for arm actions."""
return self.entity_data.entity.code_arm_required
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_alarm_disarm(self, code: str | None = None) -> None:
"""Send disarm command."""
await self.entity_data.entity.async_alarm_disarm(code)
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_alarm_arm_home(self, code: str | None = None) -> None:
"""Send arm home command."""
await self.entity_data.entity.async_alarm_arm_home(code)
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_alarm_arm_away(self, code: str | None = None) -> None:
"""Send arm away command."""
await self.entity_data.entity.async_alarm_arm_away(code)
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_alarm_arm_night(self, code: str | None = None) -> None:
"""Send arm night command."""
await self.entity_data.entity.async_alarm_arm_night(code)
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_alarm_trigger(self, code: str | None = None) -> None:
"""Send alarm trigger command."""
await self.entity_data.entity.async_alarm_trigger(code)
+1 -1
View File
@@ -52,7 +52,7 @@ class ZHAButton(ZHAEntity, ButtonEntity):
self.entity_data.entity.info_object.device_class
)
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_press(self) -> None:
"""Send out a update command."""
await self.entity_data.entity.async_press()
+4 -4
View File
@@ -203,25 +203,25 @@ class Thermostat(ZHAEntity, ClimateEntity):
)
super()._handle_entity_events(event)
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_set_fan_mode(self, fan_mode: str) -> None:
"""Set fan mode."""
await self.entity_data.entity.async_set_fan_mode(fan_mode=fan_mode)
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
"""Set new target operation mode."""
await self.entity_data.entity.async_set_hvac_mode(hvac_mode=hvac_mode)
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Set new preset mode."""
await self.entity_data.entity.async_set_preset_mode(preset_mode=preset_mode)
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_set_temperature(self, **kwargs: Any) -> None:
"""Set new target temperature."""
await self.entity_data.entity.async_set_temperature(
-4
View File
@@ -75,7 +75,3 @@ MFG_CLUSTER_ID_START = 0xFC00
ZHA_ALARM_OPTIONS = "zha_alarm_options"
ZHA_OPTIONS = "zha_options"
# Dispatcher signal carrying device reconfigure progress events (bind result,
# attribute reporting result, configure complete) to the websocket subscriber.
SIGNAL_DEVICE_RECONFIGURE_EVENT = "zha_device_reconfigure_event"
+8 -8
View File
@@ -122,31 +122,31 @@ class ZhaCover(ZHAEntity, CoverEntity):
"""Return the current tilt position of the cover."""
return self.entity_data.entity.current_cover_tilt_position
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover."""
await self.entity_data.entity.async_open_cover()
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_open_cover_tilt(self, **kwargs: Any) -> None:
"""Open the cover tilt."""
await self.entity_data.entity.async_open_cover_tilt()
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the cover."""
await self.entity_data.entity.async_close_cover()
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_close_cover_tilt(self, **kwargs: Any) -> None:
"""Close the cover tilt."""
await self.entity_data.entity.async_close_cover_tilt()
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_set_cover_position(self, **kwargs: Any) -> None:
"""Move the cover to a specific position."""
await self.entity_data.entity.async_set_cover_position(
@@ -154,7 +154,7 @@ class ZhaCover(ZHAEntity, CoverEntity):
)
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_set_cover_tilt_position(self, **kwargs: Any) -> None:
"""Move the cover tilt to a specific position."""
await self.entity_data.entity.async_set_cover_tilt_position(
@@ -162,13 +162,13 @@ class ZhaCover(ZHAEntity, CoverEntity):
)
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover."""
await self.entity_data.entity.async_stop_cover()
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_stop_cover_tilt(self, **kwargs: Any) -> None:
"""Stop the cover tilt."""
await self.entity_data.entity.async_stop_cover_tilt()
+93 -77
View File
@@ -3,26 +3,36 @@
from typing import Any
import voluptuous as vol
from zhaquirks.inovelli.types import AllLEDEffectType, SingleLEDEffectType
from zigpy.zcl.clusters.security import IasWd
from zha.exceptions import ZHAException
from zha.zigbee.cluster_handlers.const import (
CLUSTER_HANDLER_IAS_WD,
CLUSTER_HANDLER_INOVELLI,
)
from zha.zigbee.cluster_handlers.manufacturerspecific import (
AllLEDEffectType,
SingleLEDEffectType,
)
from homeassistant.components.device_automation import InvalidDeviceAutomationConfig
from homeassistant.const import CONF_DEVICE_ID, CONF_DOMAIN, CONF_TYPE
from homeassistant.core import Context, HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.typing import ConfigType, TemplateVarsType
from .const import DOMAIN
from .helpers import async_get_zha_device_proxy, convert_zha_error_to_ha_error
from .helpers import async_get_zha_device_proxy
from .websocket_api import SERVICE_WARNING_DEVICE_SQUAWK, SERVICE_WARNING_DEVICE_WARN
# mypy: disallow-any-generics
INOVELLI_CLUSTER_ID = 0xFC31
ACTION_SQUAWK = "squawk"
ACTION_WARN = "warn"
ATTR_DATA = "data"
ATTR_IEEE = "ieee"
CONF_ZHA_ACTION_TYPE = "zha_action_type"
ZHA_ACTION_TYPE_SERVICE_CALL = "service_call"
ZHA_ACTION_TYPE_CLUSTER_HANDLER_COMMAND = "cluster_handler_command"
INOVELLI_ALL_LED_EFFECT = "issue_all_led_effect"
INOVELLI_INDIVIDUAL_LED_EFFECT = "issue_individual_led_effect"
@@ -63,18 +73,24 @@ ACTION_SCHEMA = vol.Any(
DEFAULT_ACTION_SCHEMA,
)
# Maps a cluster_id the device must expose to the available actions.
DEVICE_ACTIONS_BY_CLUSTER_ID: dict[int, list[dict[str, str]]] = {
IasWd.cluster_id: [
DEVICE_ACTIONS = {
CLUSTER_HANDLER_IAS_WD: [
{CONF_TYPE: ACTION_SQUAWK, CONF_DOMAIN: DOMAIN},
{CONF_TYPE: ACTION_WARN, CONF_DOMAIN: DOMAIN},
],
INOVELLI_CLUSTER_ID: [
CLUSTER_HANDLER_INOVELLI: [
{CONF_TYPE: INOVELLI_ALL_LED_EFFECT, CONF_DOMAIN: DOMAIN},
{CONF_TYPE: INOVELLI_INDIVIDUAL_LED_EFFECT, CONF_DOMAIN: DOMAIN},
],
}
DEVICE_ACTION_TYPES = {
ACTION_SQUAWK: ZHA_ACTION_TYPE_SERVICE_CALL,
ACTION_WARN: ZHA_ACTION_TYPE_SERVICE_CALL,
INOVELLI_ALL_LED_EFFECT: ZHA_ACTION_TYPE_CLUSTER_HANDLER_COMMAND,
INOVELLI_INDIVIDUAL_LED_EFFECT: ZHA_ACTION_TYPE_CLUSTER_HANDLER_COMMAND,
}
DEVICE_ACTION_SCHEMAS = {
INOVELLI_ALL_LED_EFFECT: vol.Schema(
{
@@ -100,6 +116,11 @@ SERVICE_NAMES = {
ACTION_WARN: SERVICE_WARNING_DEVICE_WARN,
}
CLUSTER_HANDLER_MAPPINGS = {
INOVELLI_ALL_LED_EFFECT: CLUSTER_HANDLER_INOVELLI,
INOVELLI_INDIVIDUAL_LED_EFFECT: CLUSTER_HANDLER_INOVELLI,
}
async def async_call_action_from_config(
hass: HomeAssistant,
@@ -108,9 +129,9 @@ async def async_call_action_from_config(
context: Context | None,
) -> None:
"""Perform an action based on configuration."""
action_type = config[CONF_TYPE]
handler = ACTION_HANDLERS[action_type]
await handler(hass, config, context)
await ZHA_ACTION_TYPES[DEVICE_ACTION_TYPES[config[CONF_TYPE]]](
hass, config, variables, context
)
async def async_validate_action_config(
@@ -129,18 +150,19 @@ async def async_get_actions(
zha_device = async_get_zha_device_proxy(hass, device_id).device
except KeyError, AttributeError:
return []
cluster_ids = {
cluster_id
for ep_id, endpoint in zha_device.device.endpoints.items()
if ep_id != 0
for cluster_id in endpoint.in_clusters
}
actions: list[dict[str, str]] = []
for required_cluster_id, cluster_actions in DEVICE_ACTIONS_BY_CLUSTER_ID.items():
if required_cluster_id in cluster_ids:
actions.extend(
{**action, CONF_DEVICE_ID: device_id} for action in cluster_actions
)
cluster_handlers = [
ch.name
for endpoint in zha_device.endpoints.values()
for ch in endpoint.claimed_cluster_handlers.values()
]
actions = [
action
for cluster_handler, cluster_handler_actions in DEVICE_ACTIONS.items()
for action in cluster_handler_actions
if cluster_handler in cluster_handlers
]
for action in actions:
action[CONF_DEVICE_ID] = device_id
return actions
@@ -153,75 +175,69 @@ async def async_get_action_capabilities(
return {"extra_fields": fields}
async def _execute_siren_service(
async def _execute_service_based_action(
hass: HomeAssistant,
config: dict[str, Any],
variables: TemplateVarsType,
context: Context | None,
) -> None:
action_type = config[CONF_TYPE]
service_name = SERVICE_NAMES[action_type]
try:
zha_device = async_get_zha_device_proxy(hass, config[CONF_DEVICE_ID]).device
except KeyError, AttributeError:
return
service_data = {ATTR_IEEE: str(zha_device.ieee)}
await hass.services.async_call(
DOMAIN,
SERVICE_NAMES[config[CONF_TYPE]],
{ATTR_IEEE: str(zha_device.ieee)},
blocking=True,
context=context,
DOMAIN, service_name, service_data, blocking=True, context=context
)
def _find_inovelli_cluster(hass: HomeAssistant, config: dict[str, Any]) -> Any:
async def _execute_cluster_handler_command_based_action(
hass: HomeAssistant,
config: dict[str, Any],
variables: TemplateVarsType,
context: Context | None,
) -> None:
action_type = config[CONF_TYPE]
cluster_handler_name = CLUSTER_HANDLER_MAPPINGS[action_type]
try:
zha_device = async_get_zha_device_proxy(hass, config[CONF_DEVICE_ID]).device
except (KeyError, AttributeError) as err:
except KeyError, AttributeError:
return
action_cluster_handler = None
for endpoint in zha_device.endpoints.values():
for cluster_handler in endpoint.all_cluster_handlers.values():
if cluster_handler.name == cluster_handler_name:
action_cluster_handler = cluster_handler
break
if action_cluster_handler is None:
raise InvalidDeviceAutomationConfig(
f"ZHA device {config[CONF_DEVICE_ID]} not found"
) from err
f"Unable to execute cluster handler action -"
f" cluster handler: {cluster_handler_name} action:"
f" {action_type}"
)
if not hasattr(action_cluster_handler, action_type):
raise InvalidDeviceAutomationConfig(
f"Unable to execute cluster handler -"
f" cluster handler: {cluster_handler_name} action:"
f" {action_type}"
)
try:
return zha_device.device.find_cluster(cluster_id=INOVELLI_CLUSTER_ID)
except ValueError as err:
raise InvalidDeviceAutomationConfig(
f"Device does not expose Inovelli cluster 0x{INOVELLI_CLUSTER_ID:04x}"
) from err
await getattr(action_cluster_handler, action_type)(**config)
except ZHAException as err:
raise HomeAssistantError(err) from err
async def _execute_inovelli_all_led_effect(
hass: HomeAssistant,
config: dict[str, Any],
context: Context | None,
) -> None:
cluster = _find_inovelli_cluster(hass, config)
async with convert_zha_error_to_ha_error():
await cluster.led_effect(
led_effect=config["effect_type"],
led_color=config["color"],
led_level=config["level"],
led_duration=config["duration"],
)
async def _execute_inovelli_individual_led_effect(
hass: HomeAssistant,
config: dict[str, Any],
context: Context | None,
) -> None:
cluster = _find_inovelli_cluster(hass, config)
async with convert_zha_error_to_ha_error():
await cluster.individual_led_effect(
led_effect=config["effect_type"],
led_color=config["color"],
led_level=config["level"],
led_duration=config["duration"],
led_number=config["led_number"],
)
ACTION_HANDLERS = {
ACTION_SQUAWK: _execute_siren_service,
ACTION_WARN: _execute_siren_service,
INOVELLI_ALL_LED_EFFECT: _execute_inovelli_all_led_effect,
INOVELLI_INDIVIDUAL_LED_EFFECT: _execute_inovelli_individual_led_effect,
ZHA_ACTION_TYPES = {
ZHA_ACTION_TYPE_SERVICE_CALL: _execute_service_based_action,
ZHA_ACTION_TYPE_CLUSTER_HANDLER_COMMAND: (
_execute_cluster_handler_command_based_action
),
}
+1 -1
View File
@@ -206,7 +206,7 @@ class ZHAEntity(LogMixin, RestoreEntity, Entity):
await super().async_will_remove_from_hass()
self.remove_future.set_result(True)
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_update(self) -> None:
"""Update the entity."""
await self.entity_data.entity.async_update()
+4 -4
View File
@@ -92,7 +92,7 @@ class ZhaFan(FanEntity, ZHAEntity):
"""Return the number of speeds the fan supports."""
return self.entity_data.entity.speed_count
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_turn_on(
self,
percentage: int | None = None,
@@ -105,19 +105,19 @@ class ZhaFan(FanEntity, ZHAEntity):
)
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the entity off."""
await self.entity_data.entity.async_turn_off()
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_set_percentage(self, percentage: int) -> None:
"""Set the speed percentage of the fan."""
await self.entity_data.entity.async_set_percentage(percentage=percentage)
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Set the preset mode for the fan."""
await self.entity_data.entity.async_set_preset_mode(preset_mode=preset_mode)
+56 -63
View File
@@ -2,23 +2,23 @@
import asyncio
import collections
from collections.abc import AsyncGenerator, Callable, Mapping
from contextlib import asynccontextmanager
from collections.abc import Awaitable, Callable, Coroutine, Mapping
import copy
import dataclasses
import enum
import functools
import itertools
import logging
import queue
import re
import time
from types import MappingProxyType
from typing import TYPE_CHECKING, Any, NamedTuple, cast
from typing import TYPE_CHECKING, Any, Concatenate, NamedTuple, cast
from zoneinfo import ZoneInfo
import voluptuous as vol
from zha.application import Platform as ZhaPlatform
from zha.application.const import (
ATTR_CLUSTER_ID,
ATTR_DEVICE_IEEE,
ATTR_TYPE,
ATTR_UNIQUE_ID,
@@ -28,6 +28,11 @@ from zha.application.const import (
CONF_DEFAULT_CONSIDER_UNAVAILABLE_MAINS,
UNKNOWN_MANUFACTURER,
UNKNOWN_MODEL,
ZHA_CLUSTER_HANDLER_CFG_DONE,
ZHA_CLUSTER_HANDLER_MSG,
ZHA_CLUSTER_HANDLER_MSG_BIND,
ZHA_CLUSTER_HANDLER_MSG_CFG_RPT,
ZHA_CLUSTER_HANDLER_MSG_DATA,
ZHA_EVENT,
ZHA_GW_MSG,
ZHA_GW_MSG_DEVICE_FULL_INIT,
@@ -66,11 +71,10 @@ from zha.application.platforms import GroupEntity, PlatformEntity
from zha.event import EventBase
from zha.exceptions import ZHAException
from zha.mixins import LogMixin
from zha.zigbee.cluster_handlers import ClusterBindEvent, ClusterConfigureReportingEvent
from zha.zigbee.device import (
ClusterBindEvent,
ClusterConfigureReportingEvent,
ClusterHandlerConfigurationComplete,
Device,
DeviceConfiguredEvent,
DeviceEntityAddedEvent,
DeviceEntityRemovedEvent,
DeviceFirmwareInfoUpdatedEvent,
@@ -122,7 +126,9 @@ from homeassistant.util.logging import HomeAssistantQueueHandler
from .const import (
ATTR_ACTIVE_COORDINATOR,
ATTR_ATTRIBUTES,
ATTR_AVAILABLE,
ATTR_CLUSTER_NAME,
ATTR_DEVICE_TYPE,
ATTR_ENDPOINT_NAMES,
ATTR_EXPOSES_FEATURES,
@@ -138,6 +144,7 @@ from .const import (
ATTR_ROUTES,
ATTR_RSSI,
ATTR_SIGNATURE,
ATTR_SUCCESS,
CONF_ALARM_ARM_REQUIRES_CODE,
CONF_ALARM_FAILED_TRIES,
CONF_ALARM_MASTER_CODE,
@@ -161,7 +168,6 @@ from .const import (
DEFAULT_DATABASE_NAME,
DEVICE_PAIRING_STATUS,
DOMAIN,
SIGNAL_DEVICE_RECONFIGURE_EVENT,
ZHA_ALARM_OPTIONS,
ZHA_OPTIONS,
)
@@ -444,46 +450,50 @@ class ZHADeviceProxy(EventBase):
)
@callback
def handle_zha_cluster_bind(self, event: ClusterBindEvent) -> None:
"""Forward a cluster bind result to the reconfigure websocket."""
async_dispatcher_send(
self.gateway_proxy.hass,
SIGNAL_DEVICE_RECONFIGURE_EVENT,
{
"type": "zha_channel_bind",
"zha_channel_msg_data": {
"cluster_name": event.cluster_name,
"cluster_id": event.cluster_id,
"success": event.success,
},
},
)
@callback
def handle_zha_cluster_configure_reporting(
def handle_zha_channel_configure_reporting(
self, event: ClusterConfigureReportingEvent
) -> None:
"""Forward a cluster reporting-configured result to the reconfigure websocket."""
"""Handle a ZHA cluster configure reporting event."""
async_dispatcher_send(
self.gateway_proxy.hass,
SIGNAL_DEVICE_RECONFIGURE_EVENT,
ZHA_CLUSTER_HANDLER_MSG,
{
"type": "zha_channel_configure_reporting",
"zha_channel_msg_data": {
"cluster_name": event.cluster_name,
"cluster_id": event.cluster_id,
"attributes": event.attributes,
ATTR_TYPE: ZHA_CLUSTER_HANDLER_MSG_CFG_RPT,
ZHA_CLUSTER_HANDLER_MSG_DATA: {
ATTR_CLUSTER_NAME: event.cluster_name,
ATTR_CLUSTER_ID: event.cluster_id,
ATTR_ATTRIBUTES: event.attributes,
},
},
)
@callback
def handle_zha_device_configured(self, event: DeviceConfiguredEvent) -> None:
"""Forward the device configuration-complete signal to the reconfigure websocket."""
def handle_zha_channel_cfg_done(
self, event: ClusterHandlerConfigurationComplete
) -> None:
"""Handle a ZHA cluster configure reporting event."""
async_dispatcher_send(
self.gateway_proxy.hass,
SIGNAL_DEVICE_RECONFIGURE_EVENT,
{"type": "zha_channel_cfg_done"},
ZHA_CLUSTER_HANDLER_MSG,
{
ATTR_TYPE: ZHA_CLUSTER_HANDLER_CFG_DONE,
},
)
@callback
def handle_zha_channel_bind(self, event: ClusterBindEvent) -> None:
"""Handle a ZHA cluster bind event."""
async_dispatcher_send(
self.gateway_proxy.hass,
ZHA_CLUSTER_HANDLER_MSG,
{
ATTR_TYPE: ZHA_CLUSTER_HANDLER_MSG_BIND,
ZHA_CLUSTER_HANDLER_MSG_DATA: {
ATTR_CLUSTER_NAME: event.cluster_name,
ATTR_CLUSTER_ID: event.cluster_id,
ATTR_SUCCESS: event.success,
},
},
)
@callback
@@ -491,9 +501,6 @@ class ZHADeviceProxy(EventBase):
self, event: DeviceEntityAddedEvent
) -> None:
"""Handle a new entity being added to a device at runtime."""
if event.platform is ZhaPlatform.VIRTUAL:
return
key = (event.platform, event.unique_id)
if (entity := self.device.platform_entities.get(key)) is None:
return
@@ -508,9 +515,6 @@ class ZHADeviceProxy(EventBase):
self, event: DeviceEntityRemovedEvent
) -> None:
"""Handle an entity being removed from a device at runtime."""
if event.platform is ZhaPlatform.VIRTUAL:
return
if not event.remove:
# Soft remove: signal the entity to unload; registry entry stays
async_dispatcher_send(
@@ -907,9 +911,6 @@ class ZHAGatewayProxy(EventBase):
if isinstance(proxy_object, ZHADeviceProxy):
for entity in proxy_object.device.platform_entities.values():
if entity.PLATFORM is ZhaPlatform.VIRTUAL:
continue
ha_zha_data.platforms[Platform(entity.PLATFORM)].append(
EntityData(
entity=entity, device_proxy=proxy_object, group_proxy=None
@@ -917,9 +918,6 @@ class ZHAGatewayProxy(EventBase):
)
else:
for entity in proxy_object.group.group_entities.values():
if entity.PLATFORM is ZhaPlatform.VIRTUAL:
continue
ha_zha_data.platforms[Platform(entity.PLATFORM)].append(
EntityData(
entity=entity,
@@ -1388,24 +1386,19 @@ def create_zha_config(hass: HomeAssistant, ha_zha_data: HAZHAData) -> ZHAData:
)
@asynccontextmanager
async def convert_zha_error_to_ha_error() -> AsyncGenerator[None]:
def convert_zha_error_to_ha_error[**_P, _EntityT: ZHAEntity](
func: Callable[Concatenate[_EntityT, _P], Awaitable[None]],
) -> Callable[Concatenate[_EntityT, _P], Coroutine[Any, Any, None]]:
"""Decorate ZHA commands and re-raises ZHAException as HomeAssistantError."""
try:
yield
except TimeoutError as exc:
raise HomeAssistantError(
"Failed to send request: device did not respond"
) from exc
except zigpy.exceptions.ZigbeeException as exc:
message = "Failed to send request"
if str(exc):
message = f"{message}: {exc}"
@functools.wraps(func)
async def handler(self: _EntityT, *args: _P.args, **kwargs: _P.kwargs) -> None:
try:
return await func(self, *args, **kwargs)
except ZHAException as err:
raise HomeAssistantError(err) from err
raise HomeAssistantError(message) from exc
except ZHAException as err:
raise HomeAssistantError(err) from err
return handler
def exclude_none_values(obj: Mapping[str, Any]) -> dict[str, Any]:
+2 -2
View File
@@ -171,7 +171,7 @@ class Light(LightEntity, ZHAEntity):
"""Return the current effect."""
return self.entity_data.entity.effect
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the entity on."""
color_temp = (
@@ -189,7 +189,7 @@ class Light(LightEntity, ZHAEntity):
)
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the entity off."""
await self.entity_data.entity.async_turn_off(
+6 -6
View File
@@ -94,19 +94,19 @@ class ZhaDoorLock(ZHAEntity, LockEntity):
"""Return true if entity is locked."""
return self.entity_data.entity.is_locked
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_lock(self, **kwargs: Any) -> None:
"""Lock the lock."""
await self.entity_data.entity.async_lock()
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_unlock(self, **kwargs: Any) -> None:
"""Unlock the lock."""
await self.entity_data.entity.async_unlock()
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_set_lock_user_code(self, code_slot: int, user_code: str) -> None:
"""Set the user_code to index X on the lock."""
await self.entity_data.entity.async_set_lock_user_code(
@@ -114,19 +114,19 @@ class ZhaDoorLock(ZHAEntity, LockEntity):
)
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_enable_lock_user_code(self, code_slot: int) -> None:
"""Enable user_code at index X on the lock."""
await self.entity_data.entity.async_enable_lock_user_code(code_slot=code_slot)
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_disable_lock_user_code(self, code_slot: int) -> None:
"""Disable user_code at index X on the lock."""
await self.entity_data.entity.async_disable_lock_user_code(code_slot=code_slot)
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_clear_lock_user_code(self, code_slot: int) -> None:
"""Clear the user_code at index X on the lock."""
await self.entity_data.entity.async_clear_lock_user_code(code_slot=code_slot)
+1 -1
View File
@@ -23,7 +23,7 @@
"universal_silabs_flasher",
"serialx"
],
"requirements": ["zha==1.4.0"],
"requirements": ["zha==1.3.1"],
"usb": [
{
"description": "*2652*",
+1 -1
View File
@@ -78,7 +78,7 @@ class ZhaNumber(ZHAEntity, RestoreNumber):
"""Return the unit the value is expressed in."""
return self.entity_data.entity.native_unit_of_measurement
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_set_native_value(self, value: float) -> None:
"""Update the current value from HA."""
await self.entity_data.entity.async_set_native_value(value=value)
+1 -1
View File
@@ -58,7 +58,7 @@ class ZHAEnumSelectEntity(ZHAEntity, SelectEntity):
"""Return the selected entity option to represent the entity state."""
return self.entity_data.entity.current_option
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_select_option(self, option: str) -> None:
"""Change the selected option."""
await self.entity_data.entity.async_select_option(option=option)
+16 -11
View File
@@ -3,10 +3,15 @@
import functools
from typing import Any
from zha.application.platforms.siren import (
SirenEntityFeature as ZHASirenEntityFeature,
WarningMode,
from zha.application.const import (
WARNING_DEVICE_MODE_BURGLAR,
WARNING_DEVICE_MODE_EMERGENCY,
WARNING_DEVICE_MODE_EMERGENCY_PANIC,
WARNING_DEVICE_MODE_FIRE,
WARNING_DEVICE_MODE_FIRE_PANIC,
WARNING_DEVICE_MODE_POLICE_PANIC,
)
from zha.application.platforms.siren import SirenEntityFeature as ZHASirenEntityFeature
from homeassistant.components.siren import (
ATTR_DURATION,
@@ -54,12 +59,12 @@ class ZHASiren(ZHAEntity, SirenEntity):
"""Representation of a ZHA siren."""
_attr_available_tones: list[int | str] | dict[int, str] | None = {
WarningMode.Burglar: "Burglar",
WarningMode.Fire: "Fire",
WarningMode.Emergency: "Emergency",
WarningMode.Police_Panic: "Police Panic",
WarningMode.Fire_Panic: "Fire Panic",
WarningMode.Emergency_Panic: "Emergency Panic",
WARNING_DEVICE_MODE_BURGLAR: "Burglar",
WARNING_DEVICE_MODE_FIRE: "Fire",
WARNING_DEVICE_MODE_EMERGENCY: "Emergency",
WARNING_DEVICE_MODE_POLICE_PANIC: "Police Panic",
WARNING_DEVICE_MODE_FIRE_PANIC: "Fire Panic",
WARNING_DEVICE_MODE_EMERGENCY_PANIC: "Emergency Panic",
}
def __init__(self, entity_data: EntityData, **kwargs: Any) -> None:
@@ -87,7 +92,7 @@ class ZHASiren(ZHAEntity, SirenEntity):
"""Return True if entity is on."""
return self.entity_data.entity.is_on
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn on siren."""
await self.entity_data.entity.async_turn_on(
@@ -97,7 +102,7 @@ class ZHASiren(ZHAEntity, SirenEntity):
)
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn off siren."""
await self.entity_data.entity.async_turn_off()
+2 -2
View File
@@ -49,13 +49,13 @@ class Switch(ZHAEntity, SwitchEntity):
"""Return if the switch is on based on the statemachine."""
return self.entity_data.entity.is_on
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the entity on."""
await self.entity_data.entity.async_turn_on()
self.async_write_ha_state()
@convert_zha_error_to_ha_error()
@convert_zha_error_to_ha_error
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the entity off."""
await self.entity_data.entity.async_turn_off()
+1 -1
View File
@@ -181,7 +181,7 @@ class ZHAFirmwareUpdateEntity(
return self.entity_data.entity.release_url
# We explicitly convert ZHA exceptions to HA exceptions here so there is no need to
# use the `@convert_zha_error_to_ha_error()` decorator.
# use the `@convert_zha_error_to_ha_error` decorator.
async def async_install(
self, version: str | None, backup: bool, **kwargs: Any
) -> None:
+80 -34
View File
@@ -29,6 +29,12 @@ from zha.application.const import (
CLUSTER_COMMANDS_SERVER,
CLUSTER_TYPE_IN,
CLUSTER_TYPE_OUT,
WARNING_DEVICE_MODE_EMERGENCY,
WARNING_DEVICE_SOUND_HIGH,
WARNING_DEVICE_SQUAWK_MODE_ARMED,
WARNING_DEVICE_STROBE_HIGH,
WARNING_DEVICE_STROBE_YES,
ZHA_CLUSTER_HANDLER_MSG,
ZHA_GW_MSG,
)
from zha.application.gateway import Gateway
@@ -38,14 +44,7 @@ from zha.application.helpers import (
get_matched_clusters,
qr_to_install_code,
)
from zha.application.platforms.siren import (
BaseSiren,
SirenLevel,
SquawkMode,
Strobe,
StrobeLevel,
WarningMode,
)
from zha.zigbee.cluster_handlers.const import CLUSTER_HANDLER_IAS_WD
from zha.zigbee.group import GroupMemberReference
import zigpy.backups
from zigpy.config import CONF_DEVICE
@@ -60,7 +59,7 @@ import zigpy.zdo.types as zdo_types
from homeassistant.components import websocket_api
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_COMMAND, ATTR_ID, ATTR_NAME, Platform
from homeassistant.const import ATTR_COMMAND, ATTR_ID, ATTR_NAME
from homeassistant.core import HomeAssistant, ServiceCall, callback
from homeassistant.helpers import config_validation as cv, entity_registry as er
from homeassistant.helpers.dispatcher import async_dispatcher_connect
@@ -80,7 +79,6 @@ from .const import (
GROUP_IDS,
GROUP_NAME,
MFG_CLUSTER_ID_START,
SIGNAL_DEVICE_RECONFIGURE_EVENT,
ZHA_ALARM_OPTIONS,
ZHA_OPTIONS,
)
@@ -182,13 +180,13 @@ SERVICE_SCHEMAS: dict[str, VolSchemaType] = {
{
vol.Required(ATTR_IEEE): IEEE_SCHEMA,
vol.Optional(
ATTR_WARNING_DEVICE_MODE, default=SquawkMode.Armed
ATTR_WARNING_DEVICE_MODE, default=WARNING_DEVICE_SQUAWK_MODE_ARMED
): cv.positive_int,
vol.Optional(
ATTR_WARNING_DEVICE_STROBE, default=Strobe.Strobe
ATTR_WARNING_DEVICE_STROBE, default=WARNING_DEVICE_STROBE_YES
): cv.positive_int,
vol.Optional(
ATTR_LEVEL, default=SirenLevel.High_level_sound
ATTR_LEVEL, default=WARNING_DEVICE_SOUND_HIGH
): cv.positive_int,
}
),
@@ -196,21 +194,20 @@ SERVICE_SCHEMAS: dict[str, VolSchemaType] = {
{
vol.Required(ATTR_IEEE): IEEE_SCHEMA,
vol.Optional(
ATTR_WARNING_DEVICE_MODE, default=WarningMode.Emergency
ATTR_WARNING_DEVICE_MODE, default=WARNING_DEVICE_MODE_EMERGENCY
): cv.positive_int,
vol.Optional(
ATTR_WARNING_DEVICE_STROBE, default=Strobe.Strobe
ATTR_WARNING_DEVICE_STROBE, default=WARNING_DEVICE_STROBE_YES
): cv.positive_int,
vol.Optional(
ATTR_LEVEL, default=SirenLevel.High_level_sound
ATTR_LEVEL, default=WARNING_DEVICE_SOUND_HIGH
): cv.positive_int,
vol.Optional(ATTR_WARNING_DEVICE_DURATION, default=5): cv.positive_int,
vol.Optional(
ATTR_WARNING_DEVICE_STROBE_DUTY_CYCLE, default=0x00
): cv.positive_int,
vol.Optional(
ATTR_WARNING_DEVICE_STROBE_INTENSITY,
default=StrobeLevel.High_level_strobe,
ATTR_WARNING_DEVICE_STROBE_INTENSITY, default=WARNING_DEVICE_STROBE_HIGH
): cv.positive_int,
}
),
@@ -427,7 +424,10 @@ async def websocket_get_groupable_devices(
),
}
for entity_ref in entity_refs
if entity_ref.entity_data.entity.endpoint.id == ep_id
if list(entity_ref.entity_data.entity.cluster_handlers.values())[
0
].cluster.endpoint.endpoint_id
== ep_id
],
"device": device.zha_device_info,
}
@@ -649,7 +649,7 @@ async def websocket_reconfigure_node(
connection.send_message(websocket_api.event_message(msg["id"], data))
remove_dispatcher_function = async_dispatcher_connect(
hass, SIGNAL_DEVICE_RECONFIGURE_EVENT, forward_messages
hass, ZHA_CLUSTER_HANDLER_MSG, forward_messages
)
@callback
@@ -1480,6 +1480,15 @@ def async_load_api(hass: HomeAssistant) -> None:
schema=SERVICE_SCHEMAS[SERVICE_ISSUE_ZIGBEE_GROUP_COMMAND],
)
def _get_ias_wd_cluster_handler(zha_device):
"""Get the IASWD cluster handler for a device."""
cluster_handlers = {
ch.name: ch
for endpoint in zha_device.endpoints.values()
for ch in endpoint.claimed_cluster_handlers.values()
}
return cluster_handlers.get(CLUSTER_HANDLER_IAS_WD)
async def warning_device_squawk(service: ServiceCall) -> None:
"""Issue the squawk command for an IAS warning device."""
ieee: EUI64 = service.data[ATTR_IEEE]
@@ -1487,10 +1496,31 @@ def async_load_api(hass: HomeAssistant) -> None:
strobe: int = service.data[ATTR_WARNING_DEVICE_STROBE]
level: int = service.data[ATTR_LEVEL]
device = zha_gateway.get_device(ieee)
siren: BaseSiren = device.get_entity(Platform.SIREN, pick_first=True)
await siren.async_squawk(mode=mode, strobe=strobe, squawk_level=level)
if (zha_device := zha_gateway.get_device(ieee)) is not None:
if cluster_handler := _get_ias_wd_cluster_handler(zha_device):
await cluster_handler.issue_squawk(mode, strobe, level)
else:
_LOGGER.error(
"Squawking IASWD: %s: [%s] is missing"
" the required IASWD cluster handler!",
ATTR_IEEE,
str(ieee),
)
else:
_LOGGER.error(
"Squawking IASWD: %s: [%s] could not be found!", ATTR_IEEE, str(ieee)
)
_LOGGER.debug(
"Squawking IASWD: %s: [%s] %s: [%s] %s: [%s] %s: [%s]",
ATTR_IEEE,
str(ieee),
ATTR_WARNING_DEVICE_MODE,
mode,
ATTR_WARNING_DEVICE_STROBE,
strobe,
ATTR_LEVEL,
level,
)
async_register_admin_service(
hass,
@@ -1510,16 +1540,32 @@ def async_load_api(hass: HomeAssistant) -> None:
duty_mode: int = service.data[ATTR_WARNING_DEVICE_STROBE_DUTY_CYCLE]
intensity: int = service.data[ATTR_WARNING_DEVICE_STROBE_INTENSITY]
device = zha_gateway.get_device(ieee)
siren: BaseSiren = device.get_entity(Platform.SIREN, pick_first=True)
await siren.async_turn_on(
tone=mode,
volume_level=level,
duration=duration,
strobe=strobe,
strobe_duty_cycle=duty_mode,
strobe_intensity=intensity,
if (zha_device := zha_gateway.get_device(ieee)) is not None:
if cluster_handler := _get_ias_wd_cluster_handler(zha_device):
await cluster_handler.issue_start_warning(
mode, strobe, level, duration, duty_mode, intensity
)
else:
_LOGGER.error(
"Warning IASWD: %s: [%s] is missing"
" the required IASWD cluster handler!",
ATTR_IEEE,
str(ieee),
)
else:
_LOGGER.error(
"Warning IASWD: %s: [%s] could not be found!", ATTR_IEEE, str(ieee)
)
_LOGGER.debug(
"Warning IASWD: %s: [%s] %s: [%s] %s: [%s] %s: [%s]",
ATTR_IEEE,
str(ieee),
ATTR_WARNING_DEVICE_MODE,
mode,
ATTR_WARNING_DEVICE_STROBE,
strobe,
ATTR_LEVEL,
level,
)
async_register_admin_service(
+1 -1
View File
@@ -14,7 +14,7 @@ if TYPE_CHECKING:
APPLICATION_NAME: Final = "HomeAssistant"
MAJOR_VERSION: Final = 2026
MINOR_VERSION: Final = 6
MINOR_VERSION: Final = 7
PATCH_VERSION: Final = "0.dev0"
__short_version__: Final = f"{MAJOR_VERSION}.{MINOR_VERSION}"
__version__: Final = f"{__short_version__}.{PATCH_VERSION}"
+1 -1
View File
@@ -30,7 +30,7 @@ certifi>=2021.5.30
ciso8601==2.3.3
cronsim==2.7
cryptography==48.0.0
dbus-fast==5.0.16
dbus-fast==5.0.15
file-read-backwards==2.0.0
fnv-hash-fast==2.0.3
go2rtc-client==0.4.0
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "homeassistant"
version = "2026.6.0.dev0"
version = "2026.7.0.dev0"
license = "Apache-2.0"
license-files = ["LICENSE*", "homeassistant/backports/LICENSE*"]
description = "Open-source home automation platform running on Python 3."
+4 -4
View File
@@ -190,7 +190,7 @@ aioairzone-cloud==0.7.2
aioairzone==1.0.5
# homeassistant.components.alexa_devices
aioamazondevices==13.8.1
aioamazondevices==13.8.0
# homeassistant.components.ambient_network
# homeassistant.components.ambient_station
@@ -797,7 +797,7 @@ datadog==0.52.0
datapoint==0.12.1
# homeassistant.components.bluetooth
dbus-fast==5.0.16
dbus-fast==5.0.15
# homeassistant.components.debugpy
debugpy==1.8.17
@@ -1371,7 +1371,7 @@ insteon-frontend-home-assistant==0.6.2
intellifire4py==4.4.0
# homeassistant.components.iometer
iometer==1.0.1
iometer==0.4.0
# homeassistant.components.iotty
iottycloud==0.3.0
@@ -3442,7 +3442,7 @@ zeroconf==0.149.16
zeversolar==0.3.2
# homeassistant.components.zha
zha==1.4.0
zha==1.3.1
# homeassistant.components.zhong_hong
zhong-hong-hvac==1.0.13
@@ -1,6 +1,5 @@
{
"__typename": "iometer.reading.v1",
"installationId": "658c2b34-2017-45f2-a12b-731235f8bb97",
"meter": {
"number": "1ISK0000000000",
"reading": {
@@ -1,6 +1,5 @@
{
"__typename": "iometer.status.v1",
"installationId": "658c2b34-2017-45f2-a12b-731235f8bb97",
"meter": {
"number": "1ISK0000000000"
},
File diff suppressed because it is too large Load Diff
+1 -99
View File
@@ -12,7 +12,7 @@ from syrupy.assertion import SnapshotAssertion
from homeassistant.components.matter.binary_sensor import (
DISCOVERY_SCHEMAS as BINARY_SENSOR_SCHEMAS,
)
from homeassistant.const import EntityCategory, Platform
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
@@ -733,101 +733,3 @@ async def test_co_detector(
state = hass.states.get("binary_sensor.smart_co_sensor_carbon_monoxide")
assert state
assert state.state == "off"
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
@pytest.mark.parametrize("node_fixture", ["device_diagnostics"])
async def test_general_diagnostics_fault_sensors(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
matter_client: MagicMock,
matter_node: MatterNode,
) -> None:
"""Test GeneralDiagnostics active fault binary sensors."""
# ActiveHardwareFaults (cluster 51, attr 5) = [] (no faults)
entity_id = "binary_sensor.m5stamp_lighting_app_hardware_faults"
state = hass.states.get(entity_id)
assert state
assert state.state == "off"
entry = entity_registry.async_get(entity_id)
assert entry
assert entry.entity_category is EntityCategory.DIAGNOSTIC
# Simulate hardware fault
set_node_attribute(matter_node, 0, 51, 5, [1])
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get(entity_id)
assert state
assert state.state == "on"
# Clear faults
set_node_attribute(matter_node, 0, 51, 5, [])
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get(entity_id)
assert state
assert state.state == "off"
# ActiveRadioFaults (cluster 51, attr 6) = [] (no faults)
state = hass.states.get("binary_sensor.m5stamp_lighting_app_radio_faults")
assert state
assert state.state == "off"
set_node_attribute(matter_node, 0, 51, 6, [1])
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get("binary_sensor.m5stamp_lighting_app_radio_faults")
assert state
assert state.state == "on"
set_node_attribute(matter_node, 0, 51, 6, [])
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get("binary_sensor.m5stamp_lighting_app_radio_faults")
assert state
assert state.state == "off"
# ActiveNetworkFaults (cluster 51, attr 7) = [] (no faults)
state = hass.states.get("binary_sensor.m5stamp_lighting_app_network_faults")
assert state
assert state.state == "off"
set_node_attribute(matter_node, 0, 51, 7, [1])
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get("binary_sensor.m5stamp_lighting_app_network_faults")
assert state
assert state.state == "on"
set_node_attribute(matter_node, 0, 51, 7, [])
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get("binary_sensor.m5stamp_lighting_app_network_faults")
assert state
assert state.state == "off"
entry = entity_registry.async_get(
"binary_sensor.m5stamp_lighting_app_hardware_faults"
)
assert entry
assert entry.entity_category is EntityCategory.DIAGNOSTIC
@pytest.mark.parametrize("node_fixture", ["device_diagnostics"])
async def test_general_diagnostics_fault_sensors_disabled_by_default(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
matter_client: MagicMock,
matter_node: MatterNode,
) -> None:
"""Test GeneralDiagnostics fault binary sensors are disabled by default."""
for entity_id in (
"binary_sensor.m5stamp_lighting_app_hardware_faults",
"binary_sensor.m5stamp_lighting_app_radio_faults",
"binary_sensor.m5stamp_lighting_app_network_faults",
):
entry = entity_registry.async_get(entity_id)
assert entry, f"Expected {entity_id} to be registered"
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
-73
View File
@@ -885,76 +885,3 @@ async def test_bridged_device_reachable_updates_availability(
state = hass.states.get(entity_id)
assert state
assert state.state != STATE_UNAVAILABLE
@pytest.mark.freeze_time("2025-01-01T14:00:00+00:00")
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
@pytest.mark.parametrize("node_fixture", ["device_diagnostics"])
async def test_general_diagnostics_sensors(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
matter_client: MagicMock,
matter_node: MatterNode,
) -> None:
"""Test GeneralDiagnostics cluster sensors."""
# RebootCount (cluster 51, attr 1) = 3
state = hass.states.get("sensor.m5stamp_lighting_app_reboot_count")
assert state
assert state.state == "3"
set_node_attribute(matter_node, 0, 51, 1, 5)
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get("sensor.m5stamp_lighting_app_reboot_count")
assert state
assert state.state == "5"
entry = entity_registry.async_get("sensor.m5stamp_lighting_app_reboot_count")
assert entry
assert entry.entity_category == EntityCategory.DIAGNOSTIC
# UpTime (cluster 51, attr 2) = 213 seconds → boot at now - 213s
state = hass.states.get("sensor.m5stamp_lighting_app_uptime")
assert state
assert state.state == "2025-01-01T13:56:27+00:00"
set_node_attribute(matter_node, 0, 51, 2, 3600)
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get("sensor.m5stamp_lighting_app_uptime")
assert state
assert state.state == "2025-01-01T13:00:00+00:00"
# BootReason (cluster 51, attr 4) = 1 (PowerOnReboot)
state = hass.states.get("sensor.m5stamp_lighting_app_boot_reason")
assert state
assert state.state == "power_on_reboot"
set_node_attribute(matter_node, 0, 51, 4, 6)
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get("sensor.m5stamp_lighting_app_boot_reason")
assert state
assert state.state == "software_reset"
entry = entity_registry.async_get("sensor.m5stamp_lighting_app_boot_reason")
assert entry
assert entry.entity_category == EntityCategory.DIAGNOSTIC
@pytest.mark.parametrize("node_fixture", ["device_diagnostics"])
async def test_general_diagnostics_sensors_disabled_by_default(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
matter_client: MagicMock,
matter_node: MatterNode,
) -> None:
"""Test GeneralDiagnostics sensors are disabled by default."""
for entity_id in (
"sensor.m5stamp_lighting_app_reboot_count",
"sensor.m5stamp_lighting_app_uptime",
"sensor.m5stamp_lighting_app_boot_reason",
):
entry = entity_registry.async_get(entity_id)
assert entry, f"Expected {entity_id} to be registered"
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
@@ -246,13 +246,29 @@
'routes': list([
]),
'rssi': None,
'version': 2,
'version': 1,
'zha_lib_entities': dict({
'alarm_control_panel': list([
dict({
'info_object': dict({
'available': True,
'class_name': 'AlarmControlPanel',
'cluster_handlers': list([
dict({
'class_name': 'IasAceClientClusterHandler',
'cluster': dict({
'id': 1281,
'name': 'IAS Ancillary Control Equipment',
'type': 'client',
}),
'endpoint_id': 1,
'generic_id': 'cluster_handler_0x0501_client',
'id': '1:0x0501_client',
'status': 'INITIALIZED',
'unique_id': '**REDACTED**',
'value_attribute': None,
}),
]),
'code_arm_required': False,
'code_format': 'number',
'device_class': None,
@@ -286,6 +302,22 @@
'attribute_name': 'zone_status',
'available': True,
'class_name': 'IASZone',
'cluster_handlers': list([
dict({
'class_name': 'IASZoneClusterHandler',
'cluster': dict({
'id': 1280,
'name': 'IAS Zone',
'type': 'server',
}),
'endpoint_id': 1,
'generic_id': 'cluster_handler_0x0500',
'id': '1:0x0500',
'status': 'INITIALIZED',
'unique_id': '**REDACTED**',
'value_attribute': None,
}),
]),
'device_class': None,
'device_ieee': '**REDACTED**',
'enabled': True,
+6 -1
View File
@@ -102,7 +102,12 @@ async def test_cover(
entity_id = find_entity_id(Platform.COVER, zha_device_proxy, hass)
assert entity_id is not None
assert cluster.read_attributes.call_count == 2
assert (
not zha_device_proxy.device.endpoints[1]
.all_cluster_handlers[f"1:0x{cluster.cluster_id:04x}"]
.inverted
)
assert cluster.read_attributes.call_count == 3
assert (
WCAttrs.current_position_lift_percentage.name
in cluster.read_attributes.call_args[0][0]
+47 -2
View File
@@ -202,9 +202,12 @@ async def test_action(
await hass.async_block_till_done()
calls = async_mock_service(hass, DOMAIN, "warning_device_warn")
zigpy_device.endpoints[1].out_clusters[general.OnOff.cluster_id].listener_event(
"zha_send_event", COMMAND_SINGLE, []
cluster_handler = (
gateway.get_device(zigpy_device.ieee)
.endpoints[1]
.client_cluster_handlers["1:0x0006_client"]
)
cluster_handler.zha_send_event(COMMAND_SINGLE, [])
await hass.async_block_till_done()
assert len(calls) == 1
@@ -213,6 +216,48 @@ async def test_action(
assert calls[0].data["ieee"] == ieee_address
async def test_invalid_zha_event_type(
hass: HomeAssistant,
setup_zha: Callable[..., Coroutine[None]],
zigpy_device_mock: Callable[..., Device],
) -> None:
"""Test that unexpected types are not passed to `zha_send_event`."""
await setup_zha()
gateway = get_zha_gateway(hass)
zigpy_device = zigpy_device_mock(
{
1: {
SIG_EP_INPUT: [
general.Basic.cluster_id,
security.IasZone.cluster_id,
security.IasWd.cluster_id,
],
SIG_EP_OUTPUT: [general.OnOff.cluster_id],
SIG_EP_TYPE: zha.DeviceType.ON_OFF_SWITCH,
SIG_EP_PROFILE: zha.PROFILE_ID,
}
}
)
zigpy_device.device_automation_triggers = {
(SHORT_PRESS, SHORT_PRESS): {COMMAND: COMMAND_SINGLE}
}
gateway.get_or_create_device(zigpy_device)
await gateway.async_device_initialized(zigpy_device)
await hass.async_block_till_done(wait_background_tasks=True)
cluster_handler = (
gateway.get_device(zigpy_device.ieee)
.endpoints[1]
.client_cluster_handlers["1:0x0006_client"]
)
# `zha_send_event` accepts only zigpy responses, lists, and dicts
with pytest.raises(TypeError):
cluster_handler.zha_send_event(COMMAND_SINGLE, 123)
async def test_client_unique_id_suffix_stripped(
hass: HomeAssistant,
setup_zha: Callable[..., Coroutine[None]],
+18 -15
View File
@@ -5,7 +5,10 @@ from datetime import timedelta
from unittest.mock import ANY, call, patch
import pytest
from zha.application.platforms.siren import SirenLevel, WarningMode
from zha.application.const import (
WARNING_DEVICE_MODE_EMERGENCY_PANIC,
WARNING_DEVICE_SOUND_MEDIUM,
)
from zigpy.const import SIG_EP_INPUT, SIG_EP_OUTPUT, SIG_EP_PROFILE, SIG_EP_TYPE
from zigpy.device import Device
from zigpy.profiles import zha
@@ -105,12 +108,12 @@ async def test_siren(
False,
0,
ANY,
50, # bitmask for default args
5, # duration in seconds
0,
2,
manufacturer=None,
expect_reply=True,
warning=50, # bitmask for default args
warning_duration=5,
strobe_duty_cycle=0,
stobe_level=2,
)
]
@@ -139,12 +142,12 @@ async def test_siren(
False,
0,
ANY,
2, # bitmask for default args
5, # duration in seconds
0,
2,
manufacturer=None,
expect_reply=True,
warning=2, # bitmask for default args
warning_duration=5,
strobe_duty_cycle=0,
stobe_level=2,
)
]
@@ -170,8 +173,8 @@ async def test_siren(
{
"entity_id": entity_id,
ATTR_DURATION: 10,
ATTR_TONE: WarningMode.Emergency_Panic,
ATTR_VOLUME_LEVEL: SirenLevel.Medium_level_sound,
ATTR_TONE: WARNING_DEVICE_MODE_EMERGENCY_PANIC,
ATTR_VOLUME_LEVEL: WARNING_DEVICE_SOUND_MEDIUM,
},
blocking=True,
)
@@ -181,12 +184,12 @@ async def test_siren(
False,
0,
ANY,
97, # bitmask for passed args
10, # duration in seconds
0,
2,
manufacturer=None,
expect_reply=True,
warning=97, # bitmask for passed args
warning_duration=10,
strobe_duty_cycle=0,
stobe_level=2,
)
]
# test that the state has changed to on
+19 -16
View File
@@ -20,12 +20,8 @@ from zha.application.const import (
ATTR_TYPE,
CLUSTER_TYPE_IN,
)
from zha.zigbee.device import (
ClusterBindEvent,
ClusterConfigureReportingEvent,
Device,
DeviceConfiguredEvent,
)
from zha.zigbee.cluster_handlers import ClusterBindEvent, ClusterConfigureReportingEvent
from zha.zigbee.device import ClusterHandlerConfigurationComplete, Device
import zigpy.backups
from zigpy.const import SIG_EP_INPUT, SIG_EP_OUTPUT, SIG_EP_PROFILE, SIG_EP_TYPE
import zigpy.profiles.zha
@@ -1183,12 +1179,10 @@ async def test_websocket_reconfigure(
zha_device_proxy = get_zha_gateway_proxy(hass).get_device_proxy(zha_device.ieee)
async def mock_reinterview(ieee: EUI64) -> None:
zha_device_proxy.handle_zha_cluster_configure_reporting(
zha_device_proxy.handle_zha_channel_configure_reporting(
ClusterConfigureReportingEvent(
device_ieee=zha_device_proxy.device.ieee,
endpoint_id=1,
cluster_id=258,
cluster_name="Window Covering",
cluster_id=258,
attributes={
"current_position_lift_percentage": {
"min": 0,
@@ -1207,21 +1201,30 @@ async def test_websocket_reconfigure(
"status": "SUCCESS",
},
},
cluster_handler_unique_id="28:2c:02:bf:ff:ea:05:68:1:0x0102",
event_type="zha_channel_message",
event="zha_channel_configure_reporting",
)
)
zha_device_proxy.handle_zha_cluster_bind(
zha_device_proxy.handle_zha_channel_bind(
ClusterBindEvent(
device_ieee=zha_device_proxy.device.ieee,
endpoint_id=1,
cluster_id=1,
cluster_name="Window Covering",
cluster_id=1,
success=True,
cluster_handler_unique_id="28:2c:02:bf:ff:ea:05:68:1:0x0012",
event_type="zha_channel_message",
event="zha_channel_bind",
)
)
zha_device_proxy.handle_zha_device_configured(
DeviceConfiguredEvent(device_ieee=zha_device_proxy.device.ieee)
zha_device_proxy.handle_zha_channel_cfg_done(
ClusterHandlerConfigurationComplete(
device_ieee="28:2c:02:bf:ff:ea:05:68",
unique_id="28:2c:02:bf:ff:ea:05:68",
event_type="zha_channel_message",
event="zha_channel_cfg_done",
)
)
with patch.object(
+22 -55
View File
@@ -1,6 +1,5 @@
"""Test methods in backup_restore."""
from io import BytesIO
import json
from pathlib import Path
import tarfile
@@ -387,8 +386,8 @@ def test_restore_backup(
}
def test_restore_backup_rejects_unsafe_files(tmp_path: Path) -> None:
"""Test that a backup with unsafe paths is rejected."""
def test_restore_backup_filter_files(tmp_path: Path) -> None:
"""Test filtering dangerous files when restoring a backup."""
backup_file_path = tmp_path / "backups" / "test.tar"
backup_file_path.parent.mkdir()
get_fixture_path(
@@ -411,55 +410,7 @@ def test_restore_backup_rejects_unsafe_files(tmp_path: Path) -> None:
"data/home-assistant_v2.db-wal",
}
with (
mock.patch(
"homeassistant.backup_restore.restore_backup_file_content",
return_value=backup_restore.RestoreBackupFileContent(
backup_file_path=backup_file_path,
password=None,
remove_after_restore=False,
restore_database=True,
restore_homeassistant=True,
),
),
pytest.raises(tarfile.FilterError),
):
backup_restore.restore_backup(tmp_path.as_posix())
result = restore_result_file_content(tmp_path)
assert result is not None
assert result["success"] is False
assert result["error_type"] in {"AbsolutePathError", "OutsideDestinationError"}
def test_restore_backup_rejects_absolute_symlink(tmp_path: Path) -> None:
"""Test rejection of a symlink whose linkname escapes the destination.
A SYMTYPE entry followed by a regular file whose name traverses the
symlink would otherwise land attacker-controlled bytes outside the
extraction directory. The tar filter resolves the path after the
symlink and rejects the entry.
"""
backup_file_path = tmp_path / "backups" / "test.tar"
backup_file_path.parent.mkdir()
with tarfile.open(backup_file_path, "w") as tar:
backup_json = json.dumps(
{"homeassistant": {"version": "0.0.0"}, "compressed": False}
).encode()
info = tarfile.TarInfo(name="./backup.json")
info.size = len(backup_json)
tar.addfile(info, BytesIO(backup_json))
symlink = tarfile.TarInfo(name="pwn")
symlink.type = tarfile.SYMTYPE
symlink.linkname = "/tmp" # noqa: S108
tar.addfile(symlink)
payload = b"pwned"
evil = tarfile.TarInfo(name="pwn/ha_escape_target")
evil.size = len(payload)
tar.addfile(evil, BytesIO(payload))
real_extractone = tarfile.TarFile._extract_one
with (
mock.patch(
@@ -472,11 +423,27 @@ def test_restore_backup_rejects_absolute_symlink(tmp_path: Path) -> None:
restore_homeassistant=True,
),
),
pytest.raises(tarfile.FilterError),
mock.patch(
"tarfile.TarFile._extract_one", autospec=True, wraps=real_extractone
) as extractone_mock,
):
backup_restore.restore_backup(tmp_path.as_posix())
assert backup_restore.restore_backup(tmp_path.as_posix()) is True
assert not Path("/tmp/ha_escape_target").exists() # noqa: S108
# Check the unsafe files are not extracted, and that the safe files are extracted
extracted_files = {call.args[1].name for call in extractone_mock.mock_calls}
assert extracted_files == {
"./backup.json", # From the outer tar
"homeassistant.tar.gz", # From the outer tar
".",
"data",
"data/home-assistant_v2.db",
"data/home-assistant_v2.db-wal",
}
assert restore_result_file_content(tmp_path) == {
"error": None,
"error_type": None,
"success": True,
}
@pytest.mark.parametrize(("remove_after_restore"), [True, False])