From cee520f0b55c3a45503e8fde529115ea7ef4e879 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Thu, 29 Apr 2021 23:35:57 +0200 Subject: [PATCH] Add discovery support for motionEye (#2850) --- supervisor/discovery/const.py | 7 ++++--- supervisor/discovery/services/motioneye.py | 6 ++++++ tests/discovery/test_motioneye.py | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 supervisor/discovery/services/motioneye.py create mode 100644 tests/discovery/test_motioneye.py diff --git a/supervisor/discovery/const.py b/supervisor/discovery/const.py index 71ca1b020..fd93f010f 100644 --- a/supervisor/discovery/const.py +++ b/supervisor/discovery/const.py @@ -1,10 +1,11 @@ """Discovery static data.""" +ATTR_API_KEY = "api_key" ATTR_HOST = "host" ATTR_PASSWORD = "password" ATTR_PORT = "port" ATTR_PROTOCOL = "protocol" -ATTR_SSL = "ssl" -ATTR_USERNAME = "username" -ATTR_API_KEY = "api_key" ATTR_SERIAL = "serial" +ATTR_SSL = "ssl" +ATTR_URL = "url" +ATTR_USERNAME = "username" diff --git a/supervisor/discovery/services/motioneye.py b/supervisor/discovery/services/motioneye.py new file mode 100644 index 000000000..4edb91009 --- /dev/null +++ b/supervisor/discovery/services/motioneye.py @@ -0,0 +1,6 @@ +"""Discovery service for motionEye.""" +import voluptuous as vol + +from ..const import ATTR_URL + +SCHEMA = vol.Schema({vol.Required(ATTR_URL): vol.Coerce(str)}) diff --git a/tests/discovery/test_motioneye.py b/tests/discovery/test_motioneye.py new file mode 100644 index 000000000..00ccfadd2 --- /dev/null +++ b/tests/discovery/test_motioneye.py @@ -0,0 +1,17 @@ +"""Test motionEye discovery.""" + +import pytest +import voluptuous as vol + +from supervisor.discovery.validate import valid_discovery_config + + +def test_good_config() -> None: + """Test good motionEye config.""" + valid_discovery_config("motioneye", {"url": "http://example.com:1234"}) + + +def test_bad_config() -> None: + """Test good motionEye config.""" + with pytest.raises(vol.Invalid): + valid_discovery_config("motioneye", {})