diff --git a/homeassistant/components/onewire/onewirehub.py b/homeassistant/components/onewire/onewirehub.py index 2ee99597a27..0d25a546941 100644 --- a/homeassistant/components/onewire/onewirehub.py +++ b/homeassistant/components/onewire/onewirehub.py @@ -148,8 +148,7 @@ class OneWireHub: device_id = os.path.split(os.path.split(device_path)[0])[1] device_family = self.owproxy.read(f"{device_path}family").decode() _LOGGER.debug("read `%sfamily`: %s", device_path, device_family) - device_type = self.owproxy.read(f"{device_path}type").decode() - _LOGGER.debug("read `%stype`: %s", device_path, device_type) + device_type = self._get_device_type_owserver(device_path) device_info: DeviceInfo = { ATTR_IDENTIFIERS: {(DOMAIN, device_id)}, ATTR_MANUFACTURER: DEVICE_MANUFACTURER.get( @@ -176,6 +175,19 @@ class OneWireHub: return devices + def _get_device_type_owserver(self, device_path: str) -> str: + """Get device model.""" + if TYPE_CHECKING: + assert self.owproxy + device_type = self.owproxy.read(f"{device_path}type").decode() + _LOGGER.debug("read `%stype`: %s", device_path, device_type) + if device_type == "EDS": + device_type = self.owproxy.read(f"{device_path}device_type").decode() + _LOGGER.debug("read `%sdevice_type`: %s", device_path, device_type) + if TYPE_CHECKING: + assert isinstance(device_type, str) + return device_type + def has_device_in_cache(self, device: DeviceEntry) -> bool: """Check if device was present in the cache.""" if TYPE_CHECKING: diff --git a/homeassistant/components/onewire/sensor.py b/homeassistant/components/onewire/sensor.py index c13dcd4ebf3..7efa082d482 100644 --- a/homeassistant/components/onewire/sensor.py +++ b/homeassistant/components/onewire/sensor.py @@ -395,7 +395,7 @@ def get_entities( family = device_type elif "7E" in family: device_sub_type = "EDS" - family = onewirehub.owproxy.read(f"{device_path}device_type").decode() + family = device_type if family not in get_sensor_types(device_sub_type): _LOGGER.warning( diff --git a/tests/components/onewire/const.py b/tests/components/onewire/const.py index 1cd4babd263..777cb1f3d25 100644 --- a/tests/components/onewire/const.py +++ b/tests/components/onewire/const.py @@ -801,7 +801,7 @@ MOCK_OWPROXY_DEVICES = { ATTR_DEVICE_INFO: { ATTR_IDENTIFIERS: {(DOMAIN, "7E.111111111111")}, ATTR_MANUFACTURER: MANUFACTURER_EDS, - ATTR_MODEL: "EDS", + ATTR_MODEL: "EDS0068", ATTR_NAME: "7E.111111111111", }, SENSOR_DOMAIN: [ @@ -851,7 +851,7 @@ MOCK_OWPROXY_DEVICES = { ATTR_DEVICE_INFO: { ATTR_IDENTIFIERS: {(DOMAIN, "7E.222222222222")}, ATTR_MANUFACTURER: MANUFACTURER_EDS, - ATTR_MODEL: "EDS", + ATTR_MODEL: "EDS0066", ATTR_NAME: "7E.222222222222", }, SENSOR_DOMAIN: [