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

Allow passing of json argument to service call #319

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Commits on Jul 18, 2023

  1. Allow passing of json/yaml argument to service call

    When calling service who needs arguments which are other things than
    strings, ex nested dicts, its easiest done by being able to pass a json
    or yaml argument, for example when calling html5.dismis:
    
    hass-cli service call html5.dismiss --json '{"target": "DEVICE", "data": {"tag": "TAG"}}'
    
    As requested in review, this also adds support for passing in @filename
    or - for reading arguments from stdin or from a file.
    
    Signed-off-by: Anton Lundin <[email protected]>
    glance- committed Jul 18, 2023
    Configuration menu
    Copy the full SHA
    3de17eb View commit details
    Browse the repository at this point in the history
  2. Correct mypy warning

    glance- committed Jul 18, 2023
    Configuration menu
    Copy the full SHA
    71c78bb View commit details
    Browse the repository at this point in the history
  3. Move argument parsing callback to helper

    This is to simplify re-use outside service calls.
    glance- committed Jul 18, 2023
    Configuration menu
    Copy the full SHA
    816e90f View commit details
    Browse the repository at this point in the history
  4. Increase argument capability in raw ws and raw post

    This re-uses the --yaml and --json argument parsers from services to
    allow passing from stdin and files.
    
    One awesome use case is:
    hass-cli raw ws lovelace/config > ui-lovelace.yaml
    $EDITOR ui-lovelace.yaml , replacing the status fields, up until result:
    with config:, and then,
    hass-cli raw ws lovelace/config/save --yaml @ui-lovelace.yaml
    glance- committed Jul 18, 2023
    Configuration menu
    Copy the full SHA
    ee7e69f View commit details
    Browse the repository at this point in the history