From 5120181e0e217c47cf1c291852710700b5ad11b0 Mon Sep 17 00:00:00 2001 From: Raman Gupta <7243222+raman325@users.noreply.github.com> Date: Wed, 27 Nov 2019 05:20:24 -0500 Subject: [PATCH] move facebox service to facebox domain (#29151) --- homeassistant/components/facebox/const.py | 4 ++++ .../components/facebox/image_processing.py | 4 ++-- homeassistant/components/facebox/services.yaml | 12 ++++++++++++ .../components/image_processing/services.yaml | 13 ------------- tests/components/facebox/test_image_processing.py | 8 ++++---- 5 files changed, 22 insertions(+), 19 deletions(-) create mode 100644 homeassistant/components/facebox/const.py diff --git a/homeassistant/components/facebox/const.py b/homeassistant/components/facebox/const.py new file mode 100644 index 000000000000..991ec925a981 --- /dev/null +++ b/homeassistant/components/facebox/const.py @@ -0,0 +1,4 @@ +"""Constants for the Facebox component.""" + +DOMAIN = "facebox" +SERVICE_TEACH_FACE = "teach_face" diff --git a/homeassistant/components/facebox/image_processing.py b/homeassistant/components/facebox/image_processing.py index 228cae2f19d5..ba53ac1ac7d0 100644 --- a/homeassistant/components/facebox/image_processing.py +++ b/homeassistant/components/facebox/image_processing.py @@ -15,7 +15,6 @@ from homeassistant.components.image_processing import ( CONF_SOURCE, CONF_ENTITY_ID, CONF_NAME, - DOMAIN, ) from homeassistant.const import ( CONF_IP_ADDRESS, @@ -27,6 +26,8 @@ from homeassistant.const import ( HTTP_UNAUTHORIZED, ) +from .const import DOMAIN, SERVICE_TEACH_FACE + _LOGGER = logging.getLogger(__name__) ATTR_BOUNDING_BOX = "bounding_box" @@ -38,7 +39,6 @@ FACEBOX_NAME = "name" CLASSIFIER = "facebox" DATA_FACEBOX = "facebox_classifiers" FILE_PATH = "file_path" -SERVICE_TEACH_FACE = "facebox_teach_face" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( diff --git a/homeassistant/components/facebox/services.yaml b/homeassistant/components/facebox/services.yaml index e69de29bb2d1..c6b686efb851 100644 --- a/homeassistant/components/facebox/services.yaml +++ b/homeassistant/components/facebox/services.yaml @@ -0,0 +1,12 @@ +teach_face: + description: Teach facebox a face using a file. + fields: + entity_id: + description: The facebox entity to teach. + example: 'image_processing.facebox' + name: + description: The name of the face to teach. + example: 'my_name' + file_path: + description: The path to the image file. + example: '/images/my_image.jpg' diff --git a/homeassistant/components/image_processing/services.yaml b/homeassistant/components/image_processing/services.yaml index 0689c34c1a3e..1f1fa347dc9b 100644 --- a/homeassistant/components/image_processing/services.yaml +++ b/homeassistant/components/image_processing/services.yaml @@ -6,16 +6,3 @@ scan: entity_id: description: Name(s) of entities to scan immediately. example: 'image_processing.alpr_garage' - -facebox_teach_face: - description: Teach facebox a face using a file. - fields: - entity_id: - description: The facebox entity to teach. - example: 'image_processing.facebox' - name: - description: The name of the face to teach. - example: 'my_name' - file_path: - description: The path to the image file. - example: '/images/my_image.jpg' diff --git a/tests/components/facebox/test_image_processing.py b/tests/components/facebox/test_image_processing.py index edad90e41c71..9b4610e84b0d 100644 --- a/tests/components/facebox/test_image_processing.py +++ b/tests/components/facebox/test_image_processing.py @@ -261,7 +261,7 @@ async def test_teach_service( fb.FILE_PATH: MOCK_FILE_PATH, } await hass.services.async_call( - ip.DOMAIN, fb.SERVICE_TEACH_FACE, service_data=data + fb.DOMAIN, fb.SERVICE_TEACH_FACE, service_data=data ) await hass.async_block_till_done() @@ -275,7 +275,7 @@ async def test_teach_service( fb.FILE_PATH: MOCK_FILE_PATH, } await hass.services.async_call( - ip.DOMAIN, fb.SERVICE_TEACH_FACE, service_data=data + fb.DOMAIN, fb.SERVICE_TEACH_FACE, service_data=data ) await hass.async_block_till_done() assert "AuthenticationError on facebox" in caplog.text @@ -290,7 +290,7 @@ async def test_teach_service( fb.FILE_PATH: MOCK_FILE_PATH, } await hass.services.async_call( - ip.DOMAIN, fb.SERVICE_TEACH_FACE, service_data=data + fb.DOMAIN, fb.SERVICE_TEACH_FACE, service_data=data ) await hass.async_block_till_done() assert MOCK_ERROR_NO_FACE in caplog.text @@ -305,7 +305,7 @@ async def test_teach_service( fb.FILE_PATH: MOCK_FILE_PATH, } await hass.services.async_call( - ip.DOMAIN, fb.SERVICE_TEACH_FACE, service_data=data + fb.DOMAIN, fb.SERVICE_TEACH_FACE, service_data=data ) await hass.async_block_till_done() assert "ConnectionError: Is facebox running?" in caplog.text