mirror of
https://github.com/thorsten-gehrig/alexa-remote-control.git
synced 2024-11-14 12:59:02 +01:00
commit
6e07eadf75
@ -54,6 +54,8 @@ SET_PASSWORD='Very_Secret_Amazon_Account_Password'
|
|||||||
SET_LANGUAGE="de,en-US;q=0.7,en;q=0.3"
|
SET_LANGUAGE="de,en-US;q=0.7,en;q=0.3"
|
||||||
#SET_LANGUAGE="en-US"
|
#SET_LANGUAGE="en-US"
|
||||||
|
|
||||||
|
SET_TTS_LOCALE='de-DE'
|
||||||
|
|
||||||
SET_AMAZON='amazon.de'
|
SET_AMAZON='amazon.de'
|
||||||
#SET_AMAZON='amazon.com'
|
#SET_AMAZON='amazon.com'
|
||||||
|
|
||||||
@ -90,6 +92,7 @@ LANGUAGE=${LANGUAGE:-$SET_LANGUAGE}
|
|||||||
BROWSER=${BROWSER:-$SET_BROWSER}
|
BROWSER=${BROWSER:-$SET_BROWSER}
|
||||||
CURL=${CURL:-$SET_CURL}
|
CURL=${CURL:-$SET_CURL}
|
||||||
OPTS=${OPTS:-$SET_OPTS}
|
OPTS=${OPTS:-$SET_OPTS}
|
||||||
|
TTS_LOCALE=${TTS_LOCALE:-$SET_TTS_LOCALE}
|
||||||
TMP=${TMP:-$SET_TMP}
|
TMP=${TMP:-$SET_TMP}
|
||||||
|
|
||||||
COOKIE="${TMP}/.alexa.cookie"
|
COOKIE="${TMP}/.alexa.cookie"
|
||||||
@ -517,15 +520,13 @@ if [ -n "${SEQUENCECMD}" ]
|
|||||||
SEQUENCE=$(jq --arg utterance "${UTTERANCE}" -r -c '.[] | select( .triggers[].payload.utterance == $utterance) | .sequence' "${TMP}/.alexa.automation" | sed 's/"/\\"/g' | sed "s/ALEXA_CURRENT_DEVICE_TYPE/${DEVICETYPE}/g" | sed "s/ALEXA_CURRENT_DSN/${DEVICESERIALNUMBER}/g" | sed "s/ALEXA_CUSTOMER_ID/${MEDIAOWNERCUSTOMERID}/g")
|
SEQUENCE=$(jq --arg utterance "${UTTERANCE}" -r -c '.[] | select( .triggers[].payload.utterance == $utterance) | .sequence' "${TMP}/.alexa.automation" | sed 's/"/\\"/g' | sed "s/ALEXA_CURRENT_DEVICE_TYPE/${DEVICETYPE}/g" | sed "s/ALEXA_CURRENT_DSN/${DEVICESERIALNUMBER}/g" | sed "s/ALEXA_CUSTOMER_ID/${MEDIAOWNERCUSTOMERID}/g")
|
||||||
rm -f "${TMP}/.alexa.automation"
|
rm -f "${TMP}/.alexa.automation"
|
||||||
|
|
||||||
echo "Running routine: ${UTTERANCE}"
|
ALEXACMD="{\"behaviorId\":\"${AUTOMATION}\",\"sequenceJson\":\"${SEQUENCE}\",\"status\":\"ENABLED\"}"
|
||||||
COMMAND="{\"behaviorId\":\"${AUTOMATION}\",\"sequenceJson\":\"${SEQUENCE}\",\"status\":\"ENABLED\"}"
|
|
||||||
else
|
else
|
||||||
echo "Sequence command: ${SEQUENCECMD}"
|
ALEXACMD="{\"behaviorId\":\"PREVIEW\",\"sequenceJson\":\"{\\\"@type\\\":\\\"com.amazon.alexa.behaviors.model.Sequence\\\",\\\"startNode\\\":{\\\"@type\\\":\\\"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode\\\",\\\"type\\\":\\\"${SEQUENCECMD}\\\",\\\"operationPayload\\\":{\\\"deviceType\\\":\\\"${DEVICETYPE}\\\",\\\"deviceSerialNumber\\\":\\\"${DEVICESERIALNUMBER}\\\",\\\"locale\\\":\\\"${TTS_LOCALE}\\\",\\\"customerId\\\":\\\"${MEDIAOWNERCUSTOMERID}\\\"${TTS}}}}\",\"status\":\"ENABLED\"}"
|
||||||
COMMAND="{\"behaviorId\":\"PREVIEW\",\"sequenceJson\":\"{\\\"@type\\\":\\\"com.amazon.alexa.behaviors.model.Sequence\\\",\\\"startNode\\\":{\\\"@type\\\":\\\"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode\\\",\\\"type\\\":\\\"${SEQUENCECMD}\\\",\\\"operationPayload\\\":{\\\"deviceType\\\":\\\"${DEVICETYPE}\\\",\\\"deviceSerialNumber\\\":\\\"${DEVICESERIALNUMBER}\\\",\\\"locale\\\":\\\"${LANGUAGE}\\\",\\\"customerId\\\":\\\"${MEDIAOWNERCUSTOMERID}\\\"${TTS}}}}\",\"status\":\"ENABLED\"}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Due to some weird shell-escape-behavior the command has t be written to a file before POSTing it
|
# Due to some weird shell-escape-behavior the command has t be written to a file before POSTing it
|
||||||
echo $COMMAND > "${TMP}/.alexa.cmd"
|
echo $ALEXACMD > "${TMP}/.alexa.cmd"
|
||||||
|
|
||||||
${CURL} ${OPTS} -s -b ${COOKIE} -A "${BROWSER}" -H "DNT: 1" -H "Connection: keep-alive" -L\
|
${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 "Content-Type: application/json; charset=UTF-8" -H "Referer: https://alexa.${AMAZON}/spa/index.html" -H "Origin: https://alexa.${AMAZON}"\
|
||||||
@ -829,9 +830,11 @@ if [ -n "$COMMAND" -o -n "$QUEUE" ] ; then
|
|||||||
run_cmd
|
run_cmd
|
||||||
# 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
|
||||||
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
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
@ -839,9 +842,11 @@ if [ -n "$COMMAND" -o -n "$QUEUE" ] ; then
|
|||||||
if [ -n "$COMMAND" ] ; then
|
if [ -n "$COMMAND" ] ; 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
|
||||||
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
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
elif [ -n "$LEMUR" ] ; then
|
elif [ -n "$LEMUR" ] ; then
|
||||||
@ -859,6 +864,7 @@ elif [ -n "$LEMUR" ] ; then
|
|||||||
else
|
else
|
||||||
echo "Creating multi room dev:${LEMUR} member_dev(s):${CHILD}"
|
echo "Creating multi room dev:${LEMUR} member_dev(s):${CHILD}"
|
||||||
create_multiroom
|
create_multiroom
|
||||||
|
echo
|
||||||
fi
|
fi
|
||||||
rm -f ${DEVLIST}
|
rm -f ${DEVLIST}
|
||||||
get_devlist
|
get_devlist
|
||||||
@ -869,20 +875,24 @@ elif [ -n "$BLUETOOTH" ] ; then
|
|||||||
set_var
|
set_var
|
||||||
echo "bluetooth devices for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}:"
|
echo "bluetooth devices for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}:"
|
||||||
list_bluetooth
|
list_bluetooth
|
||||||
|
echo
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
set_var
|
set_var
|
||||||
echo "bluetooth devices for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}:"
|
echo "bluetooth devices for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}:"
|
||||||
list_bluetooth
|
list_bluetooth
|
||||||
|
echo
|
||||||
fi
|
fi
|
||||||
elif [ "$BLUETOOTH" = "null" ] ; then
|
elif [ "$BLUETOOTH" = "null" ] ; then
|
||||||
set_var
|
set_var
|
||||||
echo "disconnecting dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} from bluetooth"
|
echo "disconnecting dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} from bluetooth"
|
||||||
disconnect_bluetooth
|
disconnect_bluetooth
|
||||||
|
echo
|
||||||
else
|
else
|
||||||
set_var
|
set_var
|
||||||
echo "connecting dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} to bluetooth device:${BLUETOOTH}"
|
echo "connecting dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} to bluetooth device:${BLUETOOTH}"
|
||||||
connect_bluetooth
|
connect_bluetooth
|
||||||
|
echo
|
||||||
fi
|
fi
|
||||||
elif [ -n "$STATIONID" ] ; then
|
elif [ -n "$STATIONID" ] ; then
|
||||||
set_var
|
set_var
|
||||||
|
@ -20,6 +20,8 @@ SET_PASSWORD='Very_Secret_Amazon_Account_Password'
|
|||||||
SET_LANGUAGE="de,en-US;q=0.7,en;q=0.3"
|
SET_LANGUAGE="de,en-US;q=0.7,en;q=0.3"
|
||||||
#SET_LANGUAGE="en-US"
|
#SET_LANGUAGE="en-US"
|
||||||
|
|
||||||
|
SET_TTS_LOCALE='de-DE'
|
||||||
|
|
||||||
SET_AMAZON='amazon.de'
|
SET_AMAZON='amazon.de'
|
||||||
#SET_AMAZON='amazon.com'
|
#SET_AMAZON='amazon.com'
|
||||||
|
|
||||||
@ -56,6 +58,7 @@ LANGUAGE=${LANGUAGE:-$SET_LANGUAGE}
|
|||||||
BROWSER=${BROWSER:-$SET_BROWSER}
|
BROWSER=${BROWSER:-$SET_BROWSER}
|
||||||
CURL=${CURL:-$SET_CURL}
|
CURL=${CURL:-$SET_CURL}
|
||||||
OPTS=${OPTS:-$SET_OPTS}
|
OPTS=${OPTS:-$SET_OPTS}
|
||||||
|
TTS_LOCALE=${TTS_LOCALE:-$SET_TTS_LOCALE}
|
||||||
TMP=${TMP:-$SET_TMP}
|
TMP=${TMP:-$SET_TMP}
|
||||||
|
|
||||||
COOKIE="${TMP}/.alexa.cookie"
|
COOKIE="${TMP}/.alexa.cookie"
|
||||||
@ -526,11 +529,10 @@ run_cmd()
|
|||||||
{
|
{
|
||||||
if [ -n "${SEQUENCECMD}" ]
|
if [ -n "${SEQUENCECMD}" ]
|
||||||
then
|
then
|
||||||
echo "Sequence command: ${SEQUENCECMD}"
|
ALEXACMD="{\"behaviorId\":\"PREVIEW\",\"sequenceJson\":\"{\\\"@type\\\":\\\"com.amazon.alexa.behaviors.model.Sequence\\\",\\\"startNode\\\":{\\\"@type\\\":\\\"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode\\\",\\\"type\\\":\\\"${SEQUENCECMD}\\\",\\\"operationPayload\\\":{\\\"deviceType\\\":\\\"${DEVICETYPE}\\\",\\\"deviceSerialNumber\\\":\\\"${DEVICESERIALNUMBER}\\\",\\\"locale\\\":\\\"${TTS_LOCALE}\\\",\\\"customerId\\\":\\\"${MEDIAOWNERCUSTOMERID}\\\"${TTS}}}}\",\"status\":\"ENABLED\"}"
|
||||||
COMMAND="{\"behaviorId\":\"PREVIEW\",\"sequenceJson\":\"{\\\"@type\\\":\\\"com.amazon.alexa.behaviors.model.Sequence\\\",\\\"startNode\\\":{\\\"@type\\\":\\\"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode\\\",\\\"type\\\":\\\"${SEQUENCECMD}\\\",\\\"operationPayload\\\":{\\\"deviceType\\\":\\\"${DEVICETYPE}\\\",\\\"deviceSerialNumber\\\":\\\"${DEVICESERIALNUMBER}\\\",\\\"locale\\\":\\\"${LANGUAGE}\\\",\\\"customerId\\\":\\\"${MEDIAOWNERCUSTOMERID}\\\"${TTS}}}}\",\"status\":\"ENABLED\"}"
|
|
||||||
|
|
||||||
# Due to some weird shell-escape-behavior the command has t be written to a file before POSTing it
|
# Due to some weird shell-escape-behavior the command has t be written to a file before POSTing it
|
||||||
echo $COMMAND > "${TMP}/.alexa.cmd"
|
echo $ALEXACMD > "${TMP}/.alexa.cmd"
|
||||||
|
|
||||||
${CURL} ${OPTS} -s -b ${COOKIE} -A "${BROWSER}" -H "DNT: 1" -H "Connection: keep-alive" -L\
|
${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 "Content-Type: application/json; charset=UTF-8" -H "Referer: https://alexa.${AMAZON}/spa/index.html" -H "Origin: https://alexa.${AMAZON}"\
|
||||||
@ -772,15 +774,23 @@ if [ -n "$COMMAND" -o -n "$QUEUE" ] ; then
|
|||||||
run_cmd
|
run_cmd
|
||||||
# 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
|
||||||
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
|
||||||
fi
|
fi
|
||||||
done < ${DEVALL}
|
done < ${DEVALL}
|
||||||
else
|
else
|
||||||
|
set_var
|
||||||
if [ -n "$COMMAND" ] ; then
|
if [ -n "$COMMAND" ] ; 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
|
||||||
|
else
|
||||||
|
echo "queue info for dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER}"
|
||||||
|
show_queue
|
||||||
|
echo
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
elif [ -n "$LEMUR" ] ; then
|
elif [ -n "$LEMUR" ] ; then
|
||||||
@ -794,6 +804,7 @@ elif [ -n "$LEMUR" ] ; then
|
|||||||
else
|
else
|
||||||
echo "Creating multi room dev:${LEMUR} member_dev(s):${CHILD}"
|
echo "Creating multi room dev:${LEMUR} member_dev(s):${CHILD}"
|
||||||
create_multiroom
|
create_multiroom
|
||||||
|
echo
|
||||||
fi
|
fi
|
||||||
rm -f ${DEVLIST}
|
rm -f ${DEVLIST}
|
||||||
rm -f ${DEVALL}
|
rm -f ${DEVALL}
|
||||||
@ -806,20 +817,24 @@ elif [ -n "$BLUETOOTH" ] ; then
|
|||||||
set_var
|
set_var
|
||||||
echo "bluetooth api list:"
|
echo "bluetooth api list:"
|
||||||
list_bluetooth
|
list_bluetooth
|
||||||
|
echo
|
||||||
done < ${DEVALL}
|
done < ${DEVALL}
|
||||||
else
|
else
|
||||||
set_var
|
set_var
|
||||||
echo "bluetooth api list:"
|
echo "bluetooth api list:"
|
||||||
list_bluetooth
|
list_bluetooth
|
||||||
|
echo
|
||||||
fi
|
fi
|
||||||
elif [ "$BLUETOOTH" = "null" ] ; then
|
elif [ "$BLUETOOTH" = "null" ] ; then
|
||||||
set_var
|
set_var
|
||||||
echo "disconnecting dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} from bluetooth"
|
echo "disconnecting dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} from bluetooth"
|
||||||
disconnect_bluetooth
|
disconnect_bluetooth
|
||||||
|
echo
|
||||||
else
|
else
|
||||||
set_var
|
set_var
|
||||||
echo "connecting dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} to bluetooth device:${BLUETOOTH}"
|
echo "connecting dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} to bluetooth device:${BLUETOOTH}"
|
||||||
connect_bluetooth
|
connect_bluetooth
|
||||||
|
echo
|
||||||
fi
|
fi
|
||||||
elif [ -n "$STATIONID" ] ; then
|
elif [ -n "$STATIONID" ] ; then
|
||||||
set_var
|
set_var
|
||||||
|
Loading…
Reference in New Issue
Block a user