celestianctl
Tools/celestianctl.py is a small MQTT client for sending settings and commands to Sentinel and watching all its messages. It uses paho-mqtt.
Setting up
Section titled “Setting up”python3 -m venv .venv && .venv/bin/pip install -r requirements.txtThe examples below use python3; replace with .venv/bin/python if paho-mqtt is not installed in the system Python.
Broker target
Section titled “Broker target”The default is the DC Gateway’s local broker (topics sentinel/<mac>/…, anonymous):
| Option | Meaning |
|---|---|
--host |
broker address (default localhost; the gateway IP, e.g. 10.10.0.1) |
--port |
port (default 1883; gateway: 11884 for MQTT 5, 11883 for MQTT 3.1.1) |
To go directly through Celestian, add --workspace, --channel, and --user <device ID>, with the device key in the environment variable CELESTIAN_DEVICE_KEY. That device needs publish (and subscribe for watch) connections to the channel. The client_id is automatically prefixed with the device ID per the broker policy.
export CELESTIAN_DEVICE_KEY='<device key>'python3 Tools/celestianctl.py --host broker.contoh --workspace dc-magna --channel rak \ --user <device ID> cmd a2cb8ff8768d identifyCommands
Section titled “Commands”# configuration (retained); values are read as JSON when possiblepython3 Tools/celestianctl.py config a2cb8ff8768d cfg_ver=2 telemetry_interval_ms=30000 temp_alarm_c=38python3 Tools/celestianctl.py config a2cb8ff8768d d1_type=door t2_label=Bawah t2_alarm_c=30
# commandspython3 Tools/celestianctl.py cmd a2cb8ff8768d rebootpython3 Tools/celestianctl.py cmd a2cb8ff8768d identify seconds=60python3 Tools/celestianctl.py cmd a2cb8ff8768d rescanpython3 Tools/celestianctl.py cmd a2cb8ff8768d ota url=/fw/snt-g1/edge-snt-g1-idf-0.21.1.bin
# rules (replaces the WHOLE set)python3 Tools/celestianctl.py rules a2cb8ff8768d --file Tools/rules-contoh.jsonpython3 Tools/celestianctl.py rules a2cb8ff8768d --file rules.json --confirm-s 120python3 Tools/celestianctl.py rules a2cb8ff8768d --confirm 8a3030f6python3 Tools/celestianctl.py rules a2cb8ff8768d --getpython3 Tools/celestianctl.py rules a2cb8ff8768d --clear
# Modbus sources, profiles, telemetry groups (similar options: --file, --get, --clear, --confirm-s, --confirm, --rollback)python3 Tools/celestianctl.py sources a2cb8ff8768d --file Tools/sources-contoh-profil.jsonpython3 Tools/celestianctl.py profiles --listpython3 Tools/celestianctl.py profiles a2cb8ff8768d --sources Tools/sources-contoh-profil.jsonpython3 Tools/celestianctl.py tgroups a2cb8ff8768d --file tgroups.json
# watch all messagespython3 Tools/celestianctl.py watchNames and ROMs that could be read as numbers need JSON quotes: t1_rom='"28a54dca18253061"'.
rules,sources,profiles, andtgroupscheck the size limits first and print thecrc32of the message sent;--getcompares it with thehashreported by the node.--versets the version number; the default is the current time (always rising).- For
sources,--model snt-g1uses the G1 limits. profiles --sourcesimitates what the server would do: it computes the profiles referenced by the installation from theTools/profil-modbus/library and sends only those.