Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add model_id and serial_number to onewire device info #135279

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions homeassistant/components/onewire/onewirehub.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,7 @@
from pyownet import protocol

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
ATTR_IDENTIFIERS,
ATTR_MANUFACTURER,
ATTR_MODEL,
ATTR_NAME,
ATTR_VIA_DEVICE,
CONF_HOST,
CONF_PORT,
)
from homeassistant.const import ATTR_VIA_DEVICE, CONF_HOST, CONF_PORT
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.device_registry import DeviceInfo
Expand Down Expand Up @@ -80,14 +72,9 @@ async def initialize(self) -> None:
# Populate the device registry
device_registry = dr.async_get(self._hass)
for device in self.devices:
device_info = device.device_info
device_registry.async_get_or_create(
config_entry_id=self._config_entry.entry_id,
identifiers=device_info[ATTR_IDENTIFIERS],
manufacturer=device_info[ATTR_MANUFACTURER],
model=device_info[ATTR_MODEL],
name=device_info[ATTR_NAME],
via_device=device_info.get(ATTR_VIA_DEVICE),
**device.device_info,
)


Expand All @@ -113,7 +100,9 @@ def _discover_devices(
identifiers={(DOMAIN, device_id)},
manufacturer=DEVICE_MANUFACTURER.get(device_family, MANUFACTURER_MAXIM),
model=device_type,
model_id=device_type,
name=device_id,
serial_number=device_id[3:],
)
if parent_id:
device_info[ATTR_VIA_DEVICE] = (DOMAIN, parent_id)
Expand Down
2 changes: 2 additions & 0 deletions tests/components/onewire/snapshots/test_diagnostics.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
]),
'manufacturer': 'Hobby Boards',
'model': 'HB_HUB',
'model_id': 'HB_HUB',
'name': 'EF.111111111113',
'serial_number': '111111111113',
}),
'family': 'EF',
'id': 'EF.111111111113',
Expand Down
84 changes: 42 additions & 42 deletions tests/components/onewire/snapshots/test_init.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
}),
'manufacturer': 'Maxim Integrated',
'model': 'DS2405',
'model_id': None,
'model_id': 'DS2405',
'name': '05.111111111111',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'serial_number': '111111111111',
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
Expand Down Expand Up @@ -53,11 +53,11 @@
}),
'manufacturer': 'Maxim Integrated',
'model': 'DS18S20',
'model_id': None,
'model_id': 'DS18S20',
'name': '10.111111111111',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'serial_number': '111111111111',
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
Expand Down Expand Up @@ -85,11 +85,11 @@
}),
'manufacturer': 'Maxim Integrated',
'model': 'DS2406',
'model_id': None,
'model_id': 'DS2406',
'name': '12.111111111111',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'serial_number': '111111111111',
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
Expand Down Expand Up @@ -117,11 +117,11 @@
}),
'manufacturer': 'Maxim Integrated',
'model': 'DS2423',
'model_id': None,
'model_id': 'DS2423',
'name': '1D.111111111111',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'serial_number': '111111111111',
'suggested_area': None,
'sw_version': None,
'via_device_id': <ANY>,
Expand Down Expand Up @@ -149,11 +149,11 @@
}),
'manufacturer': 'Maxim Integrated',
'model': 'DS2409',
'model_id': None,
'model_id': 'DS2409',
'name': '1F.111111111111',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'serial_number': '111111111111',
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
Expand Down Expand Up @@ -181,11 +181,11 @@
}),
'manufacturer': 'Maxim Integrated',
'model': 'DS1822',
'model_id': None,
'model_id': 'DS1822',
'name': '22.111111111111',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'serial_number': '111111111111',
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
Expand Down Expand Up @@ -213,11 +213,11 @@
}),
'manufacturer': 'Maxim Integrated',
'model': 'DS2438',
'model_id': None,
'model_id': 'DS2438',
'name': '26.111111111111',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'serial_number': '111111111111',
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
Expand Down Expand Up @@ -245,11 +245,11 @@
}),
'manufacturer': 'Maxim Integrated',
'model': 'DS18B20',
'model_id': None,
'model_id': 'DS18B20',
'name': '28.111111111111',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'serial_number': '111111111111',
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
Expand Down Expand Up @@ -277,11 +277,11 @@
}),
'manufacturer': 'Maxim Integrated',
'model': 'DS18B20',
'model_id': None,
'model_id': 'DS18B20',
'name': '28.222222222222',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'serial_number': '222222222222',
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
Expand Down Expand Up @@ -309,11 +309,11 @@
}),
'manufacturer': 'Maxim Integrated',
'model': 'DS18B20',
'model_id': None,
'model_id': 'DS18B20',
'name': '28.222222222223',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'serial_number': '222222222223',
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
Expand Down Expand Up @@ -341,11 +341,11 @@
}),
'manufacturer': 'Maxim Integrated',
'model': 'DS2408',
'model_id': None,
'model_id': 'DS2408',
'name': '29.111111111111',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'serial_number': '111111111111',
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
Expand Down Expand Up @@ -373,11 +373,11 @@
}),
'manufacturer': 'Maxim Integrated',
'model': 'DS2760',
'model_id': None,
'model_id': 'DS2760',
'name': '30.111111111111',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'serial_number': '111111111111',
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
Expand Down Expand Up @@ -405,11 +405,11 @@
}),
'manufacturer': 'Maxim Integrated',
'model': 'DS2413',
'model_id': None,
'model_id': 'DS2413',
'name': '3A.111111111111',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'serial_number': '111111111111',
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
Expand Down Expand Up @@ -437,11 +437,11 @@
}),
'manufacturer': 'Maxim Integrated',
'model': 'DS1825',
'model_id': None,
'model_id': 'DS1825',
'name': '3B.111111111111',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'serial_number': '111111111111',
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
Expand Down Expand Up @@ -469,11 +469,11 @@
}),
'manufacturer': 'Maxim Integrated',
'model': 'DS28EA00',
'model_id': None,
'model_id': 'DS28EA00',
'name': '42.111111111111',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'serial_number': '111111111111',
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
Expand Down Expand Up @@ -501,11 +501,11 @@
}),
'manufacturer': 'Embedded Data Systems',
'model': 'EDS0068',
'model_id': None,
'model_id': 'EDS0068',
'name': '7E.111111111111',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'serial_number': '111111111111',
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
Expand Down Expand Up @@ -533,11 +533,11 @@
}),
'manufacturer': 'Embedded Data Systems',
'model': 'EDS0066',
'model_id': None,
'model_id': 'EDS0066',
'name': '7E.222222222222',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'serial_number': '222222222222',
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
Expand Down Expand Up @@ -565,11 +565,11 @@
}),
'manufacturer': 'Maxim Integrated',
'model': 'DS2438',
'model_id': None,
'model_id': 'DS2438',
'name': 'A6.111111111111',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'serial_number': '111111111111',
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
Expand Down Expand Up @@ -597,11 +597,11 @@
}),
'manufacturer': 'Hobby Boards',
'model': 'HobbyBoards_EF',
'model_id': None,
'model_id': 'HobbyBoards_EF',
'name': 'EF.111111111111',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'serial_number': '111111111111',
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
Expand Down Expand Up @@ -629,11 +629,11 @@
}),
'manufacturer': 'Hobby Boards',
'model': 'HB_MOISTURE_METER',
'model_id': None,
'model_id': 'HB_MOISTURE_METER',
'name': 'EF.111111111112',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'serial_number': '111111111112',
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
Expand Down Expand Up @@ -661,11 +661,11 @@
}),
'manufacturer': 'Hobby Boards',
'model': 'HB_HUB',
'model_id': None,
'model_id': 'HB_HUB',
'name': 'EF.111111111113',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'serial_number': '111111111113',
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
Expand Down
14 changes: 0 additions & 14 deletions tests/components/onewire/test_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,6 @@ def override_platforms() -> Generator[None]:
yield


DEVICE_DETAILS = {
"device_info": {
"identifiers": [["onewire", "EF.111111111113"]],
"manufacturer": "Hobby Boards",
"model": "HB_HUB",
"name": "EF.111111111113",
},
"family": "EF",
"id": "EF.111111111113",
"path": "/EF.111111111113/",
"type": "HB_HUB",
}


@pytest.mark.parametrize("device_id", ["EF.111111111113"], indirect=True)
async def test_entry_diagnostics(
hass: HomeAssistant,
Expand Down