From a2f70caa6501efcf8b177fb9255b3de4b553f945 Mon Sep 17 00:00:00 2001 From: endor-force <1937941+endor-force@users.noreply.github.com> Date: Thu, 7 Dec 2017 13:20:37 +0100 Subject: [PATCH] Stdin does not work with quoting on $input (#208) * Update config.json * Update run.sh * Single quotes.. ? * Nope.. single quotes did not work * Splitting on space and putting it back together Spaced.. * Gosh * Update run.sh * Cropping msg Since we wish to output the results from tdtool in either way (error or regular response) i cropped the catching of output. * Keep it simple. * ... * hmm * Update run.sh * Update run.sh * Update run.sh --- tellstick/config.json | 2 +- tellstick/run.sh | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tellstick/config.json b/tellstick/config.json index 0027aeb..6892295 100644 --- a/tellstick/config.json +++ b/tellstick/config.json @@ -1,6 +1,6 @@ { "name": "TellStick", - "version": "0.3", + "version": "0.4", "slug": "tellstick", "description": "TellStick and TellStick Duo service.", "url": "https://home-assistant.io/addons/tellstick/", diff --git a/tellstick/run.sh b/tellstick/run.sh index ea0a1db..b8dd867 100644 --- a/tellstick/run.sh +++ b/tellstick/run.sh @@ -68,13 +68,14 @@ socat TCP-LISTEN:50801,reuseaddr,fork UNIX-CONNECT:/tmp/TelldusEvents & # Listen for input to tdtool echo "[Info] Starting event listener" while read -r input; do - # removing JSON stuff - input="$(echo "$input" | jq --raw-output '.')" - echo "[Info] Read alias: $input" - - if ! msg="$(tdtool "--$input")"; then - echo "[Error] TellStick Command fails -> $msg" + # parse JSON value + funct="$(echo "$input" | jq --raw-output '.function')" + devid="$(echo "$input" | jq --raw-output '.device // empty')" + echo "[Info] Read $funct / $devid" + + if ! msg="$(tdtool "--$funct" "$devid")"; then + echo "[Error] TellStick $funct fails -> $msg" else - echo "[Info] TellStick Command success -> $msg" + echo "[Info] TellStick $funct success -> $msg" fi done