mirror of
https://github.com/thorsten-gehrig/alexa-remote-control.git
synced 2024-11-13 04:19:03 +01:00
Merge branch 'master' into master
This commit is contained in:
commit
4279441dc8
@ -29,7 +29,7 @@ export LANGUAGE='de,en-US;q=0.7,en;q=0.3'
|
||||
|
||||
```
|
||||
alexa-remote-control [-d <device>|ALL] -e <pause|play|next|prev|fwd|rwd|shuffle|repeat|vol:<0-100>> |
|
||||
-b [list|<"AA:BB:CC:DD:EE:FF">] | -q | -r <"station name"|stationid> |
|
||||
-b [list|<"AA:BB:CC:DD:EE:FF">] | -q | -n | -r <"station name"|stationid> |
|
||||
-s <trackID|'Artist' 'Album'> | -t <ASIN> | -u <seedID> | -v <queueID> |
|
||||
-w <playlistId> | -i | -p | -P | -S | -a | -z | -l | -h |
|
||||
-m <multiroom_device> [device_1 .. device_X] | -lastalexa
|
||||
@ -39,6 +39,7 @@ alexa-remote-control [-d <device>|ALL] -e <pause|play|next|prev|fwd|rwd|shuffle|
|
||||
speak:'<text>',automation:'<routine name>'
|
||||
-b : connect/disconnect/list bluetooth device
|
||||
-q : query queue
|
||||
-n : query notifications
|
||||
-r : play tunein radio
|
||||
-s : play library track/library album
|
||||
-t : play Prime playlist
|
||||
|
@ -164,7 +164,7 @@ GETVOL=""
|
||||
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 " -i | -p | -P | -S | -a | -m <multiroom_device> [device_1 .. device_X] | -lastalexa | -z | -l | -h"
|
||||
echo
|
||||
@ -172,6 +172,7 @@ usage()
|
||||
echo " weather,traffic,flashbriefing,goodmorning,singasong,tellstory,speak:'<text>',automation:'<routine name>'"
|
||||
echo " -b : connect/disconnect/list bluetooth device"
|
||||
echo " -q : query queue"
|
||||
echo " -n : query notifications"
|
||||
echo " -r : play tunein radio"
|
||||
echo " -s : play library track/library album"
|
||||
echo " -t : play Prime playlist"
|
||||
@ -320,6 +321,9 @@ while [ "$#" -gt 0 ] ; do
|
||||
-q)
|
||||
QUEUE="true"
|
||||
;;
|
||||
-n)
|
||||
NOTIFICATIONS="true"
|
||||
;;
|
||||
-lastalexa)
|
||||
LASTALEXA="true"
|
||||
;;
|
||||
@ -875,6 +879,19 @@ get_volume()
|
||||
cut -d' ' -f1 "${TMP}/.alexa.volume.${DEVICESERIALNUMBER}"
|
||||
}
|
||||
|
||||
#
|
||||
# show notifications and alarms
|
||||
#
|
||||
show_notifications()
|
||||
{
|
||||
echo "/api/notifications"
|
||||
${CURL} ${OPTS} -s -b ${COOKIE} -A "${BROWSER}" -H "DNT: 1" -H "Connection: keep-alive" -L\
|
||||
-H "Content-Type: application/json; charset=UTF-8" -H "Referer: https://alexa.${AMAZON}/spa/index.html" -H "Origin: https://alexa.${AMAZON}"\
|
||||
-H "csrf: $(awk "\$0 ~/.${AMAZON}.*csrf[ \\s\\t]+/ {print \$7}" ${COOKIE})" -X GET \
|
||||
"https://${ALEXA}/api/notifications?deviceSerialNumber=${DEVICESERIALNUMBER}&deviceType=${DEVICETYPE}"
|
||||
echo
|
||||
}
|
||||
|
||||
#
|
||||
# deletes a multiroom device
|
||||
#
|
||||
@ -965,7 +982,7 @@ rm -f ${TMP}/.alexa.*.list
|
||||
rm -f ${TMP}/.alexa.volume.*
|
||||
}
|
||||
|
||||
if [ -z "$LASTALEXA" -a -z "$BLUETOOTH" -a -z "$LEMUR" -a -z "$PLIST" -a -z "$HIST" -a -z "$SEEDID" -a -z "$ASIN" -a -z "$PRIME" -a -z "$TYPE" -a -z "$QUEUE" -a -z "$LIST" -a -z "$COMMAND" -a -z "$STATIONID" -a -z "$SONG" -a -z "$GETVOL" -a -n "$LOGOFF" ] ; then
|
||||
if [ -z "$LASTALEXA" -a -z "$BLUETOOTH" -a -z "$LEMUR" -a -z "$PLIST" -a -z "$HIST" -a -z "$SEEDID" -a -z "$ASIN" -a -z "$PRIME" -a -z "$TYPE" -a -z "$QUEUE" -a -z "$NOTIFICATIONS" -a -z "$LIST" -a -z "$COMMAND" -a -z "$STATIONID" -a -z "$SONG" -a -z "$GETVOL" -a -n "$LOGOFF" ] ; then
|
||||
echo "only logout option present, logging off ..."
|
||||
log_off
|
||||
exit 0
|
||||
@ -1030,6 +1047,34 @@ if [ -n "$COMMAND" -o -n "$QUEUE" -o -n "$GETVOL" ] ; then
|
||||
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
|
||||
|
@ -122,6 +122,7 @@ usage()
|
||||
echo " weather,traffic,flashbriefing,goodmorning,singasong,tellstory,speak:'<text>'"
|
||||
echo " -b : connect/disconnect/list bluetooth device"
|
||||
echo " -q : query queue"
|
||||
echo " -n : query notifications"
|
||||
echo " -r : play tunein radio"
|
||||
echo " -s : play library track/library album"
|
||||
echo " -t : play Prime playlist"
|
||||
@ -253,6 +254,9 @@ while [ "$#" -gt 0 ] ; do
|
||||
-q)
|
||||
QUEUE="true"
|
||||
;;
|
||||
-n)
|
||||
NOTIFICATIONS="true"
|
||||
;;
|
||||
-lastalexa)
|
||||
LASTALEXA="true"
|
||||
;;
|
||||
@ -779,6 +783,19 @@ ${CURL} ${OPTS} -s -b ${COOKIE} -A "${BROWSER}" -H "DNT: 1" -H "Connection: keep
|
||||
echo
|
||||
}
|
||||
|
||||
#
|
||||
# show notifications and alarms
|
||||
#
|
||||
show_notifications()
|
||||
{
|
||||
echo "/api/notifications"
|
||||
${CURL} ${OPTS} -s -b ${COOKIE} -A "${BROWSER}" -H "DNT: 1" -H "Connection: keep-alive" -L\
|
||||
-H "Content-Type: application/json; charset=UTF-8" -H "Referer: https://alexa.${AMAZON}/spa/index.html" -H "Origin: https://alexa.${AMAZON}"\
|
||||
-H "csrf: $(awk "\$0 ~/.${AMAZON}.*csrf[ \\s\\t]+/ {print \$7}" ${COOKIE})" -X GET \
|
||||
"https://${ALEXA}/api/notifications?deviceSerialNumber=${DEVICESERIALNUMBER}&deviceType=${DEVICETYPE}"
|
||||
echo
|
||||
}
|
||||
|
||||
#
|
||||
# deletes a multiroom device
|
||||
#
|
||||
@ -867,7 +884,7 @@ rm -f ${DEVALL}
|
||||
rm -f ${COOKIE}
|
||||
}
|
||||
|
||||
if [ -z "$LASTALEXA" -a -z "$BLUETOOTH" -a -z "$LEMUR" -a -z "$PLIST" -a -z "$HIST" -a -z "$SEEDID" -a -z "$ASIN" -a -z "$QUEUE" -a -z "$COMMAND" -a -z "$STATIONID" -a -z "$SONG" -a -n "$LOGOFF" ] ; then
|
||||
if [ -z "$LASTALEXA" -a -z "$BLUETOOTH" -a -z "$LEMUR" -a -z "$PLIST" -a -z "$HIST" -a -z "$SEEDID" -a -z "$ASIN" -a -z "$QUEUE" -a -z "$NOTIFICATIONS" -a -z "$COMMAND" -a -z "$STATIONID" -a -z "$SONG" -a -n "$LOGOFF" ] ; then
|
||||
echo "only logout option present, logging off ..."
|
||||
log_off
|
||||
exit 0
|
||||
@ -928,6 +945,34 @@ if [ -n "$COMMAND" -o -n "$QUEUE" ] ; then
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user