Run local shell commands from MQTT topics. Inspired by mac2mqtt, but intended to work across operating systems.
- Copy the sample config:
cp computer2mqtt-example.yaml computer2mqtt.yaml
- Edit
computer2mqtt.yamlwith your MQTT broker and commands. - Run directly without installing:
uvx computer2mqtt --config computer2mqtt.yaml
Install once, then call the command directly:
uv tool install computer2mqtt- Run:
computer2mqtt --config computer2mqtt.yaml - Upgrade later:
uv tool upgrade computer2mqtt
This package also exposes an alias command:
c2m --config computer2mqtt.yaml
- Run latest published version directly:
uvx computer2mqtt --config computer2mqtt.yaml - Run the alias directly:
uvx --from computer2mqtt c2m --config computer2mqtt.yaml
The service subscribes to:
mac2mqtt/<hostname>/command/#
For each configured command key (for example displaysleep), publish:
- Topic:
mac2mqtt/<hostname>/command/displaysleep - Payload:
displaysleep
See computer2mqtt-example.yaml for a full config example.
Requirements:
Setup:
direnv allow
Code quality hooks are managed with prek:
uv run prek run --all-files