Skip to content

Reset of values after outage fix #91

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Reset of values after outage fix #91

wants to merge 6 commits into from

Conversation

sargonas
Copy link
Member

Sorry I thought I had opened this for a PR weeks ago! It's been working fine on my system, but I defer to your judgement @cayossarian if you are satisfied with my changes or not before merging them in. Would love to get this into a release, sooner than later, if possible.

sargonas added 3 commits June 25, 2025 12:28
added detection for anomalous data and drops the reading if they are larger than is sensible

Set to use the following Circuit-specific thresholds (but they are changeable)

self._max_energy_jump_wh = 20000  - defaults at 20 kWh max jump between readings since a 60amp circuit can't pull more than 15 kwh, and I can't think of a residential setup where there would be more than that even on an EV charger

self._max_energy_rate_w = 50000   # 50 kW max power rate feels very generous to avoid false positives I think?

In theory i focused this at the circuit level only, so I don't THINK it will have any knock-on effects to the solar and grid readings, which are quite higher.
This reverts commit b90ef99.
crafted a backstop to keep sensors from going `unavailable` every time the panel updates or restarts, causing HA to calculate energy deltas from 0 to current, instead of previous to current as desired.
@sargonas sargonas changed the title Rest values fix Reset of values after outage fix Jul 15, 2025
@sargonas
Copy link
Member Author

had to step out as soon as I opened this, but when I get home I'll take a look at any CI issues and try to address them ASAP tonight.

@sargonas
Copy link
Member Author

having no end of a headache with some of the CI stuff. Just when I get it passing locally, I get new issues on GH that I didn't have locally. Going to take another stab at this tomorrow to get it passing.

@cayossarian
Copy link
Member

Yes sorry I haven't forgotten you. I'm on the verge of a major refactoring to add this baseline for these math-aware sensors and your request will be in it. I will pull your changes this week so no worries.

Cheers

@sargonas
Copy link
Member Author

sargonas commented Jul 15, 2025 via email

@cayossarian
Copy link
Member

Just to add a little color my thinking is that we use the synthetic sensor definition, which I have already integrated to store the previous state of the sensor in an attribute of the sensor and then test the current state against that previous state with another variable (potentially a SensorSet global or two for power vs energy thresholds). We can expose these thresholds in the options and then when the sensor evaluates its state it can do something meaningful like log the spike, toss it, etc.

I'll look at what you've done algorithmically and incorporate those concepts and we can iterate on how best to proceed. Since your panel is working with your fork can no one else is complaining I feel like we have a bit of time to get this right. See the discussion here for some background on the bigger picture.

@cayossarian
Copy link
Member

I'm working on this now with the ha-synthetic-sensor now looking much better and integrated into my 1.2.0 branch. It was just a massive effort with > 1500 tests. I'll put the grace period in the options. I assume your fix has solve the problem for you and the approach is a go...

@cayossarian
Copy link
Member

I'm working on this now that the ha-synthetic-sensors is working well. It was just a massive effort (>1500 tests) so hopefully will get 1.2.0 out later this week or early next. It will be fun to see what we can do with it.

I'll put the grace period in the options. Assume the general approach is working for you. That was great digging!

@cayossarian
Copy link
Member

This doc describes the approach.

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.

2 participants