Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double reports if the two sensors are updated at different times #51

Closed
borpin opened this issue Jan 8, 2022 · 4 comments · Fixed by #75
Closed

Double reports if the two sensors are updated at different times #51

borpin opened this issue Jan 8, 2022 · 4 comments · Fixed by #75

Comments

@borpin
Copy link
Contributor

borpin commented Jan 8, 2022

I am occasionally seeing double reports from the component within a few milliseconds of each other.

I wonder if this is caused by the 2 sensors being updated at slightly different times?

Does the component wait for both sensors to be updated before doing the calculations?

@borpin
Copy link
Contributor Author

borpin commented Mar 7, 2022

I think the component needs to check the last_updated times for both sensors to check the values are within a specific time window (as second or so I expect).

@borpin
Copy link
Contributor Author

borpin commented Mar 18, 2022

@dckiller51 I have worked with the author of the Passive BLE Monitor integration such that the weight and impedance sensors update almost simultaneously. custom-components/ble_monitor#617

However, I am still getting 2 updates of this component. All I can think of is that the few milliseconds between the 2 sensors update is sufficient to trigger the 2 updates.

Can a delay be added in while the component waits for both sensors to update?

@edenhaus
Copy link
Collaborator

Currently the component subscribe for states updates for each sensor.

On each sensor update all values are calculated.

async def async_added_to_hass(self) -> None:
"""After being added to hass."""
async_track_state_change_event(
self.hass,
list(self._config[CONF_SENSORS].values()),
self._state_changed_event,
)

To avoid the second report, we need to change how we subscribe. Probably introduce a delay

@borpin
Copy link
Contributor Author

borpin commented Mar 21, 2022

Precisely and you cannot calculate the correct details until both the weight and the impedance are available.

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 a pull request may close this issue.

2 participants