feat: add encoder_leak, endpoint_reading_missed, device_alert binary sensors#178
Open
GeorgeIoak wants to merge 2 commits intokdeyev:masterfrom
Open
feat: add encoder_leak, endpoint_reading_missed, device_alert binary sensors#178GeorgeIoak wants to merge 2 commits intokdeyev:masterfrom
GeorgeIoak wants to merge 2 commits intokdeyev:masterfrom
Conversation
…sensors Add three new binary sensor descriptions that are present in the EyeOnWater API response flags but were not yet exposed as entities: - encoder_leak (MOISTURE) — secondary leak indicator from the encoder - endpoint_reading_missed (PROBLEM) — meter failed to report on schedule - device_alert (PROBLEM) — general device-level alert condition All three are disabled by default (entity_registry_enabled_default=False) so they have no impact on existing users. Users can enable them individually in the HA entity registry if needed. Also adds enabled_by_default field to the Description dataclass and wires it through to BinarySensorEntityDescription.entity_registry_enabled_default, and switches get_flag() from __dict__ lookup to getattr(..., False) to avoid KeyError on meters that do not carry all flag fields. Tests cover catalog presence, device class, enabled_by_default values, get_flag behaviour, and graceful handling of missing flag attributes.
- Bump manifest version from 2.7.9-beta.1 to 2.7.10-beta.1 (required by version-check CI for PRs that touch Python source files) - Apply black formatting to tests/test_binary_sensor.py (long method signatures now wrapped per black's style + COM812 trailing commas) - Fix test_get_flag_missing_field_returns_false: remove invalid `del __dataclass_fields__` (class attribute, not deletable via instance); FakeFlags already doesn't define 'nonexistent_flag' so getattr fallback is exercised correctly without any setup
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.
Summary
Exposes three binary sensor flag fields that are present in the EyeOnWater API response but not yet surfaced as Home Assistant entities:
encoder_leak(BinarySensorDeviceClass.MOISTURE) — secondary leak indicator reported by the encoder mechanismendpoint_reading_missed(BinarySensorDeviceClass.PROBLEM) — meter endpoint failed to report on scheduledevice_alert(BinarySensorDeviceClass.PROBLEM) — general device-level alert conditionAll three are disabled by default (
entity_registry_enabled_default=False), so there is zero impact on existing users. Users who want them can enable them individually in the HA entity registry.Other changes in this PR
enabled_by_default: bool = Truefield to theDescriptiondataclass and wires it through toBinarySensorEntityDescription.entity_registry_enabled_defaultget_flag()fromflags.__dict__[key]togetattr(flags, key, False)— preventsKeyErroron meters that do not include all flag fields in their API response (important for new sensors that older meter firmware may not populate)tests/test_binary_sensor.pywith tests covering catalog presence, device class,enabled_by_defaultvalues,get_flagbehaviour, and graceful handling of missing flag attributesFakeFlagsintests/conftest.pyto include the three new fieldsTest plan
poetry run pytest— all existing tests plus newtests/test_binary_sensor.pypasspoetry run ruff check .— no lint errors