Appearance
Troubleshooting
Getting logs
On the LAN
bash
ssh -p 2222 pi@controlfreak.local
cd /home/pi
sudo docker compose ps
sudo docker logs --tail 200 -f controlfreak-apiOr through the API, from anywhere on the network:
bash
curl http://controlfreak.local:8000/logs
curl "http://controlfreak.local:8000/logs/controlfreak-subscriber-rs485?tail=500&grep=error"POST /diagnostics builds a zip of the last 500 lines of every controller container's log, plus the app's own log when the app sends it. The zip is over the remote size limit on most controllers, so it only works on the LAN.
Remote
Use GET /logs and GET /logs/{name}?tail=&grep=, which are trimmed to fit the remote path, or the Logs tab in iot-console, which calls the same endpoints.
Watching MQTT
bash
mosquitto_sub -h controlfreak.local -p 1515 -t 'controller/#' -vStatus topics are retained, so the first messages are the last known state of every device, not new traffic.
The API
The API keeps restarting and every remote request times out
Check the logs for an alembic error. Two migrations with the same down_revision make two heads. The production image runs alembic upgrade heads, which applies both, and tests/api/test_migrations.py fails on a second head, so this should not reach a controller. Fix a split with a merge migration. See Database API.
A new column is missing on an existing controller
Table creation on startup only creates missing tables. A column only reaches an existing database through a migration.
Every service keeps restarting
Services need the API as they start. When controlfreak-api is down or still starting, the others crash and restart until it answers. Fix the API first.
The broker
mosquitto exits at startup
mosquitto.conf ends with include_dir /mosquitto/config/conf.d, and a missing directory is fatal. Create it:
bash
sudo mkdir -p /home/pi/configs/conf.d
sudo chmod 755 /home/pi/configs /home/pi/configs/conf.d
sudo docker compose up -d --force-recreate mosquittomosquitto reports "Unable to load CA certificates" for a file that exists
A bind mount was created before its source directory existed, so Docker mounted an empty directory over it. mosquitto mounts only /home/pi/configs, and the certificates live inside it. Recreate the container so the mount is resolved again.
Remote access
The controller works on the LAN but not remotely
Work down the chain on the Pi:
GET /controller-configshowsaws_installed: installedand a thing name./home/pi/configs/conf.d/bridge.confexists and names that thing.sudo docker logs mosquittoshows the bridge connecting to AWS.controlfreak-api-bridgeis running.
When the controller provisioned but never bridged, run the installer again:
bash
curl -X POST "http://controlfreak.local:8000/controller-config/install-aws?force=true" \
-H 'Content-Type: application/json' \
-d '{"image_name": "krumcontrolfreak/controlfreak-aws-installer:latest", "container_name": "controlfreak-aws-installer"}'It skips provisioning when that is already done, and always rewrites the bridge config and restarts the broker.
The bridge connects and is dropped straight away
The bridge's client id has to be exactly the thing name. The controller policy resolves ${iot:Connection.Thing.ThingName} from the client id, and anything else fails every publish, subscribe and connect. Check clientid in bridge.conf.
A new controller never finishes web enablement
The installer waits in 04-register-thing.sh for fleet provisioning to complete. Check the device client:
bash
journalctl -u aws-iot-device-client -fRejections here usually come from the fleet-provisioning stack. The hook rejects any thing name without the controlfreak- prefix, and the template name baked into the installer has to match the stack.
Remote requests return 504
api-bridge waits 15 seconds for the API. Slow endpoints, such as POST /prepare-update while it pulls an image, time out remotely while the controller carries on. Check the result with a follow up read.
Remote requests return 413
The response was over 120 KB, and AWS IoT drops a connection past 128 KB. Use a smaller request, such as GET /logs/{name} with a lower tail, or make the call on the LAN.
The app shows nothing for a paired controller
The authorizer grants topic access from the pairing table. Check GET /fleet/pairings for the account. When the table could not be read and nothing was cached, the authorizer grants connect only, and access returns on the next connect once the table answers.
Pairing
Claiming returns 403
The pairing window was not open. Hold the two left buttons until the display shows PAIRING, then claim within 120 seconds. The window only reaches AWS over the bridge, so the controller has to be web enabled and online first.
Updates
The update screen says it failed to start
A 503 from POST /prepare-update means the controller has no internet. Any other failure to start is in controlfreak-api's logs.
An update failed
The failed updater stays running. Its logs say which step failed:
bash
sudo docker logs controlfreak-docker-updaterRestore from the app, or with POST /restore-update. See Updates.
The controller still shows update#completed or update#failed
The result stays saved until the app calls POST /clean-update. Call it by hand to clear it:
bash
curl -X POST http://controlfreak.local:8000/clean-updateA staging controller pulls production images
Images bake in DOCKER_REGISTRY at build time. A controller runs whatever org its controlfreak-api image was built for, and the app passes the updater its own EXPO_PUBLIC_DOCKER_REGISTRY. Check both point at krumware.
Hardware
RS485 commands reach the wrong device
The port to slot mapping depends on the board revision. Check the revision the worker logged at startup in controlfreak-subscriber-rs485, and see Hardware and RS485.
An RS485 device never answers
Check the device's driver, address and baud rate against the driver's DriverSpec, and that nothing else holds the port. Only subscriber-rs485 should open it. To test the unit alone, use debug-scripts/rs485-bench/, which stops the subscriber while it runs.
A dev Pi lost a setting after a flash
flash-controller-dev.sh copies your local .env over the Pi's. Put the setting back in /home/pi/.env and recreate the containers that read it. See Onboard development.