[usb_host] Allow 0x0000 VID/PID wildcards to apply to just one field

[usb_host] Fix VID/PID wildcards
This commit is contained in:
puddly
2026-09-10 18:48:05 +00:00
parent ffb4ca997e
commit 703ffbd22b
3 changed files with 67 additions and 13 deletions
@@ -70,6 +70,36 @@ from esphome.types import ConfigType
},
id="different_manufacturer",
),
pytest.param(
{
"id": "a",
"vid": 0x303A,
"pid": 0,
"manufacturer": "Nabu Casa",
"product": "ZBT-2",
},
{
"id": "b",
"vid": 0x303A,
"pid": 0x4001,
"manufacturer": "Nabu Casa",
"product": "ZWA-2",
},
id="wildcard_pid_separated_by_product",
),
pytest.param(
{
"id": "a",
"vid": 0,
"pid": 0x4001,
},
{
"id": "b",
"vid": 0x303A,
"pid": 0x4002,
},
id="wildcard_vid_different_pid",
),
],
)
def test_disjoint_clients_are_accepted(first: ConfigType, second: ConfigType) -> None:
@@ -140,6 +170,34 @@ def test_disjoint_clients_are_accepted(first: ConfigType, second: ConfigType) ->
},
id="zero_ids_match_every_device",
),
pytest.param(
{
"id": "a",
"vid": 0x303A,
"pid": 0,
},
{
"id": "b",
"vid": 0x303A,
"pid": 0x4001,
"manufacturer": "Nabu Casa",
"product": "ZBT-2",
},
id="wildcard_pid_shadows_filtered",
),
pytest.param(
{
"id": "a",
"vid": 0,
"pid": 0x4001,
},
{
"id": "b",
"vid": 0x303A,
"pid": 0,
},
id="wildcards_on_different_fields",
),
],
)
def test_overlapping_clients_are_rejected(