Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add descriptive fields to script config #26056

Merged
merged 7 commits into from Aug 21, 2019

Conversation

@JeffLIrion
Copy link
Contributor

commented Aug 18, 2019

Description:

Allow users to provide info about scripts that will be displayed in the "call services" tab, the same way that information is displayed for standard services.

Related issue (if applicable): fixes the script portion of home-assistant/architecture#275

Pull request with documentation for home-assistant.io (if applicable): home-assistant/home-assistant.io#10180

Example entry for configuration.yaml (if applicable):

script:
  home_assistant_restart_with_delay:
    alias: 'Home Assistant: restart with delay'
    description: Restart Home Assistant after a delay.
    fields:
      seconds:
        description: The amount of time to wait (in seconds).
        example: 5
    sequence:
    - delay: '00:00:{{ seconds | int }}'
    - service: homeassistant.restart

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist

If user exposed functionality or configuration variables are added/changed:

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.
@JeffLIrion

This comment has been minimized.

Copy link
Contributor Author

commented Aug 19, 2019

Collecting bimmer_connected==0.5.6 (from -r requirements_all.txt (line 269))
  ERROR: Could not find a version that satisfies the requirement bimmer_connected==0.5.6 (from -r requirements_all.txt (line 269)) (from versions: 0.0.1, 0.0.3, 0.0.4, 0.1.0, 0.2.0, 0.3.0, 0.4.0.dev0, 0.4.0, 0.4.1, 0.5.0, 0.5.1, 0.5.2, 0.5.3, 0.5.9b0, 0.5.9b1)
ERROR: No matching distribution found for bimmer_connected==0.5.6 (from -r requirements_all.txt (line 269))
##[error]Bash exited with code '1'.

@JeffLIrion JeffLIrion closed this Aug 19, 2019

Dev automation moved this from Needs review to Cancelled Aug 19, 2019

@JeffLIrion JeffLIrion reopened this Aug 19, 2019

Dev automation moved this from Cancelled to Needs review Aug 19, 2019

@JeffLIrion JeffLIrion force-pushed the JeffLIrion:script-descriptions branch from f328cf0 to 139adfa Aug 19, 2019

@JeffLIrion JeffLIrion changed the title [WIP] Add descriptive fields to script config Add descriptive fields to script config Aug 19, 2019

@@ -129,6 +139,7 @@ def is_on(hass, entity_id):

scripts = []

hass.data.setdefault("service_description_cache", {})

This comment has been minimized.

Copy link
@balloob

balloob Aug 20, 2019

Member

We shouldn't mess with this cache ourselves. Instead, we should add a new method in helpers/service.py to set the schema for a service:

@callback
def async_set_service_schema(domain, service, schema)

And we should use the same approach for python script integration.

This comment has been minimized.

Copy link
@JeffLIrion

JeffLIrion Aug 21, 2019

Author Contributor
@ha.callback
def async_set_service_schema(hass, domain, service, schema):
    """Register a description for a service."""
    hass.data.setdefault(SERVICE_DESCRIPTION_CACHE, {})

     description = {
        "description": schema.get("description", ""),
        "fields": schema.get("fields", {}),
    }

     hass.data[SERVICE_DESCRIPTION_CACHE]["{}.{}".format(domain, service)] = description

Is that what you had in mind?

@JeffLIrion JeffLIrion closed this Aug 21, 2019

Dev automation moved this from Needs review to Cancelled Aug 21, 2019

@JeffLIrion JeffLIrion reopened this Aug 21, 2019

Dev automation moved this from Cancelled to Needs review Aug 21, 2019

@JeffLIrion JeffLIrion force-pushed the JeffLIrion:script-descriptions branch from eb3614c to 7e4a2da Aug 21, 2019

Dev automation moved this from Needs review to Reviewer approved Aug 21, 2019

@JeffLIrion

This comment has been minimized.

Copy link
Contributor Author

commented Aug 21, 2019

Once this gets merged, I can fix up #26069 in a couple minutes and it should be good to go. Hopefully both of these can get into 0.98! 👍

@balloob balloob merged commit 7090970 into home-assistant:dev Aug 21, 2019

11 checks passed

CI Build #20190821.29 succeeded
Details
CI (FullCheck Mypy) FullCheck Mypy succeeded
Details
CI (FullCheck Pylint) FullCheck Pylint succeeded
Details
CI (Overview CheckFormat) Overview CheckFormat succeeded
Details
CI (Overview Lint) Overview Lint succeeded
Details
CI (Overview Validate) Overview Validate succeeded
Details
CI (Tests PyTest Python36) Tests PyTest Python36 succeeded
Details
CI (Tests PyTest Python37) Tests PyTest Python37 succeeded
Details
cla-bot Everyone involved has signed the CLA
codecov/patch 100% of diff hit (target 94%)
Details
codecov/project 94% (target 90%)
Details

Dev automation moved this from Reviewer approved to Done Aug 21, 2019

@JeffLIrion JeffLIrion referenced this pull request Aug 21, 2019
3 of 6 tasks complete

@lock lock bot locked and limited conversation to collaborators Aug 22, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
3 participants
You can’t perform that action at this time.