From 11a89bc3ac54270b61993ce4588e16516664daf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Wed, 24 Feb 2021 17:02:48 +0100 Subject: [PATCH] Add addon selector (#46789) --- homeassistant/components/hassio/services.yaml | 101 ++++++++---------- homeassistant/helpers/selector.py | 7 ++ tests/helpers/test_selector.py | 9 ++ 3 files changed, 62 insertions(+), 55 deletions(-) diff --git a/homeassistant/components/hassio/services.yaml b/homeassistant/components/hassio/services.yaml index 8afdcc633bf..3570a857c55 100644 --- a/homeassistant/components/hassio/services.yaml +++ b/homeassistant/components/hassio/services.yaml @@ -1,110 +1,101 @@ -addon_install: - description: Install a Hass.io docker add-on. - fields: - addon: - description: The add-on slug. - example: core_ssh - version: - description: Optional or it will be use the latest version. - example: "0.2" - addon_start: - description: Start a Hass.io docker add-on. + name: Start add-on + description: Start add-on. fields: addon: + name: Add-on + required: true description: The add-on slug. example: core_ssh + selector: + addon: addon_restart: - description: Restart a Hass.io docker add-on. + name: Restart add-on. + description: Restart add-on. fields: addon: + name: Add-on + required: true description: The add-on slug. example: core_ssh + selector: + addon: addon_stdin: - description: Write data to a Hass.io docker add-on stdin . + name: Write data to add-on stdin. + description: Write data to add-on stdin. fields: addon: + name: Add-on + required: true description: The add-on slug. example: core_ssh + selector: + addon: addon_stop: - description: Stop a Hass.io docker add-on. + name: Stop add-on. + description: Stop add-on. fields: addon: + name: Add-on + required: true description: The add-on slug. example: core_ssh - -addon_uninstall: - description: Uninstall a Hass.io docker add-on. - fields: - addon: - description: The add-on slug. - example: core_ssh - -addon_update: - description: Update a Hass.io docker add-on. - fields: - addon: - description: The add-on slug. - example: core_ssh - version: - description: Optional or it will be use the latest version. - example: "0.2" - -homeassistant_update: - description: Update the Home Assistant docker image. - fields: - version: - description: Optional or it will be use the latest version. - example: 0.40.1 + selector: + addon: host_reboot: + name: Reboot the host system. description: Reboot the host system. host_shutdown: + name: Poweroff the host system. description: Poweroff the host system. -host_update: - description: Update the host system. - fields: - version: - description: Optional or it will be use the latest version. - example: "0.3" - snapshot_full: + name: Create a full snapshot. description: Create a full snapshot. fields: name: + name: Name description: Optional or it will be the current date and time. example: "Snapshot 1" + selector: + text: password: + name: Password description: Optional password. example: "password" + selector: + text: snapshot_partial: + name: Create a partial snapshot. description: Create a partial snapshot. fields: addons: + name: Add-ons description: Optional list of addon slugs. example: ["core_ssh", "core_samba", "core_mosquitto"] + selector: + object: folders: + name: Folders description: Optional list of directories. example: ["homeassistant", "share"] + selector: + object: name: + name: Name description: Optional or it will be the current date and time. example: "Partial Snapshot 1" + selector: + text: password: + name: Password description: Optional password. example: "password" - -supervisor_reload: - description: Reload the Hass.io supervisor. - -supervisor_update: - description: Update the Hass.io supervisor. - fields: - version: - description: Optional or it will be use the latest version. - example: "0.3" + selector: + text: diff --git a/homeassistant/helpers/selector.py b/homeassistant/helpers/selector.py index 68511a771d3..34befe9c37b 100644 --- a/homeassistant/helpers/selector.py +++ b/homeassistant/helpers/selector.py @@ -116,6 +116,13 @@ class NumberSelector(Selector): ) +@SELECTORS.register("addon") +class AddonSelector(Selector): + """Selector of a add-on.""" + + CONFIG_SCHEMA = vol.Schema({}) + + @SELECTORS.register("boolean") class BooleanSelector(Selector): """Selector of a boolean value.""" diff --git a/tests/helpers/test_selector.py b/tests/helpers/test_selector.py index c43ed4097e0..23d8200be23 100644 --- a/tests/helpers/test_selector.py +++ b/tests/helpers/test_selector.py @@ -118,6 +118,15 @@ def test_number_selector_schema(schema): selector.validate_selector({"number": schema}) +@pytest.mark.parametrize( + "schema", + ({},), +) +def test_addon_selector_schema(schema): + """Test add-on selector.""" + selector.validate_selector({"addon": schema}) + + @pytest.mark.parametrize( "schema", ({},),