feat: add support for MQTT v3.1.1 protocol version

Add configurable MQTT protocol version support to allow users to choose
between MQTT v5 (default) and v3.1.1 for broker compatibility.

Changes:
- Add protocol_version option to MQTT configuration in config.yaml.sample
- Add MQTT_PROTOCOL environment variable support in helpers.py
- Update README.md with MQTT_PROTOCOL documentation
- Update mqtt-helper-graystorm package to latest version with protocol support

The protocol_version accepts "3.1.1" or "5" (default: "5") and can be
configured via config.yaml or the MQTT_PROTOCOL environment variable.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
pull/106/head
Jeff Culverhouse 4 weeks ago
parent 76a62a424a
commit 58a09548dd

@ -31,6 +31,7 @@ It supports the following environment variables - but these are a pain, the conf
- `MQTT_HOST` (optional, default = 'localhost')
- `MQTT_QOS` (optional, default = 0)
- `MQTT_PORT` (optional, default = 1883)
- `MQTT_PROTOCOL` (optional, default = '5') - MQTT protocol version: '3.1.1' or '5'
- `MQTT_TLS_ENABLED` (required if using TLS) - set to `true` to enable
- `MQTT_TLS_CA_CERT` (required if using TLS) - path to the ca certs
- `MQTT_TLS_CERT` (required if using TLS) - path to the private cert

@ -4,6 +4,7 @@ mqtt:
username: mqtt
password: password
qos: 0
protocol_version: "5" # MQTT protocol version: "3.1.1" or "5" (default: "5")
prefix: amcrest2mqtt
discovery_prefix: homeassistant
tls_enabled: False

@ -200,6 +200,7 @@ class HelpersMixin:
"host": str(mqtt.get("host") or os.getenv("MQTT_HOST", "localhost")),
"port": int(str(mqtt.get("port") or os.getenv("MQTT_PORT", 1883))),
"qos": int(str(mqtt.get("qos") or os.getenv("MQTT_QOS", 0))),
"protocol_version": str(mqtt.get("protocol_version", os.getenv("MQTT_PROTOCOL", "5"))),
"username": str(mqtt.get("username") or os.getenv("MQTT_USERNAME", "")),
"password": str(mqtt.get("password") or os.getenv("MQTT_PASSWORD", "")),
"tls_enabled": bool(mqtt.get("tls_enabled") or (os.getenv("MQTT_TLS_ENABLED", "false").lower() == "true")),

@ -464,7 +464,7 @@ sdist = { url = "https://files.pythonhosted.org/packages/93/4b/979db9e44be09f71e
[[package]]
name = "mqtt-helper-graystorm"
version = "0.1.0"
source = { git = "https://github.com/weirdtangent/mqtt-helper.git?branch=main#44eeeb0d2559cfa6ae141c623ecda72502a891e5" }
source = { git = "https://github.com/weirdtangent/mqtt-helper.git?branch=main#58cd02c2c9675830feb5b433aff5b5a517572c56" }
dependencies = [
{ name = "logging" },
{ name = "paho-mqtt" },

Loading…
Cancel
Save