MQTT to SpaceAPI bridge. This script is used to connect the internal (or home user) MQTT broker with the public spaceAPI, updating the sensors spacestate and annexes (branch location) states.
Assuming python3 is installed and the system is debian-alike;
- install
git,pipandpaho-mqtt:sudo apt install git python3-pippip3 install paho-mqtt
- clone this repo locally:
- Copy over systemd service file (edit
Environmentvariables,UserandExecStartpath) and enable the servicesudo cp mqtt_spaceapi.service /etc/systemd/system/sudo systemctl enable mqtt_spaceapi.service
- optionally modify
mqtt_spaceapi.pyand change "Custom annex topic"mqtt_sensor_topicsandmqtt_spacestate_topic - run the script inside a screen/tmux (or nohup) session (change
BROKER,API_KEYandANNEXaccordingly):BROKER=192.168.1.42 API_KEY=ABC ANNEX="@xopr's" USER=ackspace PASS=ackspace ./mqtt_spaceapi.py
Note that the values can also be set as environment variables.
Mandatory variables:
BROKER: IP or FQDN/hostname of MQTT (mosquitto) broker/serverAPI_KEY: The ACKspace API key for updating the spaceAPI
Optional variables:
ANNEX: name of an annex location, for example@xopr's: omit completely to update the actual spacestateDEBUG: enable debug data on both client and spaceAPI serverUSER: MQTT username,ackspacefor read-only accessPASS: MQTT password,ackspacefor read-only access