From 1d413edd02aa0befb5ed2830e91bdd18068c2ad3 Mon Sep 17 00:00:00 2001 From: Martijn Pepping Date: Tue, 3 Jan 2023 14:44:24 +0100 Subject: [PATCH] Default MQTT values (#47) * Default MQTT values prevent breaking on upgrades * Adds the GitHub pull-req add-on for VS Code --- .devcontainer/devcontainer.json | 5 +++-- solarman/helpers.py | 2 ++ solarman/mqtt.py | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 411c435..7b3f434 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -22,9 +22,10 @@ // Add the IDs of extensions you want installed when the container is created. "extensions": [ "github.copilot", + "github.vscode-pull-request-github", "ms-python.python", - "oderwat.indent-rainbow", - "ms-python.vscode-pylance" + "ms-python.vscode-pylance", + "oderwat.indent-rainbow" ] } }, diff --git a/solarman/helpers.py b/solarman/helpers.py index 5ae1909..7d76498 100644 --- a/solarman/helpers.py +++ b/solarman/helpers.py @@ -44,6 +44,8 @@ "topic": {"type": "string"}, "username": {"type": "string"}, "password": {"type": "string"}, + "qos": {"type": "integer", "minimum": 1, "maximum": 1}, + "retain": {"type": "boolean"}, }, }, }, diff --git a/solarman/mqtt.py b/solarman/mqtt.py index b7b0cdd..f25ba22 100644 --- a/solarman/mqtt.py +++ b/solarman/mqtt.py @@ -22,8 +22,8 @@ def __init__(self, config): self.port = config["port"] self.username = config["username"] self.password = config["password"] - self.qos = config["qos"] - self.retain = config["retain"] + self.qos = config.get("qos", 1) + self.retain = config.get("retain", True) self.client = Mqtt.connect(self) def connect(self):