Adjust onewire device model (#58516)

Co-authored-by: epenet <epenet@users.noreply.github.com>
pull/56474/head
epenet 2021-10-27 19:19:55 +02:00 committed by GitHub
parent baaaf3d2bc
commit b85217c62e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 5 deletions

View File

@ -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:

View File

@ -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(

View File

@ -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: [