Skip to content

Commit

Permalink
sns: factor allowed values are 0...100
Browse files Browse the repository at this point in the history
  • Loading branch information
mcspr committed Dec 5, 2022
1 parent b8921b9 commit 5226668
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions code/espurna/sensors/CSE7766Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ class CSE7766Sensor : public BaseEmonSensor {
_factor = ((_voltage > 0) && (_current > 0))
? (100 * _active / _voltage / _current)
: 100;
if (_factor > 100) {
_factor = 100;
}

if (_apparent > _active) {
_reactive = fs_sqrt(_apparent * _apparent - _active * _active);
Expand Down
3 changes: 3 additions & 0 deletions code/espurna/sensors/V9261FSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ class V9261FSensor : public BaseEmonSensor {
_factor = ((_voltage > 0) && (_current > 0))
? (100 * _active / _voltage / _current)
: 100;
if (_factor > 100) {
_factor = 100;
}

if (_apparent > _active) {
_reactive = fs_sqrt(_apparent * _apparent - _active * _active);
Expand Down

0 comments on commit 5226668

Please sign in to comment.