Repository navigation
Report input type and unit of values - #52
Merged
Merged
Conversation
nielstron
force-pushed
the
feature/input-type-units
branch
from
November 16, 2026 14:27
8611caa to
d3c39a5
Compare
nielstron
force-pushed
the
fix/direct-robustness
branch
from
November 16, 2026 14:27
466579a to
aded4a7
Compare
nielstron
force-pushed
the
feature/input-type-units
branch
from
November 16, 2026 14:35
d3c39a5 to
8c8f2fd
Compare
When connecting to one of the resolved addresses failed, the socket was dropped without closing it, which Python 3.14+ reports as ResourceWarning. Only catch OSError instead of everything. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BLNETDirect always used its default of 60 seconds, so a BL-NET that stopped answering blocked fetch() for a minute regardless of the timeout given to BLNET. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A timeout or other error while reading left the socket open, and since _connect() only connects without a socket, every later call reused the dead connection. A BLNET object, as kept by Home Assistant, never recovered until it was recreated. - Close the socket and reset the read state on any error in get_latest, get_count, _get_data and the mode check in the constructor, which also leaked its socket on timeout - Raise ConnectionError when the BL-Net closes the connection or sends a malformed reply instead of IndexError or struct.error - Use sendall instead of send - _get_data no longer swallows errors with a return in finally Errors from the direct connection are now always OSError subclasses: ConnectionError or TimeoutError. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A real BL-Net answers GET_LATEST with a single 0xAB byte ("no data
available", see TA's interface spec) for up to about 5 seconds after a
read. The retries ran without any pause, so every read shortly after
the previous one failed with ConnectionError. Wait 2 seconds after such
a reply before the next try.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BL-NETs sometimes send the first byte of a GET_LATEST reply in a TCP segment of its own. _query() stopped after that byte, so the rest of the reply was read as the start of the next one and all following replies were shifted by one byte. The sum checksum accepts about one in 128 of those shifted datasets, which showed up as occasional garbage values like -3807 °C or jumps of the energy meter. Derive the reply length from its first byte and read it completely, and reconnect after a reply with a bad checksum so that stray bytes can't end up in the next reply. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KJJTUv5YaVyYB197zeuqBp
Home Assistant showed every analog input in °C and speed in rpm. The parser already read the input type bits but dropped them. - BLNETParser exposes analog_types: temperature, volume_flow, radiation, digital or None for unused and undocumented types - BLNET.fetch() adds type and unit_of_measurement to analog entries from the direct connection, and type (derived from the shown unit) to entries from the web interface - speed, energy and power entries carry unit_of_measurement: None (speed is a level 0-30, not rpm), kWh and kW Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nielstron
force-pushed
the
feature/input-type-units
branch
from
November 16, 2026 14:58
8c8f2fd to
2bd9969
Compare
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.
Cherry-picked from #48 (by Alexander Eisele), without the fork-specific changes (uv migration, Python 3.11 requirement, pyupgrade, PyPI/README fork changes, CLAUDE.md, version bumps).
Depends on #51, whose commits it includes: merge it first, then this diff shrinks to its own commit. This one is a feature, not a fix.
BLNETParserexposesanalog_types(temperature, volume_flow, radiation, digital, or None).BLNET.fetch()addstypeandunit_of_measurementto analog entries from the direct connection, andtype(derived from the shown unit) to web entries.unit_of_measurement: None (speed is a level 0-30, not rpm), kWh, kW.