internal/alexa/command.go, internal/device/mapdb.go, and the text entity
and user service in internal/esphome. Off only while the Dot is registered
to no Amazon account; then the entity is never advertised.
- Audio cannot be injected into Alexa on this device. On Fire OS 5
amazon.speech.simfired the wake word and opened a real cloud session, but only the detector heard the file. The upload still came from the live microphone. - "Alexa" plus 8 seconds of silence, and "Alexa, play dance party music on Amazon Music", both ended at about 1.1 seconds (1.16 and 1.11), because the command audio never arrived.
SpeechRecognizer_ExpectSpeechdid not help: it opened 0.79 seconds into the injected speech and ended 199 ms later.- The
avs-device-sdkrecipe does not transfer: there the injector replaces the microphone the whole SDK reads from. - So a command goes through
/api/behaviors/previewasAlexa.TextCommand. That is the Alexa app's own endpoint, and the only layer that takes text. The cloud then runs the command inside the Dot's own session, and the Dot answers out loud as it does to speech. - The Dot is found by
ro.serialnoin the account's device list, so the command lands on this Echo, not on the first one listed.
Measured 2026-11-14 from the Dot, with its own identity.
- The Dot's AVS gateway,
alexa.na.gateway.devices.a2z.com/v20160207/events, takes the Dot's access token: aSystem.SynchronizeStateevent answered204. The token comes fromPOST api.amazon.com/auth/tokenwith therefresh_token,reg_app_nameandreg_app_versionthe store holds, which is the call the Dot's own MAP library makes. - No text event is accepted there.
Alexa.Input.TextwithTextMessage,TextInput,RecognizeandSendText, under several payload shapes, each answered400 INVALID_REQUEST_EXCEPTION "Bad Request". So did an invented namespace and aSpeechRecognizer.Recognizewith no audio: the error does not tell an unknown interface from a wrong payload, so there is nothing to iterate against, and nothing public documents the event. The name appears only in the capability lists app emulators register. - It would not make the Dot speak anyway. AVS answers an event on the connection that sent it, not on the Dot's downchannel, so the reply would arrive here as MP3, which this daemon does not decode.
- On Fire OS 6 the credential is in the clear.
/data/ace/kvstorage/map.db(ace_maplite,0660) is an ordinary SQLite file whose one table isdeviceData (key TEXT PRIMARY KEY, value BLOB NOT NULL).refresh_tokenis 353 characters startingAtnr|;access_token,adp_tokenanddevice_private_keysit beside it, also in the clear. Root reads it, and the daemon is root. biscuit, radar and donut all hold it there. - Fire OS 5 kept it encrypted in MAP's Android store, and only MAP's own uid
could decrypt it. That is what
MapDump.javawas for: a jar run throughapp_processas uid 32051. Fire OS 6 has neitherapp_processnor that store, so the jar, its build,/data/local/mapand thesulookup are gone. internal/device/mapdb.goreads the file itself: the header, the table's root page out ofsqlite_master, the interior and leaf pages under it, and the overflow chain of any value longer than a page holds. The store is 1 KB pages, its table root is an interior page, and two values overflow, so every path runs on the real file. The fixtures underinternal/device/testdata/have the same shape and are built bymapdb.pythere;mapdb_test.goalso truncates the registered fixture at every length and corrupts it at every offset, and the reader must return an error and never panic.- No SQLite library. The device's
libsqlite.sowould need cgo and could be tested only on the Dot; the reader is a few hundred lines that fixtures check in isolation, which is the rule in constraints.md. - The file is read twice, 50 ms apart, and used only when both reads agree
and no hot
map.db-journalis beside it. Alexa rewrites the store about once an hour when she refreshes the access token, and a read that landed mid-write would hand half a token to Amazon as the credential. A read that does not settle in 5 tries is an error, not a reading. - A journal is hot when its header carries SQLite's magic. Its size says nothing: PERSIST mode leaves the file after every commit with the header zeroed, and TRUNCATE mode leaves it empty. The Dots run DELETE mode, with no journal file between writes, so the check matters only if that changes.
- The header must say rollback-journal mode (bytes 18 and 19 are 1) and
UTF-8. A WAL store keeps committed rows in
map.db-wal, so the main file lags; a UTF-16 store would match no key and read as unregistered. Either is no reading. The file's size is checked before it is read, 16 MB at most. - The read costs two file reads and the 50 ms gap. That is on
serveAPI's cold-boot path, ahead of the firewall rule and the responder; thedumpsys accountread it replaced took 1.5 s and was gated behind the jar stat for that reason. 50 ms is not. - The value must have no whitespace and be 16 to 4,096 bytes before it is
used, as MapDump's output had to be. Otherwise a wrong key or a damaged row
is posted to
api.amazon.comand comes back as an opaque 400. - The token is held in memory for the life of the process, and a refusal drops it and reads the store again, once. A refusal is a 400, 401 or 403, or an authenticated call that answers without what it should: a stale session can answer 200 with a sign-in page or an empty device list, and both count.
- The token never reaches the log. Error bodies that could carry it are withheld, and the cookies it buys are struck out of every error reported.
exchangeCookiesasks for.amazon.com, as the Alexa app does. The reply isat-main,sess-at-main,session-id,session-token,ubid-mainandx-main: a signed-in amazon.com retail session, not an Alexa-scoped one.- Asking for less does not get less.
.alexa.amazon.comreturns the same six cookies, keyed.amazon.com, and the command still works. TheDomainthis code stamps binds nothing at Amazon's end. - So the feature's scope is the whole account, and there is no opt-in: every
registered Dot offers the box. Release installs already did, because the
tarball carried the jar and
install.pyinstalled it whenever present. The only lever is the registration. SECURITY.md and README.md say so.
Measured 2026-11-14 on overdub-test, one command per variant.
- Nothing on the Dot sends a
User-Agent.libace_connectivity_manager.soembeds the header set of every endpoint the device's native stack calls:api.amazon.com/auth/tokengetsContent-Typealone, MAP's other calls getaccept-language,content-type,authorizationand thex-adp-*signature headers, and the AVS gateway getsauthorization: Bearer. A scan of every binary and library found an agent string only insntp. So there is no device agent to copy, and none to fetch per model. api.amazon.comaccepts the device's shape. The cookie exchange with noUser-Agent, nox-amzn-identity-auth-domainand nodi.*fields returned the six cookies and the command ran.app_nameis the one field Amazon insists on: without it,400 MissingValue: The request is missing a required parameter : app_name. So the exchange sendsContent-Type, and the formapp_name,source_token,source_token_type,requested_token_typeanddomain.alexa.amazon.comdoes not. With noUser-Agent,/api/languageanswers without thecsrfcookie and nothing after it can run. Nothing on the Dot ever talks to that host; its client is the Alexa app, so the daemon sends the app's set, taken from alexa-cookie, which copies the iOS app:AmazonWebView/Amazon Alexa/2.2.651540.0/iOS/18.3.1/iPhone,Accept: application/json,Accept-Language,Accept-Charset: utf-8andConnection: keep-alive. The old agent was that shape with the Dot's model and an invented version, which no client ever sent.
- A text entity
alexa_commandand a user servicesend_command: one for a person on the device page, one for an automation. Both end incommandLocked, and both are listed only onceUseCommandhas a sender. - A send can take minutes: each of the 4 HTTP requests has 30 seconds, and an auth failure runs the attempt twice. So a worker sends, never the read loop.
- Commands queue 4 deep, and the fifth is refused and logged. Unlike playback, the latest does not replace the rest: two commands are two requests, and an automation that sets a timer then turns on a lamp must not lose the timer. The bound stops a peer with the key from queuing without limit.
- The worker echoes each command into the entity's state, so the box shows the last command and a later subscriber sees the same.
- The box starts with an empty state. Home Assistant draws a text entity that never had a state as unavailable, and an unavailable box cannot be typed into, so it would stay grey for ever.
- A command is peer text, so the log cuts it to the peer-string length. The
failure line is not cut again: the reason is the daemon's own, and
clipalready bounds every quoted body at 300 bytes. A 64-byte cut would end mid-reason. The retry reports only the second refusal. Both lines go through the peer rate limit. - Empty text is published but not sent. Home Assistant clears the box by writing an empty string; keeping the last command would snap the card back to text somebody just deleted.
- The clear rides the queue. A clear judged against the published state while a command is queued sees the state before that command, is dropped as redundant, and the command it meant to erase then overwrites it.
- Text longer than
commandMaxLengthis refused, not trimmed. The listing binds only Home Assistant's field; a peer with the key can send a whole frame, and every byte would reach the recorder and Amazon. The check is at both doors and counts runes, as Home Assistant does: 200 CJK characters pass its field and are 600 bytes.
- The credential is the registration.
device.AlexaRegisteredreads the same store: arefresh_tokenrow is registered; a store without the row, without the table or empty is not; and a store that is missing, cannot be read or does not parse is no reading. Every Dot seen has the file, registered or not: the ACE stack creates its stores at first boot, as the 0-byte ones beside it show. So a missing file is a Dot in a state nobody measured, and the box fails open there as the old reading did when its service was not up.binary_sensor.<name>_alexa_registeredreports it; docs/api.md has the tick. - Fire OS 5 read
dumpsys account. Fire OS 6 has no account service: the call answersCan't find service: account, so on it the old reading was never taken and the sensor stayed unknown. commandReadyfails open on the reading. "Not registered" hides the box; a reading that could not be taken does not. That is the one case where the box is offered and still fails, and the failure names the store.- Without the check, an unregistered Dot offers a box whose every command
fails with
token: /data/ace/kvstorage/map.db holds no refresh_token. - A Dot with no account is asked again every 5 minutes, and stops once it has one. It costs two reads of a 10 KB file.
- Offering the box late drops every connection, as
UsePlaydoes, because Home Assistant reads the entity list once per connection. - A Dot deregistered while the daemon runs keeps a box that fails.
- Registration is Alexa's own process: set the button to
pass through, hold it until the ring turns orange, and add the device in the Alexa app. - Nothing here runs it, but on Fire OS 5 this intent started setup mode without the button:
am startservice -a com.amazon.device.oobe.services.action.SETUP_MODE_ON \
-n com.amazon.echo.csm.oobe/.services.SonarOOBEMainService --ei reason 2reasonmust be 2,OOBE_ENABLED_BUTTON_PRESS. Without it,logcat -s AmazonOOBE.SonarOOBEMainServicereportsStart/Stop Reason = 0and setup mode does not start.- Setup mode shows as an address on
p2p0, the Dot's own network. It takes the Dot off the LAN.