mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-18 22:56:31 +00:00
Add discovery support for zwave_js (#2454)
* Add discovery support for zwave_js * New schema * hmm * address comments
This commit is contained in:
parent
db3fc1421c
commit
1fbc8f4060
@ -1,4 +1,4 @@
|
|||||||
"""Discovery service for Zwave MQTT."""
|
"""Discovery service for OpenZwave MQTT."""
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from supervisor.validate import network_port
|
from supervisor.validate import network_port
|
||||||
@ -8,9 +8,9 @@ from ..const import ATTR_HOST, ATTR_PASSWORD, ATTR_PORT, ATTR_USERNAME
|
|||||||
# pylint: disable=no-value-for-parameter
|
# pylint: disable=no-value-for-parameter
|
||||||
SCHEMA = vol.Schema(
|
SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Required(ATTR_HOST): vol.Coerce(str),
|
vol.Required(ATTR_HOST): str,
|
||||||
vol.Required(ATTR_PORT): network_port,
|
vol.Required(ATTR_PORT): network_port,
|
||||||
vol.Required(ATTR_USERNAME): vol.Coerce(str),
|
vol.Required(ATTR_USERNAME): str,
|
||||||
vol.Required(ATTR_PASSWORD): vol.Coerce(str),
|
vol.Required(ATTR_PASSWORD): str,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
14
supervisor/discovery/services/zwave_js.py
Normal file
14
supervisor/discovery/services/zwave_js.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
"""Discovery service for Zwave JS."""
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from supervisor.validate import network_port
|
||||||
|
|
||||||
|
from ..const import ATTR_HOST, ATTR_PORT
|
||||||
|
|
||||||
|
# pylint: disable=no-value-for-parameter
|
||||||
|
SCHEMA = vol.Schema(
|
||||||
|
{
|
||||||
|
vol.Required(ATTR_HOST): str,
|
||||||
|
vol.Required(ATTR_PORT): network_port,
|
||||||
|
}
|
||||||
|
)
|
@ -1,4 +1,4 @@
|
|||||||
"""Test Zwave MQTT discovery."""
|
"""Test OpenZwave MQTT discovery."""
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
22
tests/discovery/test_zwave_js.py
Normal file
22
tests/discovery/test_zwave_js.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
"""Test Zwave JS discovery."""
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from supervisor.discovery.validate import valid_discovery_config
|
||||||
|
|
||||||
|
|
||||||
|
def test_good_config():
|
||||||
|
"""Test good zwave js config."""
|
||||||
|
|
||||||
|
valid_discovery_config(
|
||||||
|
"zwave_js",
|
||||||
|
{"host": "test", "port": 3812},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_bad_config():
|
||||||
|
"""Test good zwave js config."""
|
||||||
|
|
||||||
|
with pytest.raises(vol.Invalid):
|
||||||
|
valid_discovery_config("zwave_js", {"host": "test"})
|
Loading…
x
Reference in New Issue
Block a user