Commit a53c4c8
fix(deye): apply the SOC floor only at the API boundary
Copilot review on #4363 spotted that publish_schedule_settings_ha()
clamped the published reserve while apply_reserve_live() stored the raw
value, so the two could disagree.
Resolved the other way round from the suggestion. Clamping at entry as
well would make the internal state self-consistent but would not fix the
problem described: Predbat writes this entity and then reads it back to
confirm (write_and_poll_value), so if it writes 4 and we publish 14 the
read-back cannot match whichever end is clamped, and it retries until it
gives up — the exact "didn't complete got 0.0" failure this component
was just fixed for.
The entity is Predbat's control surface, so it now echoes what Predbat
wrote, everywhere: the entity read, the control event and the published
state all store and emit the raw value. The floor is applied in one
place, build_dynamic_payload, immediately before the payload leaves for
the API — which is what actually protects the battery, and cannot be
bypassed by any caller.
Narrow in practice: adjust_reserve already clamps to reserve_percent,
which comes from the battery_min_soc sensor this component publishes, so
the automatic path can never write below the floor. A manually configured
install that does not map battery_min_soc defaults it to 4.0 and could.
The clamp now logs once per serial when it actually lifts a value.
Routine before Predbat has written the reserve; a persistent complaint
means Predbat is planning below the inverter's floor, which is worth
seeing rather than silently correcting.
Adds a test that the reserve entity echoes a below-floor write verbatim
while the payload built from it is still lifted to the floor. Verified to
fail against the clamped-publish version: "expected the entity to echo 4,
got 14".
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent adc2ab3 commit a53c4c8
3 files changed
Lines changed: 58 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
132 | 133 | | |
133 | 134 | | |
134 | 135 | | |
| |||
639 | 640 | | |
640 | 641 | | |
641 | 642 | | |
| 643 | + | |
642 | 644 | | |
643 | 645 | | |
644 | 646 | | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
645 | 654 | | |
646 | 655 | | |
647 | 656 | | |
| |||
802 | 811 | | |
803 | 812 | | |
804 | 813 | | |
805 | | - | |
806 | | - | |
807 | | - | |
808 | | - | |
809 | | - | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
810 | 820 | | |
811 | 821 | | |
812 | 822 | | |
813 | | - | |
| 823 | + | |
814 | 824 | | |
815 | 825 | | |
816 | 826 | | |
| |||
842 | 852 | | |
843 | 853 | | |
844 | 854 | | |
845 | | - | |
846 | | - | |
847 | | - | |
848 | | - | |
| 855 | + | |
849 | 856 | | |
850 | 857 | | |
851 | 858 | | |
| |||
912 | 919 | | |
913 | 920 | | |
914 | 921 | | |
915 | | - | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
916 | 925 | | |
917 | 926 | | |
918 | 927 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
498 | 498 | | |
499 | 499 | | |
500 | 500 | | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
501 | 537 | | |
502 | 538 | | |
503 | 539 | | |
| |||
559 | 595 | | |
560 | 596 | | |
561 | 597 | | |
| 598 | + | |
562 | 599 | | |
563 | 600 | | |
564 | 601 | | |
| |||
0 commit comments