Raise exception instead of hide in logs on zha write (#93571)
Raise exception instead of hide in logs Write request that failed parsing of data would fail, yet display as successful in the gui.
This commit is contained in:
parent
1f0e235b99
commit
9aed5a47ae
2 changed files with 19 additions and 12 deletions
|
@ -740,9 +740,15 @@ class ZHADevice(LogMixin):
|
||||||
manufacturer=None,
|
manufacturer=None,
|
||||||
):
|
):
|
||||||
"""Write a value to a zigbee attribute for a cluster in this entity."""
|
"""Write a value to a zigbee attribute for a cluster in this entity."""
|
||||||
cluster = self.async_get_cluster(endpoint_id, cluster_id, cluster_type)
|
try:
|
||||||
if cluster is None:
|
cluster: Cluster = self.async_get_cluster(
|
||||||
return None
|
endpoint_id, cluster_id, cluster_type
|
||||||
|
)
|
||||||
|
except KeyError as exc:
|
||||||
|
raise ValueError(
|
||||||
|
f"Cluster {cluster_id} not found on endpoint {endpoint_id} while"
|
||||||
|
f" writing attribute {attribute} with value {value}"
|
||||||
|
) from exc
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = await cluster.write_attributes(
|
response = await cluster.write_attributes(
|
||||||
|
@ -758,15 +764,13 @@ class ZHADevice(LogMixin):
|
||||||
)
|
)
|
||||||
return response
|
return response
|
||||||
except zigpy.exceptions.ZigbeeException as exc:
|
except zigpy.exceptions.ZigbeeException as exc:
|
||||||
self.debug(
|
raise HomeAssistantError(
|
||||||
"failed to set attribute: %s %s %s %s %s",
|
f"Failed to set attribute: "
|
||||||
f"{ATTR_VALUE}: {value}",
|
f"{ATTR_VALUE}: {value} "
|
||||||
f"{ATTR_ATTRIBUTE}: {attribute}",
|
f"{ATTR_ATTRIBUTE}: {attribute} "
|
||||||
f"{ATTR_CLUSTER_ID}: {cluster_id}",
|
f"{ATTR_CLUSTER_ID}: {cluster_id} "
|
||||||
f"{ATTR_ENDPOINT_ID}: {endpoint_id}",
|
f"{ATTR_ENDPOINT_ID}: {endpoint_id}"
|
||||||
exc,
|
) from exc
|
||||||
)
|
|
||||||
return None
|
|
||||||
|
|
||||||
async def issue_cluster_command(
|
async def issue_cluster_command(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -1302,6 +1302,9 @@ def async_load_api(hass: HomeAssistant) -> None:
|
||||||
cluster_type=cluster_type,
|
cluster_type=cluster_type,
|
||||||
manufacturer=manufacturer,
|
manufacturer=manufacturer,
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
raise ValueError(f"Device with IEEE {str(ieee)} not found")
|
||||||
|
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
(
|
(
|
||||||
"Set attribute for: %s: [%s] %s: [%s] %s: [%s] %s: [%s] %s: [%s] %s:"
|
"Set attribute for: %s: [%s] %s: [%s] %s: [%s] %s: [%s] %s: [%s] %s:"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue