Merge pull request #80 from adn77/master

Fixed Notifications
This commit is contained in:
Alex 2020-01-08 21:37:07 +01:00 committed by GitHub
commit e6a1d31588
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 60 deletions

View File

@ -48,6 +48,7 @@
# 2019-12-23: v0.14b Trigger routines by either utterance or routine name # 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 # 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-03: v0.15a introduce some proper "get_volume"
# 2020-01-08: v0.15b cleaned merge errors
# #
### ###
# #
@ -160,6 +161,7 @@ PLIST=""
BLUETOOTH="" BLUETOOTH=""
LASTALEXA="" LASTALEXA=""
GETVOL="" GETVOL=""
NOTIFICATIONS=""
usage() usage()
{ {
@ -1013,7 +1015,7 @@ if [ ! -f ${DEVLIST} ] ; then
fi fi
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 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 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 set_var
@ -1026,6 +1028,9 @@ if [ -n "$COMMAND" -o -n "$QUEUE" -o -n "$GETVOL" ] ; then
elif [ -n "$GETVOL" ] ; then elif [ -n "$GETVOL" ] ; then
echo "get volume for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}" echo "get volume for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}"
get_volume get_volume
elif [ -n "$NOTIFICATIONS" ] ; then
echo "notifications info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}"
show_notifications
else else
echo "queue info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}" echo "queue info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}"
show_queue show_queue
@ -1041,40 +1046,15 @@ if [ -n "$COMMAND" -o -n "$QUEUE" -o -n "$GETVOL" ] ; then
elif [ -n "$GETVOL" ] ; then elif [ -n "$GETVOL" ] ; then
echo "get volume for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}" echo "get volume for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}"
get_volume get_volume
elif [ -n "$NOTIFICATIONS" ] ; then
echo "notifications info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}"
show_notifications
else else
echo "queue info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}" echo "queue info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}"
show_queue show_queue
echo echo
fi fi
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 elif [ -n "$LEMUR" ] ; then
DEVICESERIALNUMBER=$(jq --arg device "${LEMUR}" -r '.devices[] | select(.accountName == $device and .deviceFamily == "WHA") | .serialNumber' ${DEVLIST}) DEVICESERIALNUMBER=$(jq --arg device "${LEMUR}" -r '.devices[] | select(.accountName == $device and .deviceFamily == "WHA") | .serialNumber' ${DEVLIST})
if [ -n "$DEVICESERIALNUMBER" ] ; then if [ -n "$DEVICESERIALNUMBER" ] ; then

View File

@ -3,7 +3,7 @@
# Amazon Alexa Remote Control (PLAIN shell) # Amazon Alexa Remote Control (PLAIN shell)
# alex(at)loetzimmer.de # 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="" PLIST=""
BLUETOOTH="" BLUETOOTH=""
LASTALEXA="" LASTALEXA=""
NOTIFICATIONS=""
usage() usage()
{ {
echo "$0 [-d <device>|ALL] -e <pause|play|next|prev|fwd|rwd|shuffle|repeat|vol:<0-100>> |" echo "$0 [-d <device>|ALL] -e <pause|play|next|prev|fwd|rwd|shuffle|repeat|vol:<0-100>> |"
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 <trackID|'Artist' 'Album'> | -t <ASIN> | -u <seedID> | -v <queueID> | -w <playlistId> |" echo " -s <trackID|'Artist' 'Album'> | -t <ASIN> | -u <seedID> | -v <queueID> | -w <playlistId> |"
echo " -a | -m <multiroom_device> [device_1 .. device_X] | -lastalexa | -l | -h" echo " -a | -m <multiroom_device> [device_1 .. device_X] | -lastalexa | -l | -h"
echo echo
@ -915,7 +916,7 @@ if [ ! -f ${DEVTXT} -o ! -f ${DEVALL} ] ; then
fi fi
fi fi
if [ -n "$COMMAND" -o -n "$QUEUE" ] ; then if [ -n "$COMMAND" -o -n "$QUEUE" -o -n "$NOTIFICATIONS" ] ; then
if [ "${DEVICE}" = "ALL" ] ; then if [ "${DEVICE}" = "ALL" ] ; then
while IFS= read -r DEVICE ; do while IFS= read -r DEVICE ; do
set_var 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 # in order to prevent a "Rate exceeded" we need to delay the command
sleep 1 sleep 1
echo echo
elif [ -n "$NOTIFICATIONS" ] ; then
echo "notifications info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}"
show_notifications
else else
echo "queue info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}" echo "queue info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}"
show_queue 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}" echo "sending cmd:${COMMAND} to dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} customerid:${MEDIAOWNERCUSTOMERID}"
run_cmd run_cmd
echo echo
elif [ -n "$NOTIFICATIONS" ] ; then
echo "notifications info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}"
show_notifications
else else
echo "queue info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}" echo "queue info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}"
show_queue show_queue
echo echo
fi fi
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 elif [ -n "$LEMUR" ] ; then
DEVICE="${LEMUR}" DEVICE="${LEMUR}"
set_var set_var