Repository navigation
Commit 69d36c3
committed
fix: read-compare-write in automation to stop redundant inverter writes
Automations were writing the target value on every snapshot cycle even when
the inverter was already at that value, spamming the dongle and the
automation log (e.g. writing 0 A every 10 s when it had been 0 A for hours).
- _do_write now reads the register's current raw value first and skips the
write (silently) when it already matches the target.
- Removed the in-memory _last_written_value dedup guard, which only tracked
what this process wrote (reset on restart) and could not detect external
changes. Read-compare-write is now the single source of truth.
- Fail-safe: if the read fails, the write still proceeds (a failed read
should not block the automation from doing its job).
- Added 3 tests covering match-skip, differ-write, and read-fail-write.1 parent cacc06f commit 69d36c3
2 files changed
Lines changed: 80 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
631 | 631 | | |
632 | 632 | | |
633 | 633 | | |
634 | | - | |
635 | 634 | | |
636 | 635 | | |
637 | 636 | | |
| |||
797 | 796 | | |
798 | 797 | | |
799 | 798 | | |
800 | | - | |
801 | | - | |
802 | | - | |
803 | | - | |
804 | | - | |
805 | | - | |
806 | | - | |
807 | | - | |
808 | | - | |
809 | | - | |
810 | | - | |
811 | | - | |
812 | | - | |
813 | | - | |
814 | 799 | | |
815 | 800 | | |
816 | 801 | | |
817 | 802 | | |
818 | 803 | | |
819 | | - | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
820 | 813 | | |
821 | 814 | | |
822 | 815 | | |
| |||
840 | 833 | | |
841 | 834 | | |
842 | 835 | | |
843 | | - | |
844 | | - | |
845 | | - | |
846 | | - | |
847 | | - | |
848 | | - | |
849 | | - | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
850 | 840 | | |
851 | 841 | | |
852 | 842 | | |
853 | 843 | | |
854 | | - | |
855 | | - | |
856 | | - | |
857 | | - | |
858 | | - | |
859 | | - | |
860 | | - | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
861 | 848 | | |
862 | 849 | | |
863 | 850 | | |
| |||
944 | 931 | | |
945 | 932 | | |
946 | 933 | | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
947 | 946 | | |
948 | 947 | | |
949 | 948 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
303 | 354 | | |
304 | 355 | | |
0 commit comments