Skip to content

Commit

Permalink
Bump Matter SDK to 1.2.0.0 (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt authored Oct 24, 2023
1 parent a940f1b commit 916677a
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 14 deletions.
10 changes: 5 additions & 5 deletions matter_server/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,24 +175,24 @@ async def get_matter_fabrics(self, node_id: int) -> list[MatterFabricData]:

node = self.get_node(node_id)
fabrics: list[
Clusters.OperationalCredentials.Structs.FabricDescriptor
Clusters.OperationalCredentials.Structs.FabricDescriptorStruct
] = node.get_attribute_value(
0, None, Clusters.OperationalCredentials.Attributes.Fabrics
)

vendors_map = await self.send_command(
APICommand.GET_VENDOR_NAMES,
require_schema=3,
filter_vendors=[f.vendorId for f in fabrics],
filter_vendors=[f.vendorID for f in fabrics],
)

return [
MatterFabricData(
fabric_id=f.fabricId,
vendor_id=f.vendorId,
fabric_id=f.fabricID,
vendor_id=f.vendorID,
fabric_index=f.fabricIndex,
fabric_label=f.label if f.label else None,
vendor_name=vendors_map.get(str(f.vendorId)),
vendor_name=vendors_map.get(str(f.vendorID)),
)
for f in fabrics
]
Expand Down
129 changes: 128 additions & 1 deletion matter_server/client/models/device_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ class DoorLock(DeviceType, device_type=0x000A):
clusters = {
all_clusters.Identify,
all_clusters.Descriptor,
all_clusters.Binding,
all_clusters.DoorLock,
}

Expand Down Expand Up @@ -561,6 +560,134 @@ class ModeSelect(DeviceType, device_type=0x0027):
}


class RoomAirConditioner(DeviceType, device_type=0x0072):
"""Room Air Conditioner."""

clusters = {
all_clusters.Identify,
all_clusters.OnOff,
all_clusters.Descriptor,
all_clusters.Groups,
all_clusters.Scenes,
all_clusters.Thermostat,
all_clusters.FanControl,
all_clusters.TemperatureMeasurement,
all_clusters.RelativeHumidityMeasurement,
}


class SmokeCoAlarm(DeviceType, device_type=0x0076):
"""Smoke CO Alarm."""

clusters = {
all_clusters.Descriptor,
all_clusters.Identify,
all_clusters.Groups,
all_clusters.SmokeCoAlarm,
all_clusters.RelativeHumidityMeasurement,
all_clusters.TemperatureMeasurement,
all_clusters.CarbonMonoxideConcentrationMeasurement,
all_clusters.PowerSource,
}


class AirPurifier(DeviceType, device_type=0x002D):
"""Air Purifier."""

clusters = {
all_clusters.Descriptor,
all_clusters.Identify,
all_clusters.Groups,
all_clusters.FanControl,
all_clusters.HepaFilterMonitoring,
all_clusters.ActivatedCarbonFilterMonitoring,
}


class AirQualitySensor(DeviceType, device_type=0x002C):
"""Air Quality Sensor."""

clusters = {
all_clusters.Descriptor,
all_clusters.Identify,
all_clusters.AirQuality,
all_clusters.TemperatureMeasurement,
all_clusters.RelativeHumidityMeasurement,
all_clusters.CarbonMonoxideConcentrationMeasurement,
all_clusters.CarbonDioxideConcentrationMeasurement,
all_clusters.NitrogenDioxideConcentrationMeasurement,
all_clusters.OzoneConcentrationMeasurement,
all_clusters.FormaldehydeConcentrationMeasurement,
all_clusters.Pm1ConcentrationMeasurement,
all_clusters.Pm25ConcentrationMeasurement,
all_clusters.Pm10ConcentrationMeasurement,
all_clusters.RadonConcentrationMeasurement,
all_clusters.TotalVolatileOrganicCompoundsConcentrationMeasurement,
}


class Dishwasher(DeviceType, device_type=0x0075):
"""Dishwasher."""

clusters = {
all_clusters.Identify,
all_clusters.OnOff,
all_clusters.Descriptor,
all_clusters.TemperatureControl,
all_clusters.DishwasherMode,
all_clusters.DishwasherAlarm,
all_clusters.OperationalState,
}


class Refrigerator(DeviceType, device_type=0x0070):
"""Refrigerator."""

clusters = {
all_clusters.Identify,
all_clusters.Descriptor,
all_clusters.RefrigeratorAndTemperatureControlledCabinetMode,
all_clusters.RefrigeratorAlarm,
}


class LaundryWasher(DeviceType, device_type=0x0073):
"""Laundry Washer."""

