Wrap string registers to avoid propagating null bytes, helps #736#737
Open
Gnarfoz wants to merge 5 commits into
Open
Wrap string registers to avoid propagating null bytes, helps #736#737Gnarfoz wants to merge 5 commits into
Gnarfoz wants to merge 5 commits into
Conversation
Add warning to installation guide to exclude the raw entities from recorder if using PostgreSQL as a database backend
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.
As described in #736, reading the various Modbus version registers leaves some of the resulting sensors with trailing null bytes, if the string doesn't take up the full length of the registers.
This is bad because Home Assistant's recorder mechanism will try to persist these values including the null bytes. If someone is using a database backend that does not support this (like PostgreSQL), this will break recorder for them, system-wide. Recorder updates are batched, and if a batch includes an update to one of these sensors, it is effectively poisoned and will never be stored to the database.
Apart from changing the Modbus integration to provide an option to trim trailing null bytes (or do it unconditionally), wrapping the sensors in templates that do it and excluding the raw sensors from the recorder config seems like the lowest impact change to improve the situation.
I've added a warning to the installation documentation to point this out.