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

ct_clamp: Check sample() return value is not NaN #921

Merged
merged 1 commit into from Dec 17, 2019

Conversation

balrog-kun
Copy link
Contributor

@balrog-kun balrog-kun commented Dec 16, 2019

Don't try to update CT clamp's state with NaN values returned from the
underlaying sensor. A single IO error in the sensor code will cause a
NaN to be returned and if we use that in CTClampSensor's floating point
maths both sample_sum_ and offset_ will become NaN and from there every
future calculation will use the NaN offset_ and return NaN too.

Description:

Related issue (if applicable): fixes

Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

Don't try to update CT clamp's state with NaN values returned from the
underlaying sensor.  A single IO error in the sensor code will cause a
NaN to be returned and if we use that in CTClampSensor's floating point
maths both sample_sum_ and offset_ will become NaN and from there every
future calculation will use the NaN offset_ and return NaN too.
@OttoWinter OttoWinter merged commit c8ccb06 into esphome:dev Dec 17, 2019
@balrog-kun balrog-kun deleted the ct-clamp-ignore-nan branch December 17, 2019 13:29
@lock lock bot locked and limited conversation to collaborators Dec 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants