From 4b8f976edeb6a6e5deefda567cc9951a27055494 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Fri, 2 Oct 2026 09:02:29 +0200 Subject: [PATCH] Fix onewire setup with devices missing a type (#183973) Co-authored-by: Claude Opus 5.5 --- homeassistant/components/onewire/onewirehub.py | 4 ++-- tests/components/onewire/const.py | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/onewire/onewirehub.py b/homeassistant/components/onewire/onewirehub.py index 67ce60476b4c..1dba2e549582 100644 --- a/homeassistant/components/onewire/onewirehub.py +++ b/homeassistant/components/onewire/onewirehub.py @@ -6,7 +6,7 @@ import logging import os from aio_ownet.definitions import OWServerCommonPath -from aio_ownet.exceptions import OWServerProtocolError, OWServerReturnError +from aio_ownet.exceptions import OWServerReturnError from aio_ownet.proxy import OWServerStatelessProxy from homeassistant.config_entries import ConfigEntry @@ -181,7 +181,7 @@ async def _get_device_type( """Get device model.""" try: device_type = (await owproxy.read(f"{device_path}type")).decode() - except OWServerProtocolError as exc: + except OWServerReturnError as exc: _LOGGER.debug("Unable to read `%stype`: %s", device_path, exc) return None _LOGGER.debug("read `%stype`: %s", device_path, device_type) diff --git a/tests/components/onewire/const.py b/tests/components/onewire/const.py index 74b7c9c4d572..505367813659 100644 --- a/tests/components/onewire/const.py +++ b/tests/components/onewire/const.py @@ -1,6 +1,6 @@ """Constants for 1-Wire integration.""" -from aio_ownet.exceptions import OWServerProtocolError +from aio_ownet.exceptions import OWServerProtocolError, OWServerReturnError ATTR_INJECT_READS = "inject_reads" @@ -54,7 +54,15 @@ MOCK_OWPROXY_DEVICES = { }, "16.111111111111": { # Test case for issue #115984, where the device type cannot be read - ATTR_INJECT_READS: {"/type": [OWServerProtocolError()]}, + ATTR_INJECT_READS: { + "/type": [ + OWServerReturnError( + 1, + "Startup - command line parameters invalid", + "/16.111111111111/type", + ) + ] + }, }, "1F.111111111111": { ATTR_INJECT_READS: {"/type": [b"DS2409"]},