Use UsbServiceInfo in zwave-js (#60267)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-11-24 14:51:28 +01:00 committed by GitHub
parent 3bf12fcd29
commit 5a8cbb8cab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 30 deletions

View File

@ -345,12 +345,12 @@ class ConfigFlow(BaseZwaveJSFlow, config_entries.ConfigFlow, domain=DOMAIN):
if self._async_in_progress(): if self._async_in_progress():
return self.async_abort(reason="already_in_progress") return self.async_abort(reason="already_in_progress")
vid = discovery_info["vid"] vid = discovery_info.vid
pid = discovery_info["pid"] pid = discovery_info.pid
serial_number = discovery_info["serial_number"] serial_number = discovery_info.serial_number
device = discovery_info["device"] device = discovery_info.device
manufacturer = discovery_info["manufacturer"] manufacturer = discovery_info.manufacturer
description = discovery_info["description"] description = discovery_info.description
# Zooz uses this vid/pid, but so do 2652 sticks # Zooz uses this vid/pid, but so do 2652 sticks
if vid == "10C4" and pid == "EA60" and description and "2652" in description: if vid == "10C4" and pid == "EA60" and description and "2652" in description:
return self.async_abort(reason="not_zwave_device") return self.async_abort(reason="not_zwave_device")

View File

@ -7,6 +7,7 @@ import pytest
from zwave_js_server.version import VersionInfo from zwave_js_server.version import VersionInfo
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components import usb
from homeassistant.components.hassio.handler import HassioAPIError from homeassistant.components.hassio.handler import HassioAPIError
from homeassistant.components.zwave_js.config_flow import SERVER_VERSION_TIMEOUT, TITLE from homeassistant.components.zwave_js.config_flow import SERVER_VERSION_TIMEOUT, TITLE
from homeassistant.components.zwave_js.const import DOMAIN from homeassistant.components.zwave_js.const import DOMAIN
@ -20,32 +21,32 @@ ADDON_DISCOVERY_INFO = {
} }
USB_DISCOVERY_INFO = { USB_DISCOVERY_INFO = usb.UsbServiceInfo(
"device": "/dev/zwave", device="/dev/zwave",
"pid": "AAAA", pid="AAAA",
"vid": "AAAA", vid="AAAA",
"serial_number": "1234", serial_number="1234",
"description": "zwave radio", description="zwave radio",
"manufacturer": "test", manufacturer="test",
} )
NORTEK_ZIGBEE_DISCOVERY_INFO = { NORTEK_ZIGBEE_DISCOVERY_INFO = usb.UsbServiceInfo(
"device": "/dev/zigbee", device="/dev/zigbee",
"pid": "8A2A", pid="8A2A",
"vid": "10C4", vid="10C4",
"serial_number": "1234", serial_number="1234",
"description": "nortek zigbee radio", description="nortek zigbee radio",
"manufacturer": "nortek", manufacturer="nortek",
} )
CP2652_ZIGBEE_DISCOVERY_INFO = { CP2652_ZIGBEE_DISCOVERY_INFO = usb.UsbServiceInfo(
"device": "/dev/zigbee", device="/dev/zigbee",
"pid": "EA60", pid="EA60",
"vid": "10C4", vid="10C4",
"serial_number": "", serial_number="",
"description": "cp2652", description="cp2652",
"manufacturer": "generic", manufacturer="generic",
} )
@pytest.fixture(name="setup_entry") @pytest.fixture(name="setup_entry")