Fixed Notifications

This commit is contained in:
Alex 2020-01-08 21:34:53 +01:00
parent 4279441dc8
commit bd7b500b26
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-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

View File

@ -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 <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 " -a | -m <multiroom_device> [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