From f7609e9cb15795a434de3b622604387e2af840cd Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 1 Oct 2017 23:18:10 -0700 Subject: [PATCH] Move group services into their own YAML (#9597) * Move group services into their own YAML * Fix lint * Move persistent notification to package --- .../{group.py => group/__init__.py} | 8 +- homeassistant/components/group/services.yaml | 59 +++++++++++++ .../__init__.py} | 4 +- .../persistent_notification/services.yaml | 23 +++++ homeassistant/components/services.yaml | 85 ------------------- tests/components/group/__init__.py | 1 + .../{test_group.py => group/test_init.py} | 0 .../persistent_notification/__init__.py | 1 + .../test_init.py} | 0 9 files changed, 90 insertions(+), 91 deletions(-) rename homeassistant/components/{group.py => group/__init__.py} (98%) create mode 100644 homeassistant/components/group/services.yaml rename homeassistant/components/{persistent_notification.py => persistent_notification/__init__.py} (96%) create mode 100644 homeassistant/components/persistent_notification/services.yaml create mode 100644 tests/components/group/__init__.py rename tests/components/{test_group.py => group/test_init.py} (100%) create mode 100644 tests/components/persistent_notification/__init__.py rename tests/components/{test_persistent_notification.py => persistent_notification/test_init.py} (100%) diff --git a/homeassistant/components/group.py b/homeassistant/components/group/__init__.py similarity index 98% rename from homeassistant/components/group.py rename to homeassistant/components/group/__init__.py index fb910109d7c..0bc1fa46c4c 100644 --- a/homeassistant/components/group.py +++ b/homeassistant/components/group/__init__.py @@ -269,7 +269,7 @@ def async_setup(hass, config): hass.services.async_register( DOMAIN, SERVICE_RELOAD, reload_service_handler, - descriptions[DOMAIN][SERVICE_RELOAD], schema=RELOAD_SERVICE_SCHEMA) + descriptions[SERVICE_RELOAD], schema=RELOAD_SERVICE_SCHEMA) @asyncio.coroutine def groups_service_handler(service): @@ -346,11 +346,11 @@ def async_setup(hass, config): hass.services.async_register( DOMAIN, SERVICE_SET, groups_service_handler, - descriptions[DOMAIN][SERVICE_SET], schema=SET_SERVICE_SCHEMA) + descriptions[SERVICE_SET], schema=SET_SERVICE_SCHEMA) hass.services.async_register( DOMAIN, SERVICE_REMOVE, groups_service_handler, - descriptions[DOMAIN][SERVICE_REMOVE], schema=REMOVE_SERVICE_SCHEMA) + descriptions[SERVICE_REMOVE], schema=REMOVE_SERVICE_SCHEMA) @asyncio.coroutine def visibility_service_handler(service): @@ -368,7 +368,7 @@ def async_setup(hass, config): hass.services.async_register( DOMAIN, SERVICE_SET_VISIBILITY, visibility_service_handler, - descriptions[DOMAIN][SERVICE_SET_VISIBILITY], + descriptions[SERVICE_SET_VISIBILITY], schema=SET_VISIBILITY_SERVICE_SCHEMA) return True diff --git a/homeassistant/components/group/services.yaml b/homeassistant/components/group/services.yaml new file mode 100644 index 00000000000..2447392c3b7 --- /dev/null +++ b/homeassistant/components/group/services.yaml @@ -0,0 +1,59 @@ +reload: + description: "Reload group configuration." + +set_visibility: + description: Hide or show a group + + fields: + entity_id: + description: Name(s) of entities to set value + example: 'group.travel' + + visible: + description: True if group should be shown or False if it should be hidden. + example: True + +set: + description: Create/Update a user group + + fields: + object_id: + description: Group id and part of entity id + example: 'test_group' + + name: + description: Name of group + example: 'My test group' + + view: + description: Boolean for if the group is a view + example: True + + icon: + description: Name of icon for the group + example: 'mdi:camera' + + control: + description: Value for control the group control + example: 'hidden' + + visible: + description: If the group is visible on UI + example: True + + entities: + description: List of all members in the group. Not compatible with 'delta' + example: domain.entity_id1, domain.entity_id2 + + add_entities: + description: List of members they will change on group listening. + example: domain.entity_id1, domain.entity_id2 + +remove: + description: Remove a user group + + fields: + object_id: + description: Group id and part of entity id + example: 'test_group' + diff --git a/homeassistant/components/persistent_notification.py b/homeassistant/components/persistent_notification/__init__.py similarity index 96% rename from homeassistant/components/persistent_notification.py rename to homeassistant/components/persistent_notification/__init__.py index 5e68aeee3ab..0c4674f89cc 100644 --- a/homeassistant/components/persistent_notification.py +++ b/homeassistant/components/persistent_notification/__init__.py @@ -129,11 +129,11 @@ def async_setup(hass, config): ) hass.services.async_register(DOMAIN, SERVICE_CREATE, create_service, - descriptions[DOMAIN][SERVICE_CREATE], + descriptions[SERVICE_CREATE], SCHEMA_SERVICE_CREATE) hass.services.async_register(DOMAIN, SERVICE_DISMISS, dismiss_service, - descriptions[DOMAIN][SERVICE_DISMISS], + descriptions[SERVICE_DISMISS], SCHEMA_SERVICE_DISMISS) return True diff --git a/homeassistant/components/persistent_notification/services.yaml b/homeassistant/components/persistent_notification/services.yaml new file mode 100644 index 00000000000..2a10f9c8499 --- /dev/null +++ b/homeassistant/components/persistent_notification/services.yaml @@ -0,0 +1,23 @@ +create: + description: Show a notification in the frontend + + fields: + message: + description: Message body of the notification. [Templates accepted] + example: Please check your configuration.yaml. + + title: + description: Optional title for your notification. [Optional, Templates accepted] + example: Test notification + + notification_id: + description: Target ID of the notification, will replace a notification with the same Id. [Optional] + example: 1234 + +dismiss: + description: Remove a notification from the frontend + + fields: + notification_id: + description: Target ID of the notification, which should be removed. [Required] + example: 1234 diff --git a/homeassistant/components/services.yaml b/homeassistant/components/services.yaml index 69a5982caeb..9fd47d84fa0 100644 --- a/homeassistant/components/services.yaml +++ b/homeassistant/components/services.yaml @@ -40,91 +40,6 @@ foursquare: description: Vertical accuracy of the user's location, in meters. example: 1 -group: - reload: - description: "Reload group configuration." - - set_visibility: - description: Hide or show a group - - fields: - entity_id: - description: Name(s) of entities to set value - example: 'group.travel' - - visible: - description: True if group should be shown or False if it should be hidden. - example: True - - set: - description: Create/Update a user group - - fields: - object_id: - description: Group id and part of entity id - example: 'test_group' - - name: - description: Name of group - example: 'My test group' - - view: - description: Boolean for if the group is a view - example: True - - icon: - description: Name of icon for the group - example: 'mdi:camera' - - control: - description: Value for control the group control - example: 'hidden' - - visible: - description: If the group is visible on UI - example: True - - entities: - description: List of all members in the group. Not compatible with 'delta' - example: domain.entity_id1, domain.entity_id2 - - add_entities: - description: List of members they will change on group listening. - example: domain.entity_id1, domain.entity_id2 - - remove: - description: Remove a user group - - fields: - object_id: - description: Group id and part of entity id - example: 'test_group' - -persistent_notification: - create: - description: Show a notification in the frontend - - fields: - message: - description: Message body of the notification. [Templates accepted] - example: Please check your configuration.yaml. - - title: - description: Optional title for your notification. [Optional, Templates accepted] - example: Test notification - - notification_id: - description: Target ID of the notification, will replace a notification with the same Id. [Optional] - example: 1234 - - dismiss: - description: Remove a notification from the frontend - - fields: - notification_id: - description: Target ID of the notification, which should be removed. [Required] - example: 1234 - homematic: virtualkey: description: Press a virtual key from CCU/Homegear or simulate keypress diff --git a/tests/components/group/__init__.py b/tests/components/group/__init__.py new file mode 100644 index 00000000000..d69449d3c75 --- /dev/null +++ b/tests/components/group/__init__.py @@ -0,0 +1 @@ +"""Tests for the group component.""" diff --git a/tests/components/test_group.py b/tests/components/group/test_init.py similarity index 100% rename from tests/components/test_group.py rename to tests/components/group/test_init.py diff --git a/tests/components/persistent_notification/__init__.py b/tests/components/persistent_notification/__init__.py new file mode 100644 index 00000000000..667002b5ed4 --- /dev/null +++ b/tests/components/persistent_notification/__init__.py @@ -0,0 +1 @@ +"""Test the persistent notification component.""" diff --git a/tests/components/test_persistent_notification.py b/tests/components/persistent_notification/test_init.py similarity index 100% rename from tests/components/test_persistent_notification.py rename to tests/components/persistent_notification/test_init.py