mirror of
https://github.com/home-assistant/core.git
synced 2026-05-28 11:43:16 +02:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d9a89beb3d | |||
| 41f783f14d | |||
| 35397b818d | |||
| d42d02f20a | |||
| 99c445f261 | |||
| 567fe85828 | |||
| fd1a5d0c5a | |||
| 632ec39d53 | |||
| 67b9d28953 | |||
| e3880eedb0 | |||
| ce64f5f902 | |||
| 0da99a50fc | |||
| 43f636be65 | |||
| 262cdbfab5 | |||
| 8cbd358435 | |||
| df04b19a0a |
@@ -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)
|
||||
|
||||
@@ -8,5 +8,5 @@
|
||||
"iot_class": "cloud_polling",
|
||||
"loggers": ["aioamazondevices"],
|
||||
"quality_scale": "platinum",
|
||||
"requirements": ["aioamazondevices==13.8.0"]
|
||||
"requirements": ["aioamazondevices==13.8.1"]
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@
|
||||
"integration_type": "hub",
|
||||
"iot_class": "cloud_push",
|
||||
"loggers": ["pubnub", "yalexs"],
|
||||
"requirements": ["yalexs==9.2.0", "yalexs-ble==3.3.0"]
|
||||
"requirements": ["yalexs==9.2.1", "yalexs-ble==3.3.0"]
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ from homeassistant.helpers.hassio import is_hassio
|
||||
|
||||
from .agent import BackupAgent, LocalBackupAgent, OnProgressCallback
|
||||
from .const import DOMAIN, LOGGER
|
||||
from .models import AgentBackup, BackupNotFound
|
||||
from .models import AgentBackup, BackupNotFound, InvalidBackupFilename
|
||||
from .util import read_backup, suggested_filename
|
||||
|
||||
|
||||
@@ -54,7 +54,13 @@ class CoreLocalBackupAgent(LocalBackupAgent):
|
||||
try:
|
||||
backup = read_backup(backup_path)
|
||||
backups[backup.backup_id] = (backup, backup_path)
|
||||
except (OSError, TarError, json.JSONDecodeError, KeyError) as err:
|
||||
except (
|
||||
OSError,
|
||||
TarError,
|
||||
json.JSONDecodeError,
|
||||
KeyError,
|
||||
InvalidBackupFilename,
|
||||
) as err:
|
||||
LOGGER.warning("Unable to read backup %s: %s", backup_path, err)
|
||||
return backups
|
||||
|
||||
@@ -122,7 +128,14 @@ class CoreLocalBackupAgent(LocalBackupAgent):
|
||||
|
||||
def get_new_backup_path(self, backup: AgentBackup) -> Path:
|
||||
"""Return the local path to a new backup."""
|
||||
return self._backup_dir / suggested_filename(backup)
|
||||
candidate = self._backup_dir / suggested_filename(backup)
|
||||
# suggested_filename does not strip separators; refuse paths that would
|
||||
# land outside the backup directory.
|
||||
if candidate.parent != self._backup_dir:
|
||||
raise InvalidBackupFilename(
|
||||
f"Refusing to write outside {self._backup_dir}: {candidate}"
|
||||
)
|
||||
return candidate
|
||||
|
||||
async def async_delete_backup(self, backup_id: str, **kwargs: Any) -> None:
|
||||
"""Delete a backup file."""
|
||||
|
||||
@@ -1978,7 +1978,13 @@ class CoreBackupReaderWriter(BackupReaderWriter):
|
||||
|
||||
try:
|
||||
backup = await async_add_executor_job(read_backup, temp_file)
|
||||
except (OSError, tarfile.TarError, json.JSONDecodeError, KeyError) as err:
|
||||
except (
|
||||
OSError,
|
||||
tarfile.TarError,
|
||||
json.JSONDecodeError,
|
||||
KeyError,
|
||||
InvalidBackupFilename,
|
||||
) as err:
|
||||
LOGGER.warning("Unable to parse backup %s: %s", temp_file, err)
|
||||
raise
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import copy
|
||||
from dataclasses import dataclass, replace
|
||||
from io import BytesIO
|
||||
import json
|
||||
from pathlib import Path, PurePath
|
||||
from pathlib import Path, PurePath, PureWindowsPath
|
||||
from queue import SimpleQueue
|
||||
import tarfile
|
||||
import threading
|
||||
@@ -34,7 +34,7 @@ from homeassistant.util.async_iterator import (
|
||||
from homeassistant.util.json import JsonObjectType, json_loads_object
|
||||
|
||||
from .const import BUF_SIZE, LOGGER, SECURETAR_CREATE_VERSION
|
||||
from .models import AddonInfo, AgentBackup, Folder
|
||||
from .models import AddonInfo, AgentBackup, Folder, InvalidBackupFilename
|
||||
|
||||
|
||||
class DecryptError(HomeAssistantError):
|
||||
@@ -109,6 +109,13 @@ def read_backup(backup_path: Path) -> AgentBackup:
|
||||
extra_metadata = cast(dict[str, bool | str], data.get("extra", {}))
|
||||
date = extra_metadata.get("supervisor.backup_request_date", data["date"])
|
||||
|
||||
name = cast(str, data["name"])
|
||||
# The name is used to derive the on-disk filename via suggested_filename;
|
||||
# reject anything that could escape the backup directory.
|
||||
safe_name = PureWindowsPath(name).name
|
||||
if safe_name != name or name in ("", ".", ".."):
|
||||
raise InvalidBackupFilename(f"Invalid backup name: {name!r}")
|
||||
|
||||
return AgentBackup(
|
||||
addons=addons,
|
||||
backup_id=cast(str, data["slug"]),
|
||||
@@ -118,7 +125,7 @@ def read_backup(backup_path: Path) -> AgentBackup:
|
||||
folders=folders,
|
||||
homeassistant_included=homeassistant_included,
|
||||
homeassistant_version=homeassistant_version,
|
||||
name=cast(str, data["name"]),
|
||||
name=name,
|
||||
protected=cast(bool, data.get("protected", False)),
|
||||
size=backup_path.stat().st_size,
|
||||
)
|
||||
|
||||
@@ -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.15",
|
||||
"dbus-fast==5.0.16",
|
||||
"habluetooth==6.7.9"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""Provide functionality to keep track of devices."""
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
from typing import TYPE_CHECKING, Any, final
|
||||
|
||||
from propcache.api import cached_property
|
||||
@@ -22,6 +23,7 @@ from homeassistant.core import (
|
||||
EventStateChangedData,
|
||||
HomeAssistant,
|
||||
State,
|
||||
async_get_hass_or_none,
|
||||
callback,
|
||||
)
|
||||
from homeassistant.helpers import (
|
||||
@@ -37,6 +39,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
from homeassistant.helpers.entity import Entity, EntityDescription
|
||||
from homeassistant.helpers.entity_platform import EntityPlatform
|
||||
from homeassistant.helpers.event import async_track_state_change_event
|
||||
from homeassistant.loader import async_suggest_report_issue
|
||||
from homeassistant.util.hass_dict import HassKey
|
||||
|
||||
from .const import (
|
||||
@@ -52,6 +55,8 @@ from .const import (
|
||||
SourceType,
|
||||
)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DATA_KEY: HassKey[dict[str, tuple[str, str]]] = HassKey(f"{DOMAIN}_mac")
|
||||
|
||||
|
||||
@@ -164,11 +169,35 @@ class BaseTrackerEntity(Entity):
|
||||
_attr_entity_category = EntityCategory.DIAGNOSTIC
|
||||
_attr_source_type: SourceType
|
||||
|
||||
def __init_subclass__(cls, **kwargs: Any) -> None:
|
||||
"""Post initialisation processing."""
|
||||
super().__init_subclass__(**kwargs)
|
||||
if "battery_level" in cls.__dict__:
|
||||
if cls.__module__.startswith("homeassistant.components."):
|
||||
# Don't ask users to report issue for built in integrations,
|
||||
# they already have issues opened on them.
|
||||
return
|
||||
report_issue = async_suggest_report_issue(
|
||||
async_get_hass_or_none(), module=cls.__module__
|
||||
)
|
||||
_LOGGER.warning(
|
||||
(
|
||||
"%s::%s is overriding the deprecated battery_level property on "
|
||||
"a subclass of BaseTrackerEntity, this will be unsupported from "
|
||||
"Home Assistant 2027.7, please %s"
|
||||
),
|
||||
cls.__module__,
|
||||
cls.__name__,
|
||||
report_issue,
|
||||
)
|
||||
|
||||
@cached_property
|
||||
def battery_level(self) -> int | None:
|
||||
"""Return the battery level of the device.
|
||||
|
||||
Percentage from 0-100.
|
||||
|
||||
The property is deprecated and will be removed in Home Assistant 2027.7.
|
||||
"""
|
||||
return None
|
||||
|
||||
@@ -212,13 +241,38 @@ class TrackerEntity(
|
||||
_attr_in_zones: list[str] | None = None
|
||||
_attr_latitude: float | None = None
|
||||
_attr_location_accuracy: float = 0
|
||||
# _attr_location_name is deprecated and will be removed in Home Assistant 2027.7
|
||||
_attr_location_name: str | None = None
|
||||
_attr_longitude: float | None = None
|
||||
_attr_source_type: SourceType = SourceType.GPS
|
||||
|
||||
__active_zone: State | None = None
|
||||
# If we reported setting deprecated _attr_location_name
|
||||
__deprecated_attr_location_name_reported = False
|
||||
__in_zones: list[str] | None = None
|
||||
|
||||
def __init_subclass__(cls, **kwargs: Any) -> None:
|
||||
"""Post initialisation processing."""
|
||||
super().__init_subclass__(**kwargs)
|
||||
if "location_name" in cls.__dict__:
|
||||
if cls.__module__.startswith("homeassistant.components."):
|
||||
# Don't ask users to report issue for built in integrations,
|
||||
# they already have issues opened on them.
|
||||
return
|
||||
report_issue = async_suggest_report_issue(
|
||||
async_get_hass_or_none(), module=cls.__module__
|
||||
)
|
||||
_LOGGER.warning(
|
||||
(
|
||||
"%s::%s is overriding the deprecated location_name property on "
|
||||
"an instance of TrackerEntity, this will be unsupported from "
|
||||
"Home Assistant 2027.7, please %s"
|
||||
),
|
||||
cls.__module__,
|
||||
cls.__name__,
|
||||
report_issue,
|
||||
)
|
||||
|
||||
@cached_property
|
||||
def should_poll(self) -> bool:
|
||||
"""No polling for entities that have location pushed."""
|
||||
@@ -249,7 +303,32 @@ class TrackerEntity(
|
||||
|
||||
@cached_property
|
||||
def location_name(self) -> str | None:
|
||||
"""Return a location name for the current location of the device."""
|
||||
"""Return a location name for the current location of the device.
|
||||
|
||||
The property is deprecated and will be removed in Home Assistant 2027.7.
|
||||
"""
|
||||
if (location_name := self._attr_location_name) is not None:
|
||||
if (
|
||||
not self.__deprecated_attr_location_name_reported
|
||||
and not self.__class__.__module__.startswith(
|
||||
"homeassistant.components."
|
||||
)
|
||||
):
|
||||
report_issue = async_suggest_report_issue(
|
||||
self.hass, module=self.__class__.__module__
|
||||
)
|
||||
_LOGGER.warning(
|
||||
(
|
||||
"%s::%s is setting the deprecated _attr_location_name attribute "
|
||||
"on an instance of TrackerEntity, this will be unsupported from "
|
||||
"Home Assistant 2027.7, please %s"
|
||||
),
|
||||
self.__class__.__module__,
|
||||
self.__class__.__name__,
|
||||
report_issue,
|
||||
)
|
||||
self.__deprecated_attr_location_name_reported = True
|
||||
return location_name
|
||||
return self._attr_location_name
|
||||
|
||||
@cached_property
|
||||
|
||||
@@ -7,6 +7,6 @@
|
||||
"integration_type": "device",
|
||||
"iot_class": "local_polling",
|
||||
"quality_scale": "bronze",
|
||||
"requirements": ["iometer==0.4.0"],
|
||||
"requirements": ["iometer==1.0.1"],
|
||||
"zeroconf": ["_iometer._tcp.local."]
|
||||
}
|
||||
|
||||
@@ -457,7 +457,14 @@ 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"
|
||||
"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,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -439,6 +439,19 @@ DISCOVERY_SCHEMAS = [
|
||||
),
|
||||
allow_multi=True, # also used for climate entity
|
||||
),
|
||||
MatterDiscoverySchema(
|
||||
platform=Platform.SENSOR,
|
||||
entity_description=MatterSensorEntityDescription(
|
||||
key="SoilMoistureSensor",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
device_class=SensorDeviceClass.MOISTURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
entity_class=MatterSensor,
|
||||
required_attributes=(
|
||||
clusters.SoilMeasurement.Attributes.SoilMoistureMeasuredValue,
|
||||
),
|
||||
),
|
||||
MatterDiscoverySchema(
|
||||
platform=Platform.SENSOR,
|
||||
entity_description=MatterSensorEntityDescription(
|
||||
|
||||
@@ -52,6 +52,11 @@ class OMIEPriceSensor(CoordinatorEntity[OMIECoordinator], SensorEntity):
|
||||
self._attr_unique_id = pyomie_series_name
|
||||
self._pyomie_series_name = pyomie_series_name
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Call when entity is added to hass."""
|
||||
await super().async_added_to_hass()
|
||||
self._handle_coordinator_update()
|
||||
|
||||
@callback
|
||||
def _handle_coordinator_update(self) -> None:
|
||||
"""Update this sensor's state from the coordinator results."""
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"iot_class": "local_push",
|
||||
"loggers": ["onvif", "wsdiscovery", "zeep"],
|
||||
"requirements": [
|
||||
"onvif-zeep-async==4.1.0",
|
||||
"onvif-zeep-async==4.1.1",
|
||||
"onvif_parsers==2.3.0",
|
||||
"WSDiscovery==2.1.2"
|
||||
]
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
"iot_class": "local_push",
|
||||
"loggers": ["wiim.sdk", "async_upnp_client"],
|
||||
"quality_scale": "bronze",
|
||||
"requirements": ["wiim==0.1.2"],
|
||||
"requirements": ["wiim==0.1.4"],
|
||||
"zeroconf": ["_linkplay._tcp.local."]
|
||||
}
|
||||
|
||||
@@ -349,15 +349,12 @@ class WiimMediaPlayerEntity(WiimBaseEntity, MediaPlayerEntity):
|
||||
sdk_status_str,
|
||||
)
|
||||
else:
|
||||
self._device.playing_status = sdk_status
|
||||
if sdk_status == SDKPlayingStatus.STOPPED:
|
||||
LOGGER.debug(
|
||||
"Device %s: TransportState is STOPPED."
|
||||
" Resetting media position and metadata",
|
||||
self.entity_id,
|
||||
)
|
||||
self._device.current_position = 0
|
||||
self._device.current_track_duration = 0
|
||||
self._attr_media_position_updated_at = None
|
||||
self._attr_media_duration = None
|
||||
self._attr_media_position = None
|
||||
|
||||
@@ -14,5 +14,5 @@
|
||||
"integration_type": "hub",
|
||||
"iot_class": "cloud_push",
|
||||
"loggers": ["socketio", "engineio", "yalexs"],
|
||||
"requirements": ["yalexs==9.2.0", "yalexs-ble==3.3.0"]
|
||||
"requirements": ["yalexs==9.2.1", "yalexs-ble==3.3.0"]
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -75,3 +75,7 @@ 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"
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -3,36 +3,26 @@
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
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 zhaquirks.inovelli.types import AllLEDEffectType, SingleLEDEffectType
|
||||
from zigpy.zcl.clusters.security import IasWd
|
||||
|
||||
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
|
||||
from .helpers import async_get_zha_device_proxy, convert_zha_error_to_ha_error
|
||||
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"
|
||||
|
||||
@@ -73,24 +63,18 @@ ACTION_SCHEMA = vol.Any(
|
||||
DEFAULT_ACTION_SCHEMA,
|
||||
)
|
||||
|
||||
DEVICE_ACTIONS = {
|
||||
CLUSTER_HANDLER_IAS_WD: [
|
||||
# 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: [
|
||||
{CONF_TYPE: ACTION_SQUAWK, CONF_DOMAIN: DOMAIN},
|
||||
{CONF_TYPE: ACTION_WARN, CONF_DOMAIN: DOMAIN},
|
||||
],
|
||||
CLUSTER_HANDLER_INOVELLI: [
|
||||
INOVELLI_CLUSTER_ID: [
|
||||
{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(
|
||||
{
|
||||
@@ -116,11 +100,6 @@ 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,
|
||||
@@ -129,9 +108,9 @@ async def async_call_action_from_config(
|
||||
context: Context | None,
|
||||
) -> None:
|
||||
"""Perform an action based on configuration."""
|
||||
await ZHA_ACTION_TYPES[DEVICE_ACTION_TYPES[config[CONF_TYPE]]](
|
||||
hass, config, variables, context
|
||||
)
|
||||
action_type = config[CONF_TYPE]
|
||||
handler = ACTION_HANDLERS[action_type]
|
||||
await handler(hass, config, context)
|
||||
|
||||
|
||||
async def async_validate_action_config(
|
||||
@@ -150,19 +129,18 @@ async def async_get_actions(
|
||||
zha_device = async_get_zha_device_proxy(hass, device_id).device
|
||||
except KeyError, AttributeError:
|
||||
return []
|
||||
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
|
||||
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
|
||||
)
|
||||
return actions
|
||||
|
||||
|
||||
@@ -175,69 +153,75 @@ async def async_get_action_capabilities(
|
||||
return {"extra_fields": fields}
|
||||
|
||||
|
||||
async def _execute_service_based_action(
|
||||
async def _execute_siren_service(
|
||||
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_name, service_data, blocking=True, context=context
|
||||
DOMAIN,
|
||||
SERVICE_NAMES[config[CONF_TYPE]],
|
||||
{ATTR_IEEE: str(zha_device.ieee)},
|
||||
blocking=True,
|
||||
context=context,
|
||||
)
|
||||
|
||||
|
||||
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]
|
||||
def _find_inovelli_cluster(hass: HomeAssistant, config: dict[str, Any]) -> Any:
|
||||
try:
|
||||
zha_device = async_get_zha_device_proxy(hass, config[CONF_DEVICE_ID]).device
|
||||
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:
|
||||
except (KeyError, AttributeError) as err:
|
||||
raise InvalidDeviceAutomationConfig(
|
||||
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}"
|
||||
)
|
||||
|
||||
f"ZHA device {config[CONF_DEVICE_ID]} not found"
|
||||
) from err
|
||||
try:
|
||||
await getattr(action_cluster_handler, action_type)(**config)
|
||||
except ZHAException as err:
|
||||
raise HomeAssistantError(err) from err
|
||||
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
|
||||
|
||||
|
||||
ZHA_ACTION_TYPES = {
|
||||
ZHA_ACTION_TYPE_SERVICE_CALL: _execute_service_based_action,
|
||||
ZHA_ACTION_TYPE_CLUSTER_HANDLER_COMMAND: (
|
||||
_execute_cluster_handler_command_based_action
|
||||
),
|
||||
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,
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -2,23 +2,23 @@
|
||||
|
||||
import asyncio
|
||||
import collections
|
||||
from collections.abc import Awaitable, Callable, Coroutine, Mapping
|
||||
from collections.abc import AsyncGenerator, Callable, Mapping
|
||||
from contextlib import asynccontextmanager
|
||||
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, Concatenate, NamedTuple, cast
|
||||
from typing import TYPE_CHECKING, Any, 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,11 +28,6 @@ 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,
|
||||
@@ -71,10 +66,11 @@ 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 (
|
||||
ClusterHandlerConfigurationComplete,
|
||||
ClusterBindEvent,
|
||||
ClusterConfigureReportingEvent,
|
||||
Device,
|
||||
DeviceConfiguredEvent,
|
||||
DeviceEntityAddedEvent,
|
||||
DeviceEntityRemovedEvent,
|
||||
DeviceFirmwareInfoUpdatedEvent,
|
||||
@@ -126,9 +122,7 @@ 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,
|
||||
@@ -144,7 +138,6 @@ from .const import (
|
||||
ATTR_ROUTES,
|
||||
ATTR_RSSI,
|
||||
ATTR_SIGNATURE,
|
||||
ATTR_SUCCESS,
|
||||
CONF_ALARM_ARM_REQUIRES_CODE,
|
||||
CONF_ALARM_FAILED_TRIES,
|
||||
CONF_ALARM_MASTER_CODE,
|
||||
@@ -168,6 +161,7 @@ from .const import (
|
||||
DEFAULT_DATABASE_NAME,
|
||||
DEVICE_PAIRING_STATUS,
|
||||
DOMAIN,
|
||||
SIGNAL_DEVICE_RECONFIGURE_EVENT,
|
||||
ZHA_ALARM_OPTIONS,
|
||||
ZHA_OPTIONS,
|
||||
)
|
||||
@@ -450,50 +444,46 @@ class ZHADeviceProxy(EventBase):
|
||||
)
|
||||
|
||||
@callback
|
||||
def handle_zha_channel_configure_reporting(
|
||||
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(
|
||||
self, event: ClusterConfigureReportingEvent
|
||||
) -> None:
|
||||
"""Handle a ZHA cluster configure reporting event."""
|
||||
"""Forward a cluster reporting-configured result to the reconfigure websocket."""
|
||||
async_dispatcher_send(
|
||||
self.gateway_proxy.hass,
|
||||
ZHA_CLUSTER_HANDLER_MSG,
|
||||
SIGNAL_DEVICE_RECONFIGURE_EVENT,
|
||||
{
|
||||
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,
|
||||
"type": "zha_channel_configure_reporting",
|
||||
"zha_channel_msg_data": {
|
||||
"cluster_name": event.cluster_name,
|
||||
"cluster_id": event.cluster_id,
|
||||
"attributes": event.attributes,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
@callback
|
||||
def handle_zha_channel_cfg_done(
|
||||
self, event: ClusterHandlerConfigurationComplete
|
||||
) -> None:
|
||||
"""Handle a ZHA cluster configure reporting event."""
|
||||
def handle_zha_device_configured(self, event: DeviceConfiguredEvent) -> None:
|
||||
"""Forward the device configuration-complete signal to the reconfigure websocket."""
|
||||
async_dispatcher_send(
|
||||
self.gateway_proxy.hass,
|
||||
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,
|
||||
},
|
||||
},
|
||||
SIGNAL_DEVICE_RECONFIGURE_EVENT,
|
||||
{"type": "zha_channel_cfg_done"},
|
||||
)
|
||||
|
||||
@callback
|
||||
@@ -501,6 +491,9 @@ 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
|
||||
@@ -515,6 +508,9 @@ 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(
|
||||
@@ -911,6 +907,9 @@ 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
|
||||
@@ -918,6 +917,9 @@ 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,
|
||||
@@ -1386,19 +1388,24 @@ def create_zha_config(hass: HomeAssistant, ha_zha_data: HAZHAData) -> ZHAData:
|
||||
)
|
||||
|
||||
|
||||
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]]:
|
||||
@asynccontextmanager
|
||||
async def convert_zha_error_to_ha_error() -> AsyncGenerator[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"
|
||||
|
||||
@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
|
||||
if str(exc):
|
||||
message = f"{message}: {exc}"
|
||||
|
||||
return handler
|
||||
raise HomeAssistantError(message) from exc
|
||||
except ZHAException as err:
|
||||
raise HomeAssistantError(err) from err
|
||||
|
||||
|
||||
def exclude_none_values(obj: Mapping[str, Any]) -> dict[str, Any]:
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"universal_silabs_flasher",
|
||||
"serialx"
|
||||
],
|
||||
"requirements": ["zha==1.3.1"],
|
||||
"requirements": ["zha==1.4.0"],
|
||||
"usb": [
|
||||
{
|
||||
"description": "*2652*",
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -3,15 +3,10 @@
|
||||
import functools
|
||||
from typing import Any
|
||||
|
||||
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,
|
||||
WarningMode,
|
||||
)
|
||||
from zha.application.platforms.siren import SirenEntityFeature as ZHASirenEntityFeature
|
||||
|
||||
from homeassistant.components.siren import (
|
||||
ATTR_DURATION,
|
||||
@@ -59,12 +54,12 @@ class ZHASiren(ZHAEntity, SirenEntity):
|
||||
"""Representation of a ZHA siren."""
|
||||
|
||||
_attr_available_tones: list[int | str] | dict[int, str] | None = {
|
||||
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",
|
||||
WarningMode.Burglar: "Burglar",
|
||||
WarningMode.Fire: "Fire",
|
||||
WarningMode.Emergency: "Emergency",
|
||||
WarningMode.Police_Panic: "Police Panic",
|
||||
WarningMode.Fire_Panic: "Fire Panic",
|
||||
WarningMode.Emergency_Panic: "Emergency Panic",
|
||||
}
|
||||
|
||||
def __init__(self, entity_data: EntityData, **kwargs: Any) -> None:
|
||||
@@ -92,7 +87,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(
|
||||
@@ -102,7 +97,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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -29,12 +29,6 @@ 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
|
||||
@@ -44,7 +38,14 @@ from zha.application.helpers import (
|
||||
get_matched_clusters,
|
||||
qr_to_install_code,
|
||||
)
|
||||
from zha.zigbee.cluster_handlers.const import CLUSTER_HANDLER_IAS_WD
|
||||
from zha.application.platforms.siren import (
|
||||
BaseSiren,
|
||||
SirenLevel,
|
||||
SquawkMode,
|
||||
Strobe,
|
||||
StrobeLevel,
|
||||
WarningMode,
|
||||
)
|
||||
from zha.zigbee.group import GroupMemberReference
|
||||
import zigpy.backups
|
||||
from zigpy.config import CONF_DEVICE
|
||||
@@ -59,7 +60,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
|
||||
from homeassistant.const import ATTR_COMMAND, ATTR_ID, ATTR_NAME, Platform
|
||||
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
|
||||
@@ -79,6 +80,7 @@ from .const import (
|
||||
GROUP_IDS,
|
||||
GROUP_NAME,
|
||||
MFG_CLUSTER_ID_START,
|
||||
SIGNAL_DEVICE_RECONFIGURE_EVENT,
|
||||
ZHA_ALARM_OPTIONS,
|
||||
ZHA_OPTIONS,
|
||||
)
|
||||
@@ -180,13 +182,13 @@ SERVICE_SCHEMAS: dict[str, VolSchemaType] = {
|
||||
{
|
||||
vol.Required(ATTR_IEEE): IEEE_SCHEMA,
|
||||
vol.Optional(
|
||||
ATTR_WARNING_DEVICE_MODE, default=WARNING_DEVICE_SQUAWK_MODE_ARMED
|
||||
ATTR_WARNING_DEVICE_MODE, default=SquawkMode.Armed
|
||||
): cv.positive_int,
|
||||
vol.Optional(
|
||||
ATTR_WARNING_DEVICE_STROBE, default=WARNING_DEVICE_STROBE_YES
|
||||
ATTR_WARNING_DEVICE_STROBE, default=Strobe.Strobe
|
||||
): cv.positive_int,
|
||||
vol.Optional(
|
||||
ATTR_LEVEL, default=WARNING_DEVICE_SOUND_HIGH
|
||||
ATTR_LEVEL, default=SirenLevel.High_level_sound
|
||||
): cv.positive_int,
|
||||
}
|
||||
),
|
||||
@@ -194,20 +196,21 @@ SERVICE_SCHEMAS: dict[str, VolSchemaType] = {
|
||||
{
|
||||
vol.Required(ATTR_IEEE): IEEE_SCHEMA,
|
||||
vol.Optional(
|
||||
ATTR_WARNING_DEVICE_MODE, default=WARNING_DEVICE_MODE_EMERGENCY
|
||||
ATTR_WARNING_DEVICE_MODE, default=WarningMode.Emergency
|
||||
): cv.positive_int,
|
||||
vol.Optional(
|
||||
ATTR_WARNING_DEVICE_STROBE, default=WARNING_DEVICE_STROBE_YES
|
||||
ATTR_WARNING_DEVICE_STROBE, default=Strobe.Strobe
|
||||
): cv.positive_int,
|
||||
vol.Optional(
|
||||
ATTR_LEVEL, default=WARNING_DEVICE_SOUND_HIGH
|
||||
ATTR_LEVEL, default=SirenLevel.High_level_sound
|
||||
): 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=WARNING_DEVICE_STROBE_HIGH
|
||||
ATTR_WARNING_DEVICE_STROBE_INTENSITY,
|
||||
default=StrobeLevel.High_level_strobe,
|
||||
): cv.positive_int,
|
||||
}
|
||||
),
|
||||
@@ -424,10 +427,7 @@ async def websocket_get_groupable_devices(
|
||||
),
|
||||
}
|
||||
for entity_ref in entity_refs
|
||||
if list(entity_ref.entity_data.entity.cluster_handlers.values())[
|
||||
0
|
||||
].cluster.endpoint.endpoint_id
|
||||
== ep_id
|
||||
if entity_ref.entity_data.entity.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, ZHA_CLUSTER_HANDLER_MSG, forward_messages
|
||||
hass, SIGNAL_DEVICE_RECONFIGURE_EVENT, forward_messages
|
||||
)
|
||||
|
||||
@callback
|
||||
@@ -1480,15 +1480,6 @@ 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]
|
||||
@@ -1496,31 +1487,10 @@ def async_load_api(hass: HomeAssistant) -> None:
|
||||
strobe: int = service.data[ATTR_WARNING_DEVICE_STROBE]
|
||||
level: int = service.data[ATTR_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,
|
||||
)
|
||||
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)
|
||||
|
||||
async_register_admin_service(
|
||||
hass,
|
||||
@@ -1540,32 +1510,16 @@ 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]
|
||||
|
||||
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,
|
||||
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,
|
||||
)
|
||||
|
||||
async_register_admin_service(
|
||||
|
||||
@@ -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}"
|
||||
|
||||
@@ -30,7 +30,7 @@ certifi>=2021.5.30
|
||||
ciso8601==2.3.3
|
||||
cronsim==2.7
|
||||
cryptography==48.0.0
|
||||
dbus-fast==5.0.15
|
||||
dbus-fast==5.0.16
|
||||
file-read-backwards==2.0.0
|
||||
fnv-hash-fast==2.0.3
|
||||
go2rtc-client==0.4.0
|
||||
|
||||
+1
-1
@@ -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."
|
||||
|
||||
Generated
+7
-7
@@ -190,7 +190,7 @@ aioairzone-cloud==0.7.2
|
||||
aioairzone==1.0.5
|
||||
|
||||
# homeassistant.components.alexa_devices
|
||||
aioamazondevices==13.8.0
|
||||
aioamazondevices==13.8.1
|
||||
|
||||
# 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.15
|
||||
dbus-fast==5.0.16
|
||||
|
||||
# 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==0.4.0
|
||||
iometer==1.0.1
|
||||
|
||||
# homeassistant.components.iotty
|
||||
iottycloud==0.3.0
|
||||
@@ -1737,7 +1737,7 @@ ondilo==0.5.0
|
||||
onedrive-personal-sdk==0.1.7
|
||||
|
||||
# homeassistant.components.onvif
|
||||
onvif-zeep-async==4.1.0
|
||||
onvif-zeep-async==4.1.1
|
||||
|
||||
# homeassistant.components.onvif
|
||||
onvif_parsers==2.3.0
|
||||
@@ -3357,7 +3357,7 @@ whois==0.9.27
|
||||
wiffi==1.1.2
|
||||
|
||||
# homeassistant.components.wiim
|
||||
wiim==0.1.2
|
||||
wiim==0.1.4
|
||||
|
||||
# homeassistant.components.wirelesstag
|
||||
wirelesstagpy==0.8.1
|
||||
@@ -3403,7 +3403,7 @@ yalexs-ble==3.3.0
|
||||
|
||||
# homeassistant.components.august
|
||||
# homeassistant.components.yale
|
||||
yalexs==9.2.0
|
||||
yalexs==9.2.1
|
||||
|
||||
# homeassistant.components.yeelight
|
||||
yeelight==0.7.16
|
||||
@@ -3442,7 +3442,7 @@ zeroconf==0.149.16
|
||||
zeversolar==0.3.2
|
||||
|
||||
# homeassistant.components.zha
|
||||
zha==1.3.1
|
||||
zha==1.4.0
|
||||
|
||||
# homeassistant.components.zhong_hong
|
||||
zhong-hong-hvac==1.0.13
|
||||
|
||||
@@ -2088,6 +2088,36 @@ async def test_receive_backup_path_traversal(
|
||||
assert resp.status == 400
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"name",
|
||||
[
|
||||
"/absolute/path",
|
||||
"../parent",
|
||||
"with/slash",
|
||||
],
|
||||
)
|
||||
async def test_receive_backup_rejects_unsafe_inner_name(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
name: str,
|
||||
) -> None:
|
||||
"""Test receive backup rejects an inner name that would escape the backup dir."""
|
||||
await setup_backup_integration(hass)
|
||||
client = await hass_client()
|
||||
|
||||
backup = replace(TEST_BACKUP_ABC123, name=name)
|
||||
with patch(
|
||||
"homeassistant.components.backup.manager.read_backup",
|
||||
return_value=backup,
|
||||
):
|
||||
resp = await client.post(
|
||||
"/api/backup/upload?agent_id=backup.local",
|
||||
data={"file": StringIO("test")},
|
||||
)
|
||||
|
||||
assert resp.status == 400
|
||||
|
||||
|
||||
async def test_receive_backup_busy_manager(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
|
||||
@@ -14,6 +14,7 @@ import pytest
|
||||
import securetar
|
||||
|
||||
from homeassistant.components.backup import DOMAIN, AddonInfo, AgentBackup, Folder
|
||||
from homeassistant.components.backup.models import InvalidBackupFilename
|
||||
from homeassistant.components.backup.util import (
|
||||
DecryptedBackupStreamer,
|
||||
EncryptedBackupStreamer,
|
||||
@@ -158,6 +159,37 @@ def test_read_backup(backup_json_content: bytes, expected_backup: AgentBackup) -
|
||||
assert backup == expected_backup
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"name",
|
||||
[
|
||||
"/absolute/path",
|
||||
"../parent",
|
||||
"with/slash",
|
||||
"with\\backslash",
|
||||
"C:\\drive\\path",
|
||||
"",
|
||||
".",
|
||||
"..",
|
||||
],
|
||||
)
|
||||
def test_read_backup_rejects_unsafe_name(name: str) -> None:
|
||||
"""Test that read_backup rejects names that could escape the backup directory."""
|
||||
backup_json_content = (
|
||||
b'{"compressed":true,"date":"2024-12-02T07:23:58.261875-05:00","homeassistant":'
|
||||
b'{"exclude_database":true,"version":"2024.12.0.dev0"},"name":"'
|
||||
+ name.encode().replace(b"\\", b"\\\\")
|
||||
+ b'","protected":true,"slug":"455645fe","type":"partial","version":2}'
|
||||
)
|
||||
mock_path = Mock()
|
||||
mock_path.stat.return_value.st_size = 1234
|
||||
|
||||
with patch("homeassistant.components.backup.util.tarfile.open") as mock_open_tar:
|
||||
tar_ctx = mock_open_tar.return_value.__enter__.return_value
|
||||
tar_ctx.extractfile.return_value.read.return_value = backup_json_content
|
||||
with pytest.raises(InvalidBackupFilename):
|
||||
read_backup(mock_path)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("backup", "password", "validation_result", "expected_messages"),
|
||||
[
|
||||
|
||||
@@ -1379,6 +1379,101 @@ def test_base_tracker_entity() -> None:
|
||||
entity.state_attributes # noqa: B018
|
||||
|
||||
|
||||
def test_battery_level_override_deprecation_warning(
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test that overriding battery_level in a subclass logs a warning."""
|
||||
error_message = "is overriding the deprecated battery_level property"
|
||||
|
||||
caplog.clear()
|
||||
|
||||
class _SubclassWithOverride(TrackerEntity):
|
||||
@property
|
||||
def battery_level(self) -> int | None:
|
||||
return 50
|
||||
|
||||
assert error_message in caplog.text
|
||||
assert _SubclassWithOverride.__name__ in caplog.text
|
||||
|
||||
# No warning for a subclass that does not override battery_level
|
||||
caplog.clear()
|
||||
|
||||
class _SubclassWithoutOverride(TrackerEntity):
|
||||
pass
|
||||
|
||||
assert error_message not in caplog.text
|
||||
|
||||
|
||||
async def test_attr_location_name_deprecation_warning(
|
||||
hass: HomeAssistant,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test that setting _attr_location_name logs a deprecation warning."""
|
||||
error_message = "is setting the deprecated _attr_location_name attribute"
|
||||
|
||||
class _Subclass(TrackerEntity):
|
||||
pass
|
||||
|
||||
# No warning when _attr_location_name is unset (default None)
|
||||
entity_no_attr = _Subclass()
|
||||
entity_no_attr.hass = hass
|
||||
assert entity_no_attr.location_name is None
|
||||
assert error_message not in caplog.text
|
||||
|
||||
# Warning fires when _attr_location_name has a non-None value
|
||||
entity = _Subclass()
|
||||
entity.hass = hass
|
||||
entity._attr_location_name = "the_zone"
|
||||
caplog.clear()
|
||||
assert entity.location_name == "the_zone"
|
||||
assert error_message in caplog.text
|
||||
|
||||
# Warning does not fire again on subsequent access for the same instance
|
||||
caplog.clear()
|
||||
assert entity.location_name == "the_zone"
|
||||
assert error_message not in caplog.text
|
||||
|
||||
# Warning is suppressed for this instance even after the cached value is
|
||||
# invalidated by a subsequent _attr_location_name assignment.
|
||||
entity._attr_location_name = "another_zone"
|
||||
caplog.clear()
|
||||
assert entity.location_name == "another_zone"
|
||||
assert error_message not in caplog.text
|
||||
|
||||
# A fresh instance warns once again
|
||||
entity_new = _Subclass()
|
||||
entity_new.hass = hass
|
||||
entity_new._attr_location_name = "the_zone"
|
||||
caplog.clear()
|
||||
assert entity_new.location_name == "the_zone"
|
||||
assert error_message in caplog.text
|
||||
|
||||
|
||||
def test_location_name_override_deprecation_warning(
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test that overriding location_name in a subclass logs a warning."""
|
||||
error_message = "is overriding the deprecated location_name property"
|
||||
|
||||
caplog.clear()
|
||||
|
||||
class _SubclassWithOverride(TrackerEntity):
|
||||
@property
|
||||
def location_name(self) -> str | None:
|
||||
return "custom"
|
||||
|
||||
assert error_message in caplog.text
|
||||
assert _SubclassWithOverride.__name__ in caplog.text
|
||||
|
||||
# No warning for a subclass that does not override location_name
|
||||
caplog.clear()
|
||||
|
||||
class _SubclassWithoutOverride(TrackerEntity):
|
||||
pass
|
||||
|
||||
assert error_message not in caplog.text
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("mac_address", "unique_id"), [(TEST_MAC_ADDRESS, f"{TEST_MAC_ADDRESS}_yo1")]
|
||||
)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"__typename": "iometer.reading.v1",
|
||||
"installationId": "658c2b34-2017-45f2-a12b-731235f8bb97",
|
||||
"meter": {
|
||||
"number": "1ISK0000000000",
|
||||
"reading": {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"__typename": "iometer.status.v1",
|
||||
"installationId": "658c2b34-2017-45f2-a12b-731235f8bb97",
|
||||
"meter": {
|
||||
"number": "1ISK0000000000"
|
||||
},
|
||||
|
||||
@@ -78,6 +78,7 @@ FIXTURES = [
|
||||
"mock_pressure_sensor",
|
||||
"mock_pump",
|
||||
"mock_room_airconditioner",
|
||||
"mock_soil_sensor",
|
||||
"mock_solar_inverter",
|
||||
"mock_speaker",
|
||||
"mock_switch_unit",
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
{
|
||||
"node_id": 101,
|
||||
"date_commissioned": "2024-11-27T00:00:00.000000",
|
||||
"last_interview": "2024-11-27T00:00:00.000000",
|
||||
"interview_version": 2,
|
||||
"attributes": {
|
||||
"0/29/0": [
|
||||
{
|
||||
"0": 22,
|
||||
"1": 1
|
||||
}
|
||||
],
|
||||
"0/29/1": [
|
||||
4, 29, 31, 40, 42, 43, 44, 48, 49, 50, 51, 52, 53, 54, 55, 59, 60, 62, 63,
|
||||
64, 65
|
||||
],
|
||||
"0/29/2": [41],
|
||||
"0/29/3": [1],
|
||||
"0/29/65532": 0,
|
||||
"0/29/65533": 1,
|
||||
"0/29/65528": [],
|
||||
"0/29/65529": [],
|
||||
"0/29/65531": [0, 1, 2, 3, 65528, 65529, 65531, 65532, 65533],
|
||||
"0/40/0": 1,
|
||||
"0/40/1": "Nabu Casa",
|
||||
"0/40/2": 65521,
|
||||
"0/40/3": "Mock SoilSensor",
|
||||
"0/40/4": 32768,
|
||||
"0/40/5": "Mock Soil Sensor",
|
||||
"0/40/6": "XX",
|
||||
"0/40/7": 0,
|
||||
"0/40/8": "v1.0",
|
||||
"0/40/9": 1,
|
||||
"0/40/10": "v1.0",
|
||||
"0/40/11": "20241127",
|
||||
"0/40/12": "",
|
||||
"0/40/13": "",
|
||||
"0/40/14": "",
|
||||
"0/40/15": "TEST_SN",
|
||||
"0/40/16": false,
|
||||
"0/40/17": true,
|
||||
"0/40/18": "mock-soil-sensor",
|
||||
"0/40/19": {
|
||||
"0": 3,
|
||||
"1": 3
|
||||
},
|
||||
"0/40/65532": 0,
|
||||
"0/40/65533": 1,
|
||||
"0/40/65528": [],
|
||||
"0/40/65529": [],
|
||||
"0/40/65531": [
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
|
||||
65528, 65529, 65531, 65532, 65533
|
||||
],
|
||||
"1/3/65529": [0, 64],
|
||||
"1/3/65531": [0, 1, 65528, 65529, 65531, 65532, 65533],
|
||||
"1/29/0": [
|
||||
{
|
||||
"0": 69,
|
||||
"1": 1
|
||||
}
|
||||
],
|
||||
"1/29/1": [3, 29, 57, 1072, 40],
|
||||
"1/29/2": [],
|
||||
"1/29/3": [9, 10],
|
||||
"1/29/65532": null,
|
||||
"1/29/65533": 1,
|
||||
"1/29/65528": [],
|
||||
"1/29/65529": [],
|
||||
"1/29/65531": [0, 1, 2, 3, 65528, 65529, 65531, 65532, 65533],
|
||||
"1/1072/0": {
|
||||
"0": 17,
|
||||
"1": true,
|
||||
"2": 0,
|
||||
"3": 100,
|
||||
"4": []
|
||||
},
|
||||
"1/1072/1": 50,
|
||||
"1/1072/65532": 0,
|
||||
"1/1072/65533": 1,
|
||||
"1/1072/65528": [],
|
||||
"1/1072/65529": [],
|
||||
"1/1072/65531": [0, 1, 65528, 65529, 65531, 65532, 65533]
|
||||
},
|
||||
"available": true,
|
||||
"attribute_subscriptions": []
|
||||
}
|
||||
@@ -18619,6 +18619,61 @@
|
||||
'state': '0.0',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[mock_soil_sensor][sensor.mock_soil_sensor_moisture-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': list([
|
||||
None,
|
||||
]),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'sensor',
|
||||
'entity_category': None,
|
||||
'entity_id': 'sensor.mock_soil_sensor_moisture',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'object_id_base': 'Moisture',
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <SensorDeviceClass.MOISTURE: 'moisture'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Moisture',
|
||||
'platform': 'matter',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': None,
|
||||
'unique_id': '00000000000004D2-0000000000000065-MatterNodeDevice-1-SoilMoistureSensor-1072-1',
|
||||
'unit_of_measurement': '%',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[mock_soil_sensor][sensor.mock_soil_sensor_moisture-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'moisture',
|
||||
'friendly_name': 'Mock Soil Sensor Moisture',
|
||||
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
'unit_of_measurement': '%',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.mock_soil_sensor_moisture',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '50',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[mock_solar_inverter][sensor.mock_solar_inverter_active_current-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': list([
|
||||
|
||||
@@ -85,6 +85,25 @@ async def test_humidity_sensor(
|
||||
assert state.state == "40.0"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("node_fixture", ["mock_soil_sensor"])
|
||||
async def test_soil_moisture_sensor(
|
||||
hass: HomeAssistant,
|
||||
matter_client: MagicMock,
|
||||
matter_node: MatterNode,
|
||||
) -> None:
|
||||
"""Test soil moisture sensor."""
|
||||
state = hass.states.get("sensor.mock_soil_sensor_moisture")
|
||||
assert state
|
||||
assert state.state == "50"
|
||||
|
||||
set_node_attribute(matter_node, 1, 1072, 1, 75)
|
||||
await trigger_subscription_callback(hass, matter_client)
|
||||
|
||||
state = hass.states.get("sensor.mock_soil_sensor_moisture")
|
||||
assert state
|
||||
assert state.state == "75"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("node_fixture", ["mock_light_sensor"])
|
||||
async def test_light_sensor(
|
||||
hass: HomeAssistant,
|
||||
|
||||
@@ -10,35 +10,35 @@ import pytest
|
||||
|
||||
from homeassistant.const import STATE_UNAVAILABLE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from . import spot_price_fetcher
|
||||
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
|
||||
|
||||
@freeze_time("2024-01-15T14:01:00Z")
|
||||
async def test_sensor_setup(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_pyomie: MagicMock,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_omie_results_jan15: OMIEResults,
|
||||
) -> None:
|
||||
"""Test sensor platform setup."""
|
||||
mock_pyomie.spot_price.side_effect = spot_price_fetcher(
|
||||
{
|
||||
"2024-01-15": mock_omie_results_jan15,
|
||||
}
|
||||
)
|
||||
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
entities = er.async_entries_for_config_entry(
|
||||
entity_registry, mock_config_entry.entry_id
|
||||
)
|
||||
|
||||
# Should have 2 sensors (PT and ES)
|
||||
assert len(entities) == 2
|
||||
|
||||
unique_ids = {entity.unique_id for entity in entities}
|
||||
expected_ids = {"pt_spot_price", "es_spot_price"}
|
||||
assert unique_ids == expected_ids
|
||||
assert (pt_state := hass.states.get("sensor.omie_portugal_spot_price"))
|
||||
assert (es_state := hass.states.get("sensor.omie_spain_spot_price"))
|
||||
assert pt_state.state == "351151500.0"
|
||||
assert es_state.state == "34151500.0"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("hass_lisbon")
|
||||
|
||||
@@ -38,5 +38,6 @@ async def fire_transport_update(
|
||||
"""Trigger the registered AVTransport callback on the mock device."""
|
||||
assert mock_device.av_transport_event_callback is not None
|
||||
mock_device.event_data = {"TransportState": transport_state.value}
|
||||
mock_device.playing_status = transport_state
|
||||
mock_device.av_transport_event_callback(MagicMock(), [])
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@@ -246,29 +246,13 @@
|
||||
'routes': list([
|
||||
]),
|
||||
'rssi': None,
|
||||
'version': 1,
|
||||
'version': 2,
|
||||
'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,
|
||||
@@ -302,22 +286,6 @@
|
||||
'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,
|
||||
|
||||
@@ -102,12 +102,7 @@ async def test_cover(
|
||||
entity_id = find_entity_id(Platform.COVER, zha_device_proxy, hass)
|
||||
assert entity_id is not None
|
||||
|
||||
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 cluster.read_attributes.call_count == 2
|
||||
assert (
|
||||
WCAttrs.current_position_lift_percentage.name
|
||||
in cluster.read_attributes.call_args[0][0]
|
||||
|
||||
@@ -202,12 +202,9 @@ async def test_action(
|
||||
await hass.async_block_till_done()
|
||||
calls = async_mock_service(hass, DOMAIN, "warning_device_warn")
|
||||
|
||||
cluster_handler = (
|
||||
gateway.get_device(zigpy_device.ieee)
|
||||
.endpoints[1]
|
||||
.client_cluster_handlers["1:0x0006_client"]
|
||||
zigpy_device.endpoints[1].out_clusters[general.OnOff.cluster_id].listener_event(
|
||||
"zha_send_event", COMMAND_SINGLE, []
|
||||
)
|
||||
cluster_handler.zha_send_event(COMMAND_SINGLE, [])
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(calls) == 1
|
||||
@@ -216,48 +213,6 @@ 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]],
|
||||
|
||||
@@ -5,10 +5,7 @@ from datetime import timedelta
|
||||
from unittest.mock import ANY, call, patch
|
||||
|
||||
import pytest
|
||||
from zha.application.const import (
|
||||
WARNING_DEVICE_MODE_EMERGENCY_PANIC,
|
||||
WARNING_DEVICE_SOUND_MEDIUM,
|
||||
)
|
||||
from zha.application.platforms.siren import SirenLevel, WarningMode
|
||||
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
|
||||
@@ -108,12 +105,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,
|
||||
)
|
||||
]
|
||||
|
||||
@@ -142,12 +139,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,
|
||||
)
|
||||
]
|
||||
|
||||
@@ -173,8 +170,8 @@ async def test_siren(
|
||||
{
|
||||
"entity_id": entity_id,
|
||||
ATTR_DURATION: 10,
|
||||
ATTR_TONE: WARNING_DEVICE_MODE_EMERGENCY_PANIC,
|
||||
ATTR_VOLUME_LEVEL: WARNING_DEVICE_SOUND_MEDIUM,
|
||||
ATTR_TONE: WarningMode.Emergency_Panic,
|
||||
ATTR_VOLUME_LEVEL: SirenLevel.Medium_level_sound,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
@@ -184,12 +181,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
|
||||
|
||||
@@ -20,8 +20,12 @@ from zha.application.const import (
|
||||
ATTR_TYPE,
|
||||
CLUSTER_TYPE_IN,
|
||||
)
|
||||
from zha.zigbee.cluster_handlers import ClusterBindEvent, ClusterConfigureReportingEvent
|
||||
from zha.zigbee.device import ClusterHandlerConfigurationComplete, Device
|
||||
from zha.zigbee.device import (
|
||||
ClusterBindEvent,
|
||||
ClusterConfigureReportingEvent,
|
||||
Device,
|
||||
DeviceConfiguredEvent,
|
||||
)
|
||||
import zigpy.backups
|
||||
from zigpy.const import SIG_EP_INPUT, SIG_EP_OUTPUT, SIG_EP_PROFILE, SIG_EP_TYPE
|
||||
import zigpy.profiles.zha
|
||||
@@ -1179,10 +1183,12 @@ 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_channel_configure_reporting(
|
||||
zha_device_proxy.handle_zha_cluster_configure_reporting(
|
||||
ClusterConfigureReportingEvent(
|
||||
cluster_name="Window Covering",
|
||||
device_ieee=zha_device_proxy.device.ieee,
|
||||
endpoint_id=1,
|
||||
cluster_id=258,
|
||||
cluster_name="Window Covering",
|
||||
attributes={
|
||||
"current_position_lift_percentage": {
|
||||
"min": 0,
|
||||
@@ -1201,30 +1207,21 @@ 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_channel_bind(
|
||||
zha_device_proxy.handle_zha_cluster_bind(
|
||||
ClusterBindEvent(
|
||||
cluster_name="Window Covering",
|
||||
device_ieee=zha_device_proxy.device.ieee,
|
||||
endpoint_id=1,
|
||||
cluster_id=1,
|
||||
cluster_name="Window Covering",
|
||||
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_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",
|
||||
)
|
||||
zha_device_proxy.handle_zha_device_configured(
|
||||
DeviceConfiguredEvent(device_ieee=zha_device_proxy.device.ieee)
|
||||
)
|
||||
|
||||
with patch.object(
|
||||
|
||||
Reference in New Issue
Block a user