fix: update jq parsing for new alexaHistoryRecords response structure

New API response uses:
- alexaHistoryRecords (was customerHistoryRecords)
- activityKey (was recordKey)
- deviceInfo.deviceName (was device.deviceName)
- recordType == "utterance" filter for device-specific lastcommand

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015a9UxV6q6eG4bpn3JH3PJX
This commit is contained in:
Claude
2026-09-05 09:11:03 +00:00
parent 0707c217f2
commit a15eb7a6e7
+3 -3
View File
@@ -1160,7 +1160,7 @@ get_history()
last_alexa()
{
get_history
${JQ} -r '.customerHistoryRecords | sort_by(.timestamp) | reverse | .[0] | .recordKey' ${TMP}/.alexa.activity.json | cut -d'#' -f4 | xargs -i grep -m 1 {} ${DEVLIST}.txt
${JQ} -r '.alexaHistoryRecords | sort_by(.timestamp) | reverse | .[0] | .activityKey' ${TMP}/.alexa.activity.json | cut -d'#' -f4 | xargs -i grep -m 1 {} ${DEVLIST}.txt
}
#
# last command or last command of a specific device
@@ -1170,9 +1170,9 @@ last_command()
get_history
if [ -z "$DEVICE" ] ; then
${JQ} -r --arg device "$DEVICE" '.customerHistoryRecords | sort_by(.timestamp) | reverse | .[0] | .voiceHistoryRecordItems | map({key: .recordItemType, value: .transcriptText})' ${TMP}/.alexa.activity.json
${JQ} -r '.alexaHistoryRecords | sort_by(.timestamp) | reverse | .[0] | .voiceHistoryRecordItems | map({key: .recordItemType, value: .transcriptText})' ${TMP}/.alexa.activity.json
else
${JQ} -r --arg device "$DEVICE" '[ .customerHistoryRecords | sort_by(.timestamp) | reverse | .[] | select( .device.deviceName == $device) ][0] | .voiceHistoryRecordItems | map({key: .recordItemType, value: .transcriptText})' ${TMP}/.alexa.activity.json
${JQ} -r --arg device "$DEVICE" '[ .alexaHistoryRecords | sort_by(.timestamp) | reverse | .[] | select(.recordType == "utterance" and .deviceInfo.deviceName == $device) ][0] | .voiceHistoryRecordItems | map({key: .recordItemType, value: .transcriptText})' ${TMP}/.alexa.activity.json
fi
}