MQTT sink with Home Assistant discovery - #5
Closed
ichnograph wants to merge 2 commits into
Closed
Conversation
The writer divided power by 1000 and max power by 100, assuming the milliwatt units of the M-Bus library used before the gombus migration. The domain values have been plain watts since then, so QuestDB heat power readings were three orders of magnitude off. The other sinks already stored watts.
Publishes every reading as JSON under a configurable topic prefix and announces retained Home Assistant discovery configs, so each meter shows up as a device with typed sensors and the energy and gas sensors slot into the Energy dashboard without any YAML. Availability rides a last-will status topic; the broker connection registers as a health check. One shared client per process, created lazily by the first enabled sink builder.
Contributor
Author
|
Rolled into the 1.4.0 PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an MQTT sink that makes every source visible in Home Assistant with zero YAML on the HA side.
What it does
<TopicPrefix>/<measurement>(duco and solar inverters follow the same per-table split as the database sinks).<prefix>/statustopic; the broker connection registers as a readiness check; one shared client per process.MQTT(broker URL, credentials, prefix, discovery toggle and prefix, QoS 0/1, retain). Counts toward the at-least-one-sink rule.Bug fix included (first commit)
While aligning units, the QuestDB heat writer turned out to divide power by 1000 and max power by 100, left over from the milliwatt units of the pre-fork M-Bus library. Heat power in QuestDB has been three orders of magnitude too small since the gombus migration; the SQL sinks were already correct. Now fixed; existing QuestDB heat power history will show a step change.
Tested against a recording fake client (golden discovery payloads, retain/QoS, LWT lifecycle, error propagation). Coverage 82.7%, lint 0 issues, race suite green.