clusters = {
all_clusters.Identify,
all_clusters.Descriptor,
all_clusters.OnOff,
all_clusters.LaundryWasherMode,
all_clusters.LaundryWasherControls,
all_clusters.TemperatureControl,
all_clusters.OperationalState,
}


class RoboticVacuumCleaner(DeviceType, device_type=0x0074):
"""Robotic Vacuum Cleaner."""

clusters = {
all_clusters.Identify,
all_clusters.Descriptor,
all_clusters.RvcRunMode,
all_clusters.RvcCleanMode,
all_clusters.RvcOperationalState,
}


class TemperatureControlledCabinet(DeviceType, device_type=0x0071):
"""Temperature Controlled Cabinet."""

clusters = {
all_clusters.Descriptor,
all_clusters.TemperatureControl,
all_clusters.TemperatureMeasurement,
all_clusters.RefrigeratorAndTemperatureControlledCabinetMode,
}


class AllClustersAppServerExample(DeviceType, device_type=0x0000):
"""All-clusters-app Server Example."""

Expand Down
8 changes: 5 additions & 3 deletions matter_server/client/models/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ def is_composed_device(self) -> bool:
return self.node.get_compose_parent(self.endpoint_id) is not None

@property
def device_info(self) -> Clusters.BasicInformation | Clusters.BridgedDeviceBasic:
def device_info(
self,
) -> Clusters.BasicInformation | Clusters.BridgedDeviceBasicInformation:
"""
Return device info.
Expand Down Expand Up @@ -169,15 +171,15 @@ def set_attribute_value(self, attribute_path: str, attribute_value: Any) -> None
Do not modify the data directly from a consumer.
"""
_, cluster_id, attribute_id = parse_attribute_path(attribute_path)
cluster_class: Clusters.Cluster = ALL_CLUSTERS[cluster_id]
cluster_class: type[Clusters.Cluster] = ALL_CLUSTERS[cluster_id]
if cluster_id in self.clusters:
cluster_instance = self.clusters[cluster_id]
else:
cluster_instance = cluster_class()
self.clusters[cluster_id] = cluster_instance

# unpack cluster attribute, using the descriptor
attribute_class: Clusters.ClusterAttributeDescriptor = ALL_ATTRIBUTES[
attribute_class: type[Clusters.ClusterAttributeDescriptor] = ALL_ATTRIBUTES[
cluster_id
][attribute_id]
attribute_name, attribute_type = get_object_params(
Expand Down
2 changes: 1 addition & 1 deletion matter_server/common/helpers/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@


def create_attribute_path_from_attribute(
endpoint_id: int, attribute: ClusterAttributeDescriptor
endpoint_id: int, attribute: type[ClusterAttributeDescriptor]
) -> str:
"""Create path/identifier for an Attribute."""
return create_attribute_path(
Expand Down
4 changes: 2 additions & 2 deletions matter_server/server/device_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from datetime import datetime
from functools import partial
import logging
from typing import TYPE_CHECKING, Any, Callable, Deque, Iterable, Type, TypeVar, cast
from typing import TYPE_CHECKING, Any, Callable, Iterable, Type, TypeVar, cast

from chip.ChipDeviceCtrl import CommissionableNode
from chip.clusters import Attribute, Objects as Clusters
Expand Down Expand Up @@ -73,7 +73,7 @@ def __init__(
"""Initialize the device controller."""
self.server = server
# we keep the last events in memory so we can include them in the diagnostics dump
self.event_history: Deque[Attribute.EventReadResult] = deque(maxlen=25)
self.event_history: deque[Attribute.EventReadResult] = deque(maxlen=25)
self._subscriptions: dict[int, Attribute.SubscriptionTransaction] = {}
self._attr_subscriptions: dict[int, list[tuple[Any, ...]] | str] = {}
self._resub_debounce_timer: dict[int, asyncio.TimerHandle] = {}
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ dependencies = [
"coloredlogs",
"dacite",
"orjson",
"home-assistant-chip-clusters==2023.10.0b1"
"home-assistant-chip-clusters==2023.10.1"
]

[project.optional-dependencies]
server = [
"home-assistant-chip-core==2023.10.0b1",
"home-assistant-chip-core==2023.10.1",
"cryptography==41.0.4"
]
test = [
Expand Down
4 changes: 4 additions & 0 deletions scripts/generate_devices.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ def __init_subclass__(cls, *, device_type: int, **kwargs: typing.Any) -> None:
cls.device_type = device_type
ALL_TYPES[device_type] = cls
def __hash__(self) -> int:
"""Return unique hash for this object."""
return self.device_type
'''
]

Expand Down

0 comments on commit 916677a

Please sign in to comment.