Skip to content

Send a power setpoint, and stop pre-judging overlap - #274

Draft
Poshy163 wants to merge 2 commits into
CharlesGillanders:mainfrom
Poshy163:fix/periodic-charge-discharge
Draft

Send a power setpoint, and stop pre-judging overlap#274
Poshy163 wants to merge 2 commits into
CharlesGillanders:mainfrom
Poshy163:fix/periodic-charge-discharge

Conversation

@Poshy163

Copy link
Copy Markdown
Collaborator

Two things from testing on #269.

@dragon2611 saw the discharge entry turn up in the AlphaESS portal and then just sit there doing
nothing. It had no rate to run at: setTimeChargeBySn happily accepts a period with no
chargePower and then ignores it. We were only setting one if an earlier read had handed us a
value to reuse, and if you've never had a periodic schedule there's nothing to reuse. It now falls
back to the inverter's own rated power.

@benbrown249-wq got "charge period 13:30-02:45 overlaps discharge" on a system whose schedule in
the app was completely empty. That window isn't a stale cache. It comes from the legacy store,
which on a migrated system is a different store the app doesn't show you, and because it wraps past
midnight it covers thirteen hours. So it clashed with everything and we skipped every single write.

I'd written that overlap check from the docs, back when the library couldn't tell us what the API
actually said. It can now, so I've dropped the guessing: send the schedule, and if the API comes
back with 6008, log it and name the periods we sent. The old check was shaky anyway, since it
assumed the overlap rule still applies when a cycle is disabled and nobody has confirmed that.

Two things from testing on CharlesGillanders#269.

dragon2611 saw the discharge entry appear in the AlphaESS portal and do
nothing, because it had no rate to run at. setTimeChargeBySn accepts a period
with no chargePower and then ignores it. We only sent one when a previous
periodic read had given us a value to carry over, which for a system with no
existing periodic schedule is never. Fall back to the inverter's own rated
power from getEssList.

benbrown249 hit "charge period 13:30-02:45 overlaps discharge" on a system
whose app schedule was empty. That window comes from the legacy store, which
on a migrated system is a separate store the app doesn't show, and because it
wraps midnight it spans thirteen hours and collides with anything. So every
write was skipped.

The overlap guard was written from the documentation, before the library could
report return codes. It can now, so drop the guess and send the schedule: if
the API objects with 6008 we say so, and name the periods we sent. That also
removes a guard that could never have been right, since we don't know whether
the API applies the overlap rule when a cycle is disabled.
Swept the rest of the endpoints for the two shapes behind the CharlesGillanders#269 reports: an
optional field whose absence silently does nothing, and us deciding a call will
fail instead of making it.

chargePower was the only optional field with that behaviour, and it is now
sent, so that one is closed.

The EV control pre-check is the same mistake as the overlap guard, and worse.
It refused to send start/stop unless the cached charger status matched our own
idea of which states allow which command. That status is only as fresh as the
last poll, which is configurable up to an hour, and if the status endpoint had
failed there was no status at all, so every command was blocked indefinitely.
Absorbing API errors on reads made that more likely. The command now always
goes out and we report what the charger says. can_control_ev stays for the
Can Start/Stop Charging sensors, where a hint is all it ever was.

The two services also passed times through untouched. The API wants zero
padded HH:mm on the quarter hour, so "9:00" comes back 6001 and an off-grid
minute is accepted and then unusable. They are normalised now, the same way
the time entities already did it.
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.

1 participant