From bd7b500b2650245ce881b2186f97ceb0e4d9b81c Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 8 Jan 2020 21:34:53 +0100 Subject: [PATCH] Fixed Notifications --- alexa_remote_control.sh | 38 ++++++++------------------------ alexa_remote_control_plain.sh | 41 +++++++++-------------------------- 2 files changed, 19 insertions(+), 60 deletions(-) diff --git a/alexa_remote_control.sh b/alexa_remote_control.sh index 7da59af..45a1a87 100755 --- a/alexa_remote_control.sh +++ b/alexa_remote_control.sh @@ -48,6 +48,7 @@ # 2019-12-23: v0.14b Trigger routines by either utterance or routine name # 2019-12-30: v0.15 re-worked the volume setting for TTS commands # 2020-01-03: v0.15a introduce some proper "get_volume" +# 2020-01-08: v0.15b cleaned merge errors # ### # @@ -160,6 +161,7 @@ PLIST="" BLUETOOTH="" LASTALEXA="" GETVOL="" +NOTIFICATIONS="" usage() { @@ -1013,7 +1015,7 @@ if [ ! -f ${DEVLIST} ] ; then fi fi -if [ -n "$COMMAND" -o -n "$QUEUE" -o -n "$GETVOL" ] ; then +if [ -n "$COMMAND" -o -n "$QUEUE" -o -n "$NOTIFICATIONS" -o -n "$GETVOL" ] ; then if [ "${DEVICE}" = "ALL" ] ; then for DEVICE in $( jq -r '.devices[] | select( ( .deviceFamily == "ECHO" or .deviceFamily == "KNIGHT" or .deviceFamily == "ROOK" or .deviceFamily == "WHA" ) and .online == true ) | .accountName' ${DEVLIST} | sed -r 's/ /%20/g') ; do set_var @@ -1026,6 +1028,9 @@ if [ -n "$COMMAND" -o -n "$QUEUE" -o -n "$GETVOL" ] ; then elif [ -n "$GETVOL" ] ; then echo "get volume for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}" get_volume + elif [ -n "$NOTIFICATIONS" ] ; then + echo "notifications info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}" + show_notifications else echo "queue info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}" show_queue @@ -1041,40 +1046,15 @@ if [ -n "$COMMAND" -o -n "$QUEUE" -o -n "$GETVOL" ] ; then elif [ -n "$GETVOL" ] ; then echo "get volume for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}" get_volume + elif [ -n "$NOTIFICATIONS" ] ; then + echo "notifications info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}" + show_notifications else echo "queue info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}" show_queue echo fi fi -elif [ -n "$COMMAND" -o -n "$NOTIFICATIONS" ] ; then - if [ "${DEVICE}" = "ALL" ] ; then - while IFS= read -r DEVICE ; do - set_var - if [ -n "$COMMAND" ] ; then - echo "sending cmd:${COMMAND} to dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} customerid:${MEDIAOWNERCUSTOMERID}" - run_cmd - # in order to prevent a "Rate exceeded" we need to delay the command - sleep 1 - echo - else - echo "notifications info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}" - show_notifications - echo - fi - done < ${DEVALL} - else - set_var - if [ -n "$COMMAND" ] ; then - echo "sending cmd:${COMMAND} to dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} customerid:${MEDIAOWNERCUSTOMERID}" - run_cmd - echo - else - echo "notifications info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}" - show_notifications - echo - fi - fi elif [ -n "$LEMUR" ] ; then DEVICESERIALNUMBER=$(jq --arg device "${LEMUR}" -r '.devices[] | select(.accountName == $device and .deviceFamily == "WHA") | .serialNumber' ${DEVLIST}) if [ -n "$DEVICESERIALNUMBER" ] ; then diff --git a/alexa_remote_control_plain.sh b/alexa_remote_control_plain.sh index 52b1785..d3a08b7 100755 --- a/alexa_remote_control_plain.sh +++ b/alexa_remote_control_plain.sh @@ -3,7 +3,7 @@ # Amazon Alexa Remote Control (PLAIN shell) # alex(at)loetzimmer.de # -# 2019-12-30: v0.15 (for updates see http://blog.loetzimmer.de/2017/10/amazon-alexa-hort-auf-die-shell-echo.html) +# 2020-01-08: v0.15b (for updates see http://blog.loetzimmer.de/2017/10/amazon-alexa-hort-auf-die-shell-echo.html) # ### # @@ -110,11 +110,12 @@ CHILD="" PLIST="" BLUETOOTH="" LASTALEXA="" +NOTIFICATIONS="" usage() { echo "$0 [-d |ALL] -e > |" - echo " -b [list|<\"AA:BB:CC:DD:EE:FF\">] | -q | -r <\"station name\"|stationid> |" + echo " -b [list|<\"AA:BB:CC:DD:EE:FF\">] | -q | -n | -r <\"station name\"|stationid> |" echo " -s | -t | -u | -v | -w |" echo " -a | -m [device_1 .. device_X] | -lastalexa | -l | -h" echo @@ -915,7 +916,7 @@ if [ ! -f ${DEVTXT} -o ! -f ${DEVALL} ] ; then fi fi -if [ -n "$COMMAND" -o -n "$QUEUE" ] ; then +if [ -n "$COMMAND" -o -n "$QUEUE" -o -n "$NOTIFICATIONS" ] ; then if [ "${DEVICE}" = "ALL" ] ; then while IFS= read -r DEVICE ; do set_var @@ -926,6 +927,9 @@ if [ -n "$COMMAND" -o -n "$QUEUE" ] ; then # in order to prevent a "Rate exceeded" we need to delay the command sleep 1 echo + elif [ -n "$NOTIFICATIONS" ] ; then + echo "notifications info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}" + show_notifications else echo "queue info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}" show_queue @@ -939,40 +943,15 @@ if [ -n "$COMMAND" -o -n "$QUEUE" ] ; then echo "sending cmd:${COMMAND} to dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} customerid:${MEDIAOWNERCUSTOMERID}" run_cmd echo + elif [ -n "$NOTIFICATIONS" ] ; then + echo "notifications info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}" + show_notifications else echo "queue info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}" show_queue echo fi fi -elif [ -n "$COMMAND" -o -n "$NOTIFICATIONS" ] ; then - if [ "${DEVICE}" = "ALL" ] ; then - while IFS= read -r DEVICE ; do - set_var - if [ -n "$COMMAND" ] ; then - echo "sending cmd:${COMMAND} to dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} customerid:${MEDIAOWNERCUSTOMERID}" - run_cmd - # in order to prevent a "Rate exceeded" we need to delay the command - sleep 1 - echo - else - echo "notifications info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}" - show_notifications - echo - fi - done < ${DEVALL} - else - set_var - if [ -n "$COMMAND" ] ; then - echo "sending cmd:${COMMAND} to dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} customerid:${MEDIAOWNERCUSTOMERID}" - run_cmd - echo - else - echo "notifications info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}" - show_notifications - echo - fi - fi elif [ -n "$LEMUR" ] ; then DEVICE="${LEMUR}" set_var