I have OH 3.4 and the solution I have given it for now has been the following:
You can use the api:
http://openhab:8080/amazonechocontrol/account1/PROXY/api/activities?startTime=&size=1&offset=1
which with size=1 returns the last command in JSON. In that command appears the serial number of the ECHO. Using a rule you extract that serial number and you know which ECHO has been used.
Through the Alexa app I created a routine (voice command: “Alexa, power”) that activates an OH item (Item power3_value_item_tts) and I use that item to trigger the “Alexa LastVoiceCommand” rule. The whole process is very fast, since when the item has changed it is because Alexa has already interpreted the command we have given it by voice:
rule “Alexa LastVoiceCommand”
when
Item potencia3_value_item_tts received command ON
then
val String alexa_LastVoiceCommand = sendHttpGetRequest(“http://192.168.1.19:8080/amazonechocontrol/account1/PROXY/api/activities?startTime=&size=1&offset=1”)
val serialNumber_alexa_LastVoiceCommand = transform(“JSONPATH”,“$.activities[0]sourceDeviceIds[0]serialNumber”,alexa_LastVoiceCommand)
logInfo("Echo, serialNumber: ",serialNumber_alexa_LastVoiceCommand)
< Enter your code here once you know which Echo you are interacting from >
potencia3_value_item_tts.postUpdate(OFF)
end
I have added the item in *.items so that it will recognize it as a switch device in the Alexa APP:
Switch potencia3_value_item_tts “Potencia canal 3” { alexa=“PowerController.powerState” }