Skip to content

Modernize entity lifecycle and handle unavailable humidity sensorsUpdate binary_sensor.py - #58

Open
Corsw wants to merge 1 commit into
basschipper:masterfrom
Corsw:modernize-home-assistant
Open

Modernize entity lifecycle and handle unavailable humidity sensorsUpdate binary_sensor.py#58
Corsw wants to merge 1 commit into
basschipper:masterfrom
Corsw:modernize-home-assistant

Conversation

@Corsw

@Corsw Corsw commented Jul 23, 2026

Copy link
Copy Markdown

Summary

This pull request modernizes the binary sensor entity while preserving the
existing periodic humidity-rise detection behaviour.

Changes

  • Use BinarySensorEntity
  • Register the periodic callback in async_added_to_hass
  • Automatically remove the callback when the entity is removed
  • Disable Home Assistant polling because the entity manages its own interval
  • Treat missing, unknown and unavailable source sensors as temporary states
  • Mark the entity unavailable while the source sensor is unavailable
  • Preserve warnings for invalid sensor values or missing attributes
  • Validate that sample_interval is greater than zero
  • Prevent an empty sample buffer
  • Safely handle calculations before samples are available
  • Check max_on_time even while the source sensor is unavailable
  • Prevent immediate reactivation after max_on_time
  • Use extra_state_attributes
  • Add readable debugging values for the target and timers
  • Add state-dependent water icons

Behaviour preserved

The integration still samples the source sensor periodically and compares the
current humidity with the lowest sample in the configured sample window. It
has not been converted to state-change-based sampling.

Testing

Tested on my Home Assistant installation with:

  • startup while the source humidity sensor is unknown
  • normal off state
  • humidity samples updating
  • entity availability recovery
  • state-dependent icons
  • readable target and timer attributes

The startup warnings from issue #30 no longer occur for normal temporary
unknown or unavailable states.

Modernize entity lifecycle and startup handling
@Corsw

Corsw commented Jul 23, 2026

Copy link
Copy Markdown
Author

Hi Bas,

You mentioned previously that someone would be welcome to take over and
improve the integration.

I use this integration myself and have prepared a draft pull request that modernizes the entity lifecycle and fixes the startup handling while preserving the existing behaviour.

I would be willing to maintain the integration going forward.

Would you be open to reviewing the pull request and discussing either
maintainer access or transferring the repository?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant