diff --git a/README.md b/README.md index 6bf7355..774f0c1 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/config.yaml.sample b/config.yaml.sample index 78b06ab..a1f6a86 100644 --- a/config.yaml.sample +++ b/config.yaml.sample @@ -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 diff --git a/src/amcrest2mqtt/mixins/helpers.py b/src/amcrest2mqtt/mixins/helpers.py index 317246f..5aad5e7 100644 --- a/src/amcrest2mqtt/mixins/helpers.py +++ b/src/amcrest2mqtt/mixins/helpers.py @@ -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")), diff --git a/uv.lock b/uv.lock index 7778322..88563a4 100644 --- a/uv.lock +++ b/uv.lock @@ -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" },