Skip to main content

MQTT control bridge for Vention popup diverters — embed in a MachineLogic snippet with one line.

Project description

vention-diverter-mqtt-bridge

An MQTT control bridge for Vention popup diverters. It wraps the published vention-popup-diverter fleet library and exposes it over a simple MQTT command protocol, so a MachineLogic program (or any MQTT client) can drive a diverter by publishing a message.

It's designed to embed in a MachineLogic Python snippet with one line — MachineLogic only runs one snippet at a time, so the bridge rides inside the snippet that's already running, in a background thread.

Use it from a MachineLogic snippet (one line)

Add the dep to your app's requirements.txt:

vention-diverter-mqtt-bridge

Then at the top of your snippet:

from diverter_bridge import run_in_background

run_in_background()        # non-blocking; bridge now serving MQTT in the background
# ... your snippet logic continues unchanged ...

run_in_background() returns immediately (it starts a daemon thread) and uses the bundled, calibrated config. Override anything from Python:

run_in_background(mode="mock")                 # bench test, no hardware
run_in_background(broker_host="127.0.0.1")     # different broker
run_in_background(fleet=[                       # different diverter / fleet
    {"location_id": "zone-a", "host": "192.168.21.20",
     "lift_speed": 600, "t_lower_from_rest": 0.5024},
])
run_in_background("config")                     # your own ./config/config.yaml

Precedence: bundled config < a config_dir you point at < keyword overrides.

The MQTT protocol

The command is the topic (empty payload). Replies on <prefix>/<location>/resultok or error: <reason>.

Full divert (one message, runs the whole sequence):

vention/diverter/<location>/divert/forward
vention/diverter/<location>/divert/backward

Granular (drive each step yourself):

vention/diverter/<location>/move/up
vention/diverter/<location>/move/down
vention/diverter/<location>/move/forward
vention/diverter/<location>/move/backward
vention/diverter/<location>/move/stop

Direction is forward/backward at both levels. divert/… = the bridge runs the sequence; move/… = manual control. See docs/adr/0002-mqtt-protocol.md.

Standalone (for local dev / testing)

just install            # uv sync
just smoke              # local broker + bridge (mock) + a test divert
just ci                 # ruff format + lint + pytest
python -m diverter_bridge      # or: python main.py   (uses bundled config)

DIVERTER_MODE=mock selects mock diverters; CONFIG_DIR points at an override config dir.

Calibration

The bundled config ships values calibrated at lift speed 600 (t_lower_from_rest, t_full_rev, t_high_range, down_dwell). Re-calibrate with the Feed's calibrate_all_diverters.py at the operating speed and update the config — calibration speed must equal run speed.

mmAI access

SSH keypair for controller serial 6020083 is in .keypairs/mmai-6020083/ (gitignored). The mmAI's LAN port reaches the diverter subnet (192.168.21.x); the diverter is at 192.168.21.20.

Docs

Living docs/ tree per the delivery standard — start at docs/README.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vention_diverter_mqtt_bridge-0.4.0.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vention_diverter_mqtt_bridge-0.4.0-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file vention_diverter_mqtt_bridge-0.4.0.tar.gz.

File metadata

  • Download URL: vention_diverter_mqtt_bridge-0.4.0.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.20 {"installer":{"name":"uv","version":"0.11.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for vention_diverter_mqtt_bridge-0.4.0.tar.gz
Algorithm Hash digest
SHA256 d6bcf37fc1efa2ca8ba4e4467e80d0cc96875394eb18c32bbf6ecf0445ca092e
MD5 4d39f5acbced2a5d3db005c118b6d109
BLAKE2b-256 be4387dcfad5d5393136f644921b400b7a4fc646bb1971619468cb01004f26b7

See more details on using hashes here.

File details

Details for the file vention_diverter_mqtt_bridge-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: vention_diverter_mqtt_bridge-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.20 {"installer":{"name":"uv","version":"0.11.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for vention_diverter_mqtt_bridge-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d86dbc1beee1bd8cdb729c3f14afddc921839c2dacdb9302a4b6bb54bf92a2e2
MD5 9896ec072c2c932ea1fec7d5b5f7ac6c
BLAKE2b-256 116c9d4b31978c77d50891d950212e9b4ea7c272a191bf89f32ba6fe03cbfaea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page