Created
February 19, 2023 21:04
-
-
Save pschmitt/d63e0e1053e0be87b70d95a30621a369 to your computer and use it in GitHub Desktop.
home-assistant-cli read JSON from stdin patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/homeassistant_cli/plugins/raw.py b/homeassistant_cli/plugins/raw.py | |
index 46c544e..62e6a1a 100644 | |
--- a/homeassistant_cli/plugins/raw.py | |
+++ b/homeassistant_cli/plugins/raw.py | |
@@ -61,7 +61,9 @@ def get(ctx: Configuration, method): | |
def post(ctx: Configuration, method, json): | |
"""Do a POST request against api/<method>.""" | |
if json: | |
- data = json_.loads(json) | |
+ data = json_.loads( | |
+ json if json != "-" else click.get_text_stream('stdin').read() | |
+ ) | |
else: | |
data = {} | |
@@ -86,7 +88,9 @@ def websocket(ctx: Configuration, wstype, json): # noqa: D301 | |
Example: --json='{ "area_id":"2c8bf93c8082492f99c989896962f207" }' | |
""" | |
if json: | |
- data = json_.loads(json) | |
+ data = json_.loads( | |
+ json if json != "-" else click.get_text_stream('stdin').read() | |
+ ) | |
else: | |
data = {} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment