Skip to content

fixing the check for the phase CT vs. circuit CTs for current scaling - #1

Open
asolochek wants to merge 1 commit into
digiblur:devfrom
asolochek:dev
Open

fixing the check for the phase CT vs. circuit CTs for current scaling#1
asolochek wants to merge 1 commit into
digiblur:devfrom
asolochek:dev

Conversation

@asolochek

Copy link
Copy Markdown

CTInputPort::C is 0, so the correct current scale factor was never being applied to CT A or B.

@benlbaum

Copy link
Copy Markdown

You're correct here, the code could also explicitly check for A, B, or C phases to be more clear.

const bool is_mains =
(this->input_port_ == CTInputPort::A) ||
(this->input_port_ == CTInputPort::B) ||
(this->input_port_ == CTInputPort::C);

const double scalar = is_mains
? (775.0 / 42624.0) // mains inputs A/B/C
: (775.0 / 170496.0); // branch inputs 1–16

this->current_sensor_->publish_state(raw_current_d * scalar);

@digiblur are you able to merge this PR? Thanks!

@madcatzfight

Copy link
Copy Markdown

Good Catch!

@digiblur

digiblur commented Oct 5, 2025

Copy link
Copy Markdown
Owner

You're correct here, the code could also explicitly check for A, B, or C phases to be more clear.

const bool is_mains = (this->input_port_ == CTInputPort::A) || (this->input_port_ == CTInputPort::B) || (this->input_port_ == CTInputPort::C);

const double scalar = is_mains ? (775.0 / 42624.0) // mains inputs A/B/C : (775.0 / 170496.0); // branch inputs 1–16

this->current_sensor_->publish_state(raw_current_d * scalar);

@digiblur are you able to merge this PR? Thanks!

Let me try in the morning

@natevw

natevw commented Nov 18, 2025

Copy link
Copy Markdown

Looks like the upstream dev branch now has a similar fix as the one proposed in #1 (comment) as part of the new variant: vue3 support: emporia-vue-local#362 (see the new static inline bool is_mains_port(CTInputPort port) helper).

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.

5 participants