mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Code styling tweaks to the Matter integration (#86096)
This commit is contained in:
parent
cf68d081ca
commit
bd1c476edf
@ -104,7 +104,10 @@ class MatterAdapter:
|
|||||||
name = "Hub device"
|
name = "Hub device"
|
||||||
elif not name and device_type_instances:
|
elif not name and device_type_instances:
|
||||||
# fallback name based on device type
|
# fallback name based on device type
|
||||||
name = f"{device_type_instances[0].device_type.__doc__[:-1]} {node_device.node().node_id}"
|
name = (
|
||||||
|
f"{device_type_instances[0].device_type.__doc__[:-1]}"
|
||||||
|
f" {node_device.node().node_id}"
|
||||||
|
)
|
||||||
|
|
||||||
dr.async_get(self.hass).async_get_or_create(
|
dr.async_get(self.hass).async_get_or_create(
|
||||||
name=name,
|
name=name,
|
||||||
|
@ -113,7 +113,7 @@ class MatterEntity(Entity):
|
|||||||
|
|
||||||
@callback
|
@callback
|
||||||
def get_matter_attribute(self, attribute: type) -> MatterAttribute | None:
|
def get_matter_attribute(self, attribute: type) -> MatterAttribute | None:
|
||||||
"""Lookup MatterAttribute instance on device instance by providing the attribute class."""
|
"""Lookup MatterAttribute on device by providing the attribute class."""
|
||||||
return next(
|
return next(
|
||||||
(
|
(
|
||||||
x
|
x
|
||||||
|
@ -29,8 +29,8 @@ class MatterEntryData:
|
|||||||
def get_matter(hass: HomeAssistant) -> MatterAdapter:
|
def get_matter(hass: HomeAssistant) -> MatterAdapter:
|
||||||
"""Return MatterAdapter instance."""
|
"""Return MatterAdapter instance."""
|
||||||
# NOTE: This assumes only one Matter connection/fabric can exist.
|
# NOTE: This assumes only one Matter connection/fabric can exist.
|
||||||
# Shall we support connecting to multiple servers in the client or by config entries?
|
# Shall we support connecting to multiple servers in the client or by
|
||||||
# In case of the config entry we need to fix this.
|
# config entries? In case of the config entry we need to fix this.
|
||||||
matter_entry_data: MatterEntryData = next(iter(hass.data[DOMAIN].values()))
|
matter_entry_data: MatterEntryData = next(iter(hass.data[DOMAIN].values()))
|
||||||
return matter_entry_data.adapter
|
return matter_entry_data.adapter
|
||||||
|
|
||||||
@ -42,8 +42,8 @@ def get_operational_instance_id(
|
|||||||
"""Return `Operational Instance Name` for given MatterNode."""
|
"""Return `Operational Instance Name` for given MatterNode."""
|
||||||
fabric_id_hex = f"{server_info.compressed_fabric_id:016X}"
|
fabric_id_hex = f"{server_info.compressed_fabric_id:016X}"
|
||||||
node_id_hex = f"{node.node_id:016X}"
|
node_id_hex = f"{node.node_id:016X}"
|
||||||
# operational instance id matches the mdns advertisement for the node
|
# Operational instance id matches the mDNS advertisement for the node
|
||||||
# this is the recommended ID to recognize a unique matter node (within a fabric)
|
# this is the recommended ID to recognize a unique matter node (within a fabric).
|
||||||
return f"{fabric_id_hex}-{node_id_hex}"
|
return f"{fabric_id_hex}-{node_id_hex}"
|
||||||
|
|
||||||
|
|
||||||
@ -55,5 +55,6 @@ def get_device_id(
|
|||||||
operational_instance_id = get_operational_instance_id(
|
operational_instance_id = get_operational_instance_id(
|
||||||
server_info, node_device.node()
|
server_info, node_device.node()
|
||||||
)
|
)
|
||||||
# append nodedevice(type) to differentiate between a root node and bridge within HA devices.
|
# Append nodedevice(type) to differentiate between a root node
|
||||||
|
# and bridge within Home Assistant devices.
|
||||||
return f"{operational_instance_id}-{node_device.__class__.__name__}"
|
return f"{operational_instance_id}-{node_device.__class__.__name__}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user