This repository enables you to prototype an Alexa Gadget using Raspberry Pi. It includes Python-based software, sample projects, and step-by-step instructional guides that walk you through how to use key features of the Alexa Gadgets Toolkit to create new, engaging customer interactions with gadget devices.
Essentially using Kitchen Sink with an overridden load/save of the .agt.json (as I needed it to be stored elsewhere) inside a Docker container with network_mode: host and everything needed for Bluetooth to work
(Log at the bottom)
It pairs initially and all works fine, I get directives, the .agt.json gets saved (to /data/agt.json) and that can be seen that it does save as it tries to reconnect when the script starts again
But for some reason it adamantly refuses to reconnect (just keeps trying with no luck). I also tried reconnecting in this state from the Echo without any luck either.
Logging level is set to DEBUG too, no helpful debug entries to be seen.
Under what circumstance would this occur? Is it possible the bluetooth address is changing or something stupid like that?
EDIT: Bluetooth address doesn't change and is consistently B827EB543E53. Is there standard bluetooth pairing information being handled outside the script that I might need to make persistent? I'm not overly familiar with Python + Bluetooth...
EDIT2: Found /var/lib/bluetooth with a bit of tinkering with a "Changed in the last minute" command, after binding it to a volume everything now works as it should. I should have experimented a bit more before posting an issue but I hope this helps anyone who wants to do an AGT project within Docker (and possibly Balena which I'm using) as it's a bit of a niche mixture.
For anyone who has the same problem: Essentially you just need to make sure you persist the .agt.json and keep /var/lib/bluetooth as a persistent volume and you're good. network_mode: host also needs to be set so highly recommend doing this via docker-compose.yml if you're using Balena.
02.11.19 15:44:21 (+0000) <gadget> Launching Alexa Gadget...
02.11.19 15:44:21 (+0000) <gadget> Reading in /data/agt.json
02.11.19 15:44:22 (+0000) <gadget> Starting Web Server...
02.11.19 15:44:23 (+0000) <gadget> * Serving Flask app "web" (lazy loading)
02.11.19 15:44:23 (+0000) <gadget> * Environment: production
02.11.19 15:44:23 (+0000) <gadget> WARNING: This is a development server. Do not use it in a production deployment.
02.11.19 15:44:23 (+0000) <gadget> Use a production WSGI server instead.
02.11.19 15:44:23 (+0000) <gadget> * Debug mode: off
02.11.19 15:44:23 (+0000) <gadget> INFO:werkzeug: * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
02.11.19 15:44:25 (+0000) <gadget> INFO:agt.alexa_gadget:Now in pairing mode. Pair "LED Timer" in the Alexa App.
02.11.19 17:28:36 (+0000) <gadget> INFO:agt.alexa_gadget:Connected to Echo device with address: 44:65:0D:88:54:AD
02.11.19 17:28:36 (+0000) <gadget> Writing to /data/agt.json
02.11.19 17:28:36 (+0000) <gadget> Connected to Alexa: 44:65:0D:88:54:AD
02.11.19 17:28:36 (+0000) <gadget> DEBUG:agt.alexa_gadget:Received directive from Echo device: { {'header': {'namespace': 'Alexa.Discovery', 'name': 'Discover', 'messageId': '', 'dialogRequestId': ''}, 'payload': {'scope': {'type': '', 'token': ''}}} }
02.11.19 17:28:36 (+0000) <gadget> DEBUG:agt.alexa_gadget:Sending event to Echo device: { {'header': {'namespace': 'Alexa.Discovery', 'name': 'Discover.Response', 'messageId': ''}, 'payload': {'endpoints': [{'endpointId': '<SNIP>', 'friendlyName': 'LED Timer', 'description': 'Alexa Gadget', 'manufacturerName': 'AGT', 'capabilities': [{'type': 'AlexaInterface', 'interface': 'Alexa.Gadget.StateListener', 'version': '1.0', 'configuration': {'supportedTypes': [{'name': 'timeinfo'}, {'name': 'timers'}, {'name': 'alarms'}, {'name': 'reminders'}, {'name': 'wakeword'}]}}, {'type': 'AlexaInterface', 'interface': 'Alerts', 'version': '1.1'}, {'type': 'AlexaInterface', 'interface': 'Notifications', 'version': '1.0'}, {'type': 'AlexaInterface', 'interface': 'Alexa.Gadget.MusicData', 'version': '1.0', 'configuration': {'supportedTypes': [{'name': 'tempo'}]}}, {'type': 'AlexaInterface', 'interface': 'Alexa.Gadget.SpeechData', 'version': '1.0', 'configuration': {'supportedTypes': [{'name': 'viseme'}]}}], 'additionalIdentification': {'firmwareVersion': '1', 'deviceToken': '<SNIP>', 'deviceTokenEncryptionType': '1', 'amazonDeviceType': '<SNIP>', 'modelName': 'Alexa Gadget', 'radioAddress': '<SNIP>'}}]}} }
02.11.19 17:28:37 (+0000) <gadget> DEBUG:agt.alexa_gadget:Received directive from Echo device: { {'header': {'namespace': 'Notifications', 'name': 'ClearIndicator', 'messageId': '', 'dialogRequestId': ''}} }
02.11.19 17:28:37 (+0000) <gadget> Got ClearIndicator
02.11.19 17:28:37 (+0000) <gadget> DEBUG:agt.alexa_gadget:Received directive from Echo device: { {'header': {'namespace': 'Alexa.Gadget.StateListener', 'name': 'StateUpdate', 'messageId': '', 'dialogRequestId': ''}, 'payload': {'states': [{'name': 'timeinfo', 'value': '2019-11-02T17:28:37+00:00'}]}} }
02.11.19 17:28:37 (+0000) <gadget> state name:timeinfo, state value:2019-11-02T17:28:37+00:00
02.11.19 17:28:37 (+0000) <gadget> DEBUG:agt.alexa_gadget:Received directive from Echo device: { {'header': {'namespace': 'Alerts', 'name': 'SetAlert', 'messageId': '', 'dialogRequestId': ''}, 'payload': {'token': '<SNIP>', 'type': 'TIMER', 'scheduledTime': '2019-11-02T17:57:52+00:00', 'assetPlayOrder': [], 'loopPauseInMilliSeconds': 0, 'assets': [], 'loopCount': 0, 'backgroundAlertAsset': ''}} }
02.11.19 17:28:37 (+0000) <gadget> Got SetAlert
----- RESTARTED SCRIPT HERE -----
02.11.19 17:30:11 (+0000) <gadget> Launching Alexa Gadget...
02.11.19 17:30:11 (+0000) <gadget> Reading in /data/agt.json
02.11.19 17:30:12 (+0000) <gadget> Starting Web Server...
02.11.19 17:30:12 (+0000) <gadget> * Serving Flask app "web" (lazy loading)
02.11.19 17:30:12 (+0000) <gadget> * Environment: production
02.11.19 17:30:12 (+0000) <gadget> WARNING: This is a development server. Do not use it in a production deployment.
02.11.19 17:30:12 (+0000) <gadget> INFO:agt.alexa_gadget:Attempting to reconnect to Echo device with address: 44:65:0D:88:54:AD
02.11.19 17:30:12 (+0000) <gadget> Use a production WSGI server instead.
02.11.19 17:30:12 (+0000) <gadget> * Debug mode: off
02.11.19 17:30:12 (+0000) <gadget> INFO:werkzeug: * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
02.11.19 17:30:23 (+0000) <gadget> INFO:agt.alexa_gadget:Attempting to reconnect to Echo device with address: 44:65:0D:88:54:AD
02.11.19 17:30:37 (+0000) <gadget> INFO:agt.alexa_gadget:Attempting to reconnect to Echo device with address: 44:65:0D:88:54:AD
02.11.19 17:30:48 (+0000) <gadget> INFO:agt.alexa_gadget:Attempting to reconnect to Echo device with address: 44:65:0D:88:54:AD
02.11.19 17:30:59 (+0000) <gadget> INFO:agt.alexa_gadget:Attempting to reconnect to Echo device with address: 44:65:0D:88:54:AD
02.11.19 17:31:13 (+0000) <gadget> INFO:agt.alexa_gadget:Attempting to reconnect to Echo device with address: 44:65:0D:88:54:AD
02.11.19 17:31:44 (+0000) <gadget> INFO:agt.alexa_gadget:Attempting to reconnect to Echo device with address: 44:65:0D:88:54:AD
02.11.19 17:31:55 (+0000) <gadget> INFO:agt.alexa_gadget:Attempting to reconnect to Echo device with address: 44:65:0D:88:54:AD
Essentially using Kitchen Sink with an overridden load/save of the .agt.json (as I needed it to be stored elsewhere) inside a Docker container with
network_mode: host
and everything needed for Bluetooth to work(Log at the bottom)
It pairs initially and all works fine, I get directives, the .agt.json gets saved (to /data/agt.json) and that can be seen that it does save as it tries to reconnect when the script starts again
But for some reason it adamantly refuses to reconnect (just keeps trying with no luck). I also tried reconnecting in this state from the Echo without any luck either.
Logging level is set to DEBUG too, no helpful debug entries to be seen.
Under what circumstance would this occur? Is it possible the bluetooth address is changing or something stupid like that?
EDIT: Bluetooth address doesn't change and is consistently B827EB543E53. Is there standard bluetooth pairing information being handled outside the script that I might need to make persistent? I'm not overly familiar with Python + Bluetooth...
EDIT2: Found
/var/lib/bluetooth
with a bit of tinkering with a "Changed in the last minute" command, after binding it to a volume everything now works as it should. I should have experimented a bit more before posting an issue but I hope this helps anyone who wants to do an AGT project within Docker (and possibly Balena which I'm using) as it's a bit of a niche mixture.For anyone who has the same problem: Essentially you just need to make sure you persist the .agt.json and keep /var/lib/bluetooth as a persistent volume and you're good.
network_mode: host
also needs to be set so highly recommend doing this viadocker-compose.yml
if you're using Balena.