Modules
API Reference¶
Client¶
Client
¶
Asynchronous client for talking to a GivEnergy inverter over Modbus TCP.
Holds a long-lived connection drained by a single producer/consumer task pair. All public methods are coroutines and assume they're awaited from the same asyncio event loop.
Concurrency contract¶
The client is designed to be used from multiple concurrent callers — e.g. a
polling loop calling refresh_plant() and entity-write handlers calling
one_shot_command() independently. The following invariants hold:
Safe to interleave
- Reads (
refresh_plant,load_config,refresh) and writes (one_shot_command) may run concurrently. Their request/response pairs occupy disjoint shape-hash spaces, so they never collide in the in-flight tracking dict. tx_queueis a FIFO drained by a single producer task with rate limiting between frames; bytes from one frame never interleave with another. A queued frame whose response future is already done (i.e. resolved by a late arrival from a previous attempt) is skipped at dequeue time rather than written to the wire, so retry storms don't duplicate work the inverter has already done.- Incoming frames are reassembled and dispatched serially by the consumer task, so register-cache mutations are applied one PDU at a time.
Must be serialised
detect()mutatesplant.capabilities(including in-place appends to its address lists) and must not run concurrently with anything that reads those fields — most importantlyrefresh()andload_config(). In typical usedetect()runs once at connect time before the polling loop starts, which satisfies this naturally. Downstream consumers caching capabilities across restarts can bypassdetect()on reconnect entirely.
Practical guidance for downstream consumers
- Take a per-client lock around
refresh_plant()so successive polls don't overlap. Writes don't need the same lock — they're free to land between polls. - Connection loss is surfaced three ways:
self.connectedflips toFalse, the noticing task logs a WARNING, and every in-flight or subsequently attempted request raisesConnectionLost(aCommunicationErrorthat is also aTimeoutError, so legacyexcept TimeoutErrorhandling keeps working — catchConnectionLostfirst to distinguish reconnect-me from a genuine stall).connect()is idempotent and tears down the previous connection on its own, so it can be called directly as a reconnect primitive.
Source code in givenergy_modbus/client/client.py
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 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 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 | |
capture_frames(sink, duration=60.0)
async
¶
Tee redacted TX/RX wire frames to sink for duration seconds.
sink is called with the direction ('rx' or 'tx') and the redacted bytes. The library always redacts before invoking the sink so callers can't accidentally see raw hardware identifiers; persistence, formatting and forwarding are the caller's choice.
Redaction is frame-aware: each complete GivEnergy frame is decoded, its serial-bearing fields (envelope serials, C.serial-tagged register values, LAN-config IPs) are zeroed by type, and the frame is re-encoded with a freshly-computed CRC. Frames that cannot be decoded (unknown function codes, malformed/truncated frames) are emitted intact with a log message — they are never dropped or mangled. The sink sees complete frames (one call per complete frame) rather than raw socket chunks.
Runs alongside the normal refresh loop — does not suspend reads or writes, just tees a copy of each frame to sink. Only one capture may run on a Client at a time; calling while one is in flight raises RuntimeError.
Source code in givenergy_modbus/client/client.py
1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 | |
close()
async
¶
Disconnect from the remote host and clean up tasks and queues.
Source code in givenergy_modbus/client/client.py
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 | |
connect()
async
¶
Connect to the remote host and start background tasks.
Idempotent: if the client is already connected, the existing connection
and background tasks are torn down before establishing a new one. This
makes connect() safe to use as a reconnect primitive without a
separate close() step, and guarantees the new background tasks see
_shutting_down as False even after a prior close().
Source code in givenergy_modbus/client/client.py
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 | |
detect(timeout=2.0, retries=3, probe_timeout=0.5, probe_retries=1, prior=None)
async
¶
Discover device type and peripheral topology.
Reads HR(0) and HR(21) from the inverter to resolve the model, then probes for BCUs (HV systems), meters, and LV battery devices.
Both returns the PlantCapabilities instance and assigns it to
self.plant.capabilities — the returned object and the one stored on
the plant are the same. Subsequent calls to Client.refresh() and
Client.load_config() will use it automatically.
When prior is supplied, the probe sweep restricts itself to the
addresses listed in it — empty addresses from a cold sweep are skipped.
If reality doesn't match prior (device_type changed, or any hinted
address fails to confirm), raises PlantTopologyMismatch and leaves
self.plant.capabilities as None. The exception carries prior and
actual so callers can decide whether to retry, fall back to a cold
detect(), or surface the change to the user.
Uses a two-tier timeout: timeout/retries for the known inverter device
(where a response is expected), and probe_timeout/probe_retries for
speculative probes where absence is the common case.
On a connection-level failure (TimeoutError / CommunicationError) the
connection is torn down via close(), so connect()+detect() is atomic:
connected flips to False and the standard "reconnect if not connected"
idiom recovers (#274). A PlantTopologyMismatch is raised on a healthy
connection (only the hint was wrong) and leaves it up so the caller can
retry a cold detect().
Source code in givenergy_modbus/client/client.py
812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 | |
execute(requests, timeout, retries, retry_delay=0.5, return_exceptions=False)
¶
Helper to perform multiple requests in bulk.
Source code in givenergy_modbus/client/client.py
1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 | |
installer_command(requests, timeout=1.5, retries=0, retry_delay=0.5, dry_run=False)
async
¶
Execute installer-tier write requests.
Like one_shot_command() but admits registers from INSTALLER_WRITE_REGISTERS. Requests must be constructed with installer=True via the dedicated helpers in client.commands (e.g. set_battery_nominal_power, restore_factory_defaults).
one_shot_command() always rejects installer-flagged requests — the two methods are non-overlapping by design (dual-gate separation).
If dry_run is True, validates but does not transmit.
Source code in givenergy_modbus/client/client.py
1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 | |
load_config(timeout=2.0, retries=3, retry_delay=0.5)
async
¶
Read HR configuration blocks for the inverter.
Returns the populated plant on full success. On partial/total read
failure raises RefreshPartiallySucceeded / RefreshFailed.
Success does not imply fresh: the keep-last-good guards (CRC #255, sub-bus
splice #256, bank holds) report a successful poll while serving last-known-good
content for a device whose live read was rejected. Display consumers should gate
on Plant.register_age() / Plant.block_age(), not on a poll returning.
Source code in givenergy_modbus/client/client.py
1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 | |
one_shot_command(requests, timeout=1.5, retries=0, retry_delay=0.5, dry_run=False)
async
¶
Execute write requests, validating each against the detected inverter model.
Raises InvalidPduState for any write to a register not permitted for the detected model. When capabilities are not yet known, falls back to the universally-applicable single-phase register set (conservative).
If dry_run is True, validates but does not transmit — running the same PDU
validation (ensure_valid_state) the live encode path runs, so a dry run
never passes for a request real execution would reject.
Source code in givenergy_modbus/client/client.py
1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 | |
probe_alive(timeout=2.0, retries=0)
async
¶
Cheap reconnect liveness gate: read HR(0) once and report whether the inverter answered.
Distinct from :meth:detect by design. Its ONLY job is "is the inverter responding at
all?", so on a hung dongle it fails fast (default retries=0, no peripheral sweep) and
its failure is free — the caller just probes again next tick. On the first success the
caller runs a full, robust detect(retries=3) to re-establish topology; that detect
stays robust because it no longer carries the probe's fail-fast constraint (which is the
whole reason this is a separate method rather than detect(retries=0) — one call cannot
be both the cheap gate and the robust recovery, since the identity read shares a single
retries).
Mirrors :meth:detect's connection discipline, returning a bool instead of raising:
- Alive (HR(0) came back): the socket is left open, so the caller's follow-up
detectreuses the same live connection. - Not alive (timeout / :class:
CommunicationError, or a response that left no usable HR(0)): the socket is closed (mirroring detect's #274 teardown), releasing it for the dongle's quiet window so the coordinator uniformly reconnects next tick. Never raises.
Reuses the exact HR(0,60)@0x11 read :meth:detect uses (the read proven against real
hardware). Reconnect cadence/backoff stays the caller's concern (#356): this owns only the
single check.
Source code in givenergy_modbus/client/client.py
871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 | |
refresh(timeout=2.0, retries=1, retry_delay=0.5, ir0_max_age=None, *, max_age=None)
async
¶
Read IR measurement blocks for all known devices.
Returns the populated plant on full success. On partial/total read
failure raises RefreshPartiallySucceeded / RefreshFailed.
Success does not imply fresh: the keep-last-good guards (CRC #255, sub-bus
splice #256, bank holds) report a successful poll while serving last-known-good
content for a device whose live read was rejected. Display consumers should gate
on Plant.register_age() / Plant.block_age(), not on a poll returning.
The timeout=2.0, retries=1 defaults are tuned for a contended bus: the
inverter serialises requests, so when other clients (GivTCP, the vendor app,
Predbat) poll the same unit a tighter budget produces spurious timeouts even
though the device is responsive (#132). Pass a tighter budget if you own the
bus exclusively and want genuine failures surfaced faster.
max_age (seconds) opts in to skip-if-fresh for any IR bank (#196, #207):
GivEnergy dongles fan out the responses to whoever is polling them (the cloud,
the app, another client), so the consumer often already has recent data in cache
without us asking. When set, any IR bank committed within max_age seconds
is not re-solicited this cycle. Defaults to None — always solicit, the
historic behaviour. Note the fan-out only exists while something else is polling
the unit; on a cloud-disconnected dongle the blocks age out and we solicit them.
The fan-out is opportunistic, not a promise that concurrent access is free —
some dongles idle-reap the connection under multiple clients (hass#95) and
reconnect transparently; the skip degrades safely (blocks age out, we solicit).
ir0_max_age is deprecated — use max_age instead. It applied the same
logic to IR(0,60) only; max_age extends it to every bank. Will be removed
in 3.0.
Source code in givenergy_modbus/client/client.py
1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 | |
refresh_plant(full_refresh=True, max_batteries=5, timeout=2.0, retries=1, retry_delay=0.5)
async
¶
Deprecated orchestrator — run detect() once, then drive your own loop.
.. deprecated::
Will be removed in 3.0 (soon). This composes detect() (when needed) +
load_config() + refresh(), which is trivial to do in the consumer
where the partial-failure policy belongs. It propagates
RefreshPartiallySucceeded / RefreshFailed like the primitives —
note that on a full refresh a partial failure in load_config()
short-circuits before refresh() runs; call the primitives directly for
full control.
Unlike the primitives, this wrapper runs ``detect()`` for you if
capabilities are absent (preserving the legacy connect-then-refresh shape).
New code should call ``detect()`` then ``load_config()`` / ``refresh()``
directly — the primitives raise ``PlantNotDetected`` rather than guessing
an address.
Source code in givenergy_modbus/client/client.py
1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 | |
send_request_and_await_response(request, timeout, retries, retry_delay=0.5, warn_timeout=True)
async
¶
Send a request to the remote, await and return the response.
On timeout, retry_delay seconds pass before the next attempt is
enqueued. The default of 0.5s was chosen to overcome the multi-second
silent-window failure mode observed in the field — firing the retry
immediately tends to land it inside the same silent window as the
original request, accomplishing nothing. Callers that want the
original "retry immediately" behaviour (e.g. fast probes, latency-
sensitive interactive commands) should pass retry_delay=0.
Source code in givenergy_modbus/client/client.py
1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 | |
watch_plant(handler=None, refresh_period=15.0, max_batteries=5, timeout=2.0, retries=1, retry_delay=0.5, passive=False)
async
¶
Deprecated poll loop — own the loop in the consumer instead.
.. deprecated::
Will be removed in 3.0. Connect, detect(), then loop over
load_config() / refresh() yourself, handling
RefreshPartiallySucceeded / RefreshFailed as suits the consumer.
Source code in givenergy_modbus/client/client.py
1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 | |
FrameRedactor
¶
Frame-aware stateful redactor for a captured GivEnergy byte stream.
Replaces StreamRedactor: instead of running byte-level regex over raw socket
chunks, it reassembles complete GivEnergy frames (using the same 0x5959 marker
scan the Framer uses), decodes each one, redacts only the known-sensitive
fields by type (envelope serials, C.serial-tagged register values, LAN-config IPs),
and re-encodes with a freshly-computed CRC.
Any bytes that cannot be decoded — InvalidFrame results, inter-frame garbage,
or a partial frame held at stream end — are emitted intact (not mangled) with
a log message. Nothing on the wire is ever dropped: the capture is always complete.
Not thread-safe; use one instance per capture direction.
See #158 B-3 for the design rationale and the LanConfigBroadcast PDU that
handles the #100 WO-dongle LAN-config broadcasts.
Source code in givenergy_modbus/client/client.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
feed(chunk)
¶
Absorb raw bytes; return redacted output for any complete frames found.
Source code in givenergy_modbus/client/client.py
114 115 116 117 | |
flush()
¶
Emit any remaining buffered bytes intact and reset. Call at stream end.
Source code in givenergy_modbus/client/client.py
119 120 121 122 123 124 125 | |
ProbeRange
dataclass
¶
A single Modbus read to issue during detect, with its timeout tier.
tier="known" → full timeout/retries; tier="probe" → fast
probe_timeout/probe_retries and retry_delay=0.
Source code in givenergy_modbus/client/client.py
234 235 236 237 238 239 240 241 242 243 244 245 246 | |
Commands¶
High-level methods for interacting with a remote system.
RegisterMap
¶
Mapping of holding register function to location.
Source code in givenergy_modbus/client/commands.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
disable_charge()
¶
Prevent the battery from charging at all.
Source code in givenergy_modbus/client/commands.py
291 292 293 294 | |
disable_charge_target()
¶
Removes SOC limit and target 100% charging.
Source code in givenergy_modbus/client/commands.py
224 225 226 227 228 229 | |
disable_charge_target_3ph()
¶
Remove SOC limit and target 100% charging on three-phase inverters (HR 1111, shadows HR 116).
Source code in givenergy_modbus/client/commands.py
351 352 353 354 355 356 | |
disable_discharge()
¶
Prevent the battery from discharging at all.
Source code in givenergy_modbus/client/commands.py
303 304 305 306 | |
enable_black_start(*, confirm=False)
¶
Enable EPS black-start mode (HR5003). Use with care.
Activates black-start capability on EPS-capable inverters. Incorrect use can cause the inverter to energise an island without grid synchronisation. Pass confirm=True to proceed.
Source code in givenergy_modbus/client/commands.py
1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 | |
enable_charge()
¶
Enable the battery to charge, depending on the mode and slots set.
Source code in givenergy_modbus/client/commands.py
285 286 287 288 | |
enable_discharge()
¶
Enable the battery to discharge, depending on the mode and slots set.
Source code in givenergy_modbus/client/commands.py
297 298 299 300 | |
refresh_plant_data(complete, number_batteries=1, max_batteries=5)
¶
This helper hardcoded device_address=0x32 for every read, which silently
failed on models answering elsewhere (e.g. an All-in-One at 0x11 — issue #105).
Capability-aware polling — Client.detect() then Client.load_config() /
Client.refresh() — replaces it and addresses each device correctly.
Kept as an import-compatible stub so existing imports don't break with an
ImportError; it raises PlantNotDetected to signpost the migration rather
than rebuild the unsafe blind poll.
Source code in givenergy_modbus/client/commands.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
reset_charge_slot(idx, slot_map)
¶
Reset charge slot to zero/disabled by index (1-based).
Source code in givenergy_modbus/client/commands.py
779 780 781 | |
reset_charge_slot_1(slot_map=SINGLE_PHASE_SLOTS)
¶
Source code in givenergy_modbus/client/commands.py
802 803 804 805 | |
reset_charge_slot_2(slot_map=SINGLE_PHASE_SLOTS)
¶
Source code in givenergy_modbus/client/commands.py
814 815 816 817 | |
reset_discharge_slot(idx, slot_map)
¶
Reset discharge slot to zero/disabled by index (1-based).
Source code in givenergy_modbus/client/commands.py
791 792 793 | |
reset_discharge_slot_1(slot_map=SINGLE_PHASE_SLOTS)
¶
Source code in givenergy_modbus/client/commands.py
826 827 828 829 | |
reset_discharge_slot_2(slot_map=SINGLE_PHASE_SLOTS)
¶
Source code in givenergy_modbus/client/commands.py
838 839 840 841 | |
reset_energy_totals(*, confirm=False)
¶
Reset all lifetime energy counters (HR162). Irreversible.
This clears the lifetime import/export/charge/discharge totals stored in the inverter. Cannot be undone. Pass confirm=True to proceed.
Source code in givenergy_modbus/client/commands.py
1348 1349 1350 1351 1352 1353 1354 1355 1356 | |
restore_factory_defaults(*, confirm=False)
¶
Restore factory defaults (HR5004). Irreversible — wipes all installer config.
Resets the inverter to factory defaults, including all installer-configured grid-safety limits, battery settings, and operating modes. Pass confirm=True to proceed.
Source code in givenergy_modbus/client/commands.py
1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 | |
set_ac_charge(enabled)
¶
Enable AC charging on three-phase inverters.
Source code in givenergy_modbus/client/commands.py
580 581 582 | |
set_active_power_rate(target)
¶
Set the inverter's active power output as a percentage of its rated capacity.
On an EMS-managed inverter this per-inverter write (HR50) is a silent no-op: it is accepted at the modbus layer (no error, unlike the AC-limit registers) but the EMS controller re-asserts its own value, so the change does not stick. There is no EMS-controller active-power-rate command to target instead (the EMS register block has none). See #304.
Source code in givenergy_modbus/client/commands.py
459 460 461 462 463 464 465 466 467 468 469 470 | |
set_anti_islanding_detection(enabled)
¶
Enable or disable anti-islanding detection (HR115). Installer-tier.
Source code in givenergy_modbus/client/commands.py
940 941 942 | |
set_battery_charge_limit(val)
¶
Set the battery charge rate as a C-rate cap (unit C/100; documented range 0-50 = 0-0.5C).
HR(111) is a battery-side current limit against the pack's capacity C — NOT a percentage of
inverter rated power (an earlier docstring said the latter; that was wrong on the unit). The
current GE app states it outright: "the maximum charge rate as a percentage of the C rating
(unit C/100, range 0-50)", and the installer app names the register BATTERY_MAX_C_RATING. (The
older app build we decompiled carried stale metadata — range 1-250, "power percentage" — since
corrected by GE; that was the source of our long-standing ambiguity.) So value 50 = 0.5C, and the
effective output is min(this battery C-rate, the HR(313/314) inverter-power %, the BMS
rating) — the limits sit in series (cells -> inverter -> grid).
Which pair is the live control depends on the battery-to-inverter ratio: on a DC hybrid the small pack (0.5C ~= 2.6 kW on a Gen1) is the tighter constraint, so HR(111/112) is the operative knob (and HR(313/314) is absent on DC hybrids anyway); on an All-in-One the ~6 kW inverter is tighter, so HR(313/314) is the live knob and HR(111/112) only bites when throttled well below inverter capacity. Field-confirmed in #302: sweeping HR(112) 50->100% during a discharge held output flat at ~2.66 kW (= 0.5C for that Gen1 pack, i.e. its 2600 W rating).
We accept 0-100 rather than hard-cap at 50 (bound set in #301/#302): though the app slider caps at 50, the register field tolerates >50 (a live AIO was observed holding HR(112) = 100, set by GivTCP / a max-rate write, not the GE app), so a hard [0-50] would reject a value real devices hold. Values above the pack's real C-rate are accepted but clamped by the battery/inverter — the inverse principle to the AC pair HR(313/314), which keeps a floor of 1 because writing 0 errors on the hardware (#306): cap only what the firmware rejects, document what it merely clamps.
Source code in givenergy_modbus/client/commands.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | |
set_battery_charge_limit_ac(val)
¶
Set the battery AC charge power limit as a percentage (1-100).
The GE app exposes 0-100 for this control, but writing 0 to HR313/314 does NOT work in practice on
(at least) the AC models tested — it ERRORs (hardware-confirmed via a single-phase AC tester:
WriteHoldingRegisterResponse(ERROR) then a write timeout). So the floor is 1 and a 0 raises a clean
ValueError rather than a doomed write; the 2.5.8 "0 disables" widening trusted the app range and was
wrong. The 0-floor is AC-specific — the DC pair :func:set_battery_charge_limit legitimately
accepts 0; writing 1 here drives the battery to near-zero.
Source code in givenergy_modbus/client/commands.py
503 504 505 506 507 508 509 510 511 512 513 514 515 516 | |
set_battery_discharge_limit(val)
¶
Set the battery discharge rate as a C-rate cap (unit C/100; meaningful range 0-50 = 0-0.5C).
HR(112) is a battery-side C-rate cap, not an inverter-power percentage — see
:func:set_battery_charge_limit for the full unit provenance (current GE app "C/100, range
0-50", installer BATTERY_MAX_C_RATING), the series min(C-rate, inverter %) model, and why this
accepts 0-100 rather than the historical [0-50].
Source code in givenergy_modbus/client/commands.py
432 433 434 435 436 437 438 439 440 441 442 443 | |
set_battery_discharge_limit_ac(val)
¶
Set the battery AC discharge power limit as a percentage (1-100).
The GE app exposes 0-100 for this control, but writing 0 to HR313/314 does NOT work in practice on
(at least) the AC models tested — it ERRORs (hardware-confirmed via a single-phase AC tester:
WriteHoldingRegisterResponse(ERROR) then a write timeout). So the floor is 1 and a 0 raises a clean
ValueError rather than a doomed write; the 2.5.8 "0 disables" widening trusted the app range and was
wrong. The 0-floor is AC-specific — the DC pair :func:set_battery_discharge_limit legitimately
accepts 0; writing 1 here drives the battery to near-zero.
Source code in givenergy_modbus/client/commands.py
519 520 521 522 523 524 525 526 527 528 529 530 531 532 | |
set_battery_max_charge_pct(pct)
¶
Set battery maximum charge percentage (HR310). Installer-tier. App range: 20–100.
Source code in givenergy_modbus/client/commands.py
932 933 934 935 936 937 | |
set_battery_nominal_current(current)
¶
Set battery nominal current (HR309). Installer-tier.
No explicit app range — accepts any uint16. Consult battery hardware spec.
Source code in givenergy_modbus/client/commands.py
923 924 925 926 927 928 929 | |
set_battery_nominal_power(power)
¶
Set battery nominal power (HR308). Installer-tier.
No explicit app range — accepts any uint16. Consult battery hardware spec.
Source code in givenergy_modbus/client/commands.py
915 916 917 918 919 920 | |
set_battery_pause_mode(val)
¶
Set the battery pause mode.
Source code in givenergy_modbus/client/commands.py
535 536 537 | |
set_battery_power_reserve(val)
¶
Set the battery power reserve to maintain.
Bounds [4-100]% are unconfirmed against GE firmware docs (gone) but match GivTCP's independent choice for the same register — treat as the working assumption until a portal capture contradicts it.
Source code in givenergy_modbus/client/commands.py
446 447 448 449 450 451 452 453 454 455 456 | |
set_battery_reserve_soc(val)
¶
Set the battery reserve SOC on three-phase inverters (HR 1078, "Battery Reserve %").
Three-phase only — single-phase units use set_battery_soc_reserve() (HR 110) instead. Bounds [4-100]% are unconfirmed (no GivTCP cross-reference exists for this register); treat as the working assumption until a live three-phase capture confirms them.
Source code in givenergy_modbus/client/commands.py
338 339 340 341 342 343 344 345 346 347 348 | |
set_battery_soc_reserve(val)
¶
Set the minimum level of charge to maintain.
Bounds [4-100]% are unconfirmed against GE firmware docs (gone) but match GivTCP's independent choice for the same register — treat as the working assumption until a portal capture contradicts it.
Source code in givenergy_modbus/client/commands.py
325 326 327 328 329 330 331 332 333 334 335 | |
set_battery_soc_reserve_3ph(val)
¶
Set the minimum SOC reserve on three-phase inverters (HR 1109, shadows single-phase HR 110).
Source code in givenergy_modbus/client/commands.py
359 360 361 362 363 364 | |
set_calibrate_battery_soc(val=1)
¶
Set the inverter to recalibrate the battery state of charge estimation.
val: 0 = Stop, 1 = Start, 3 = Charge Only
Source code in givenergy_modbus/client/commands.py
275 276 277 278 279 280 281 282 | |
set_charge_slot(idx, timeslot, slot_map)
¶
Set charge slot start & end times by index (1-based).
Source code in givenergy_modbus/client/commands.py
772 773 774 775 776 | |
set_charge_slot_1(timeslot, slot_map=SINGLE_PHASE_SLOTS)
¶
Source code in givenergy_modbus/client/commands.py
796 797 798 799 | |
set_charge_slot_2(timeslot, slot_map=SINGLE_PHASE_SLOTS)
¶
Source code in givenergy_modbus/client/commands.py
808 809 810 811 | |
set_charge_slot_end(idx, t, slot_map)
¶
Set just the end of a charge slot by index (1-based), or clear it if t is None.
Source code in givenergy_modbus/client/commands.py
754 755 756 757 | |
set_charge_slot_start(idx, t, slot_map)
¶
Set just the start of a charge slot by index (1-based), or clear it if t is None.
Source code in givenergy_modbus/client/commands.py
748 749 750 751 | |
set_charge_target(target_soc)
¶
Source code in givenergy_modbus/client/commands.py
246 247 248 249 | |
set_charge_target_3ph(target_soc)
¶
Source code in givenergy_modbus/client/commands.py
386 387 388 389 | |
set_charge_target_enabled(target_soc)
¶
Enable charging and stop once SOC reaches target_soc. Also referred to as "winter mode".
Source code in givenergy_modbus/client/commands.py
232 233 234 235 236 237 238 239 240 241 242 243 | |
set_charge_target_enabled_3ph(target_soc)
¶
Enable AC charging and set the charge target on three-phase inverters (HR 1111, shadows single-phase HR 116).
Source code in givenergy_modbus/client/commands.py
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | |
set_charge_target_soc(target_soc)
¶
Set only the charge target SOC (HR 116), leaving the charge / charge-target enable bits untouched.
Source code in givenergy_modbus/client/commands.py
252 253 254 255 256 257 | |
set_charge_target_soc_3ph(target_soc)
¶
Set only the charge target SOC on three-phase inverters (HR 1111), leaving enable bits untouched.
Source code in givenergy_modbus/client/commands.py
392 393 394 395 396 397 | |
set_discharge_mode_max_power()
¶
Set the battery discharge mode to maximum power, exporting to the grid if it exceeds load demand.
Source code in givenergy_modbus/client/commands.py
309 310 311 | |
set_discharge_mode_to_match_demand()
¶
Set the battery discharge mode to match demand, avoiding exporting power to the grid.
Source code in givenergy_modbus/client/commands.py
314 315 316 | |
set_discharge_slot(idx, timeslot, slot_map)
¶
Set discharge slot start & end times by index (1-based).
Source code in givenergy_modbus/client/commands.py
784 785 786 787 788 | |
set_discharge_slot_1(timeslot, slot_map=SINGLE_PHASE_SLOTS)
¶
Source code in givenergy_modbus/client/commands.py
820 821 822 823 | |
set_discharge_slot_2(timeslot, slot_map=SINGLE_PHASE_SLOTS)
¶
Source code in givenergy_modbus/client/commands.py
832 833 834 835 | |
set_discharge_slot_end(idx, t, slot_map)
¶
Set just the end of a discharge slot by index (1-based), or clear it if t is None.
Source code in givenergy_modbus/client/commands.py
766 767 768 769 | |
set_discharge_slot_start(idx, t, slot_map)
¶
Set just the start of a discharge slot by index (1-based), or clear it if t is None.
Source code in givenergy_modbus/client/commands.py
760 761 762 763 | |
set_ems_charge_slot(idx, timeslot)
¶
Set an EMS plant charge time slot by index (1-3), or clear it if None.
Source code in givenergy_modbus/client/commands.py
635 636 637 638 639 | |
set_ems_charge_slot_end(idx, t)
¶
Set just the end of EMS plant charge slot idx (1-3), or clear it if None.
Source code in givenergy_modbus/client/commands.py
647 648 649 | |
set_ems_charge_slot_start(idx, t)
¶
Set just the start of EMS plant charge slot idx (1-3), or clear it if None.
Source code in givenergy_modbus/client/commands.py
642 643 644 | |
set_ems_charge_target_soc(idx, target_soc)
¶
Set the SoC target (0-100%) for EMS plant charge slot idx (1-3).
Source code in givenergy_modbus/client/commands.py
669 670 671 672 673 674 675 676 | |
set_ems_discharge_slot(idx, timeslot)
¶
Set an EMS plant discharge time slot by index (1-3), or clear it if None.
Source code in givenergy_modbus/client/commands.py
652 653 654 655 656 | |
set_ems_discharge_slot_end(idx, t)
¶
Set just the end of EMS plant discharge slot idx (1-3), or clear it if None.
Source code in givenergy_modbus/client/commands.py
664 665 666 | |
set_ems_discharge_slot_start(idx, t)
¶
Set just the start of EMS plant discharge slot idx (1-3), or clear it if None.
Source code in givenergy_modbus/client/commands.py
659 660 661 | |
set_ems_discharge_target_soc(idx, target_soc)
¶
Set the SoC target (0-100%) for EMS plant discharge slot idx (1-3).
Source code in givenergy_modbus/client/commands.py
679 680 681 682 683 684 685 686 687 688 | |
set_ems_export_power_limit(watts)
¶
Set the EMS plant export power limit in watts.
Bounded to a 16-bit holding register (0-65535) so an out-of-range value fails here rather than later at PDU-encode time as InvalidPduState.
Source code in givenergy_modbus/client/commands.py
721 722 723 724 725 726 727 728 729 730 | |
set_ems_export_slot(idx, timeslot)
¶
Set an EMS plant export time slot by index (1-3), or clear it if None.
EMS export slots are the same HR(2062-2069) registers as set_export_slot
(export slots are EMS-only and already target the EMS address 0x11) — this is
the EMS-named alias for parity with set_ems_charge_slot/set_ems_discharge_slot.
Source code in givenergy_modbus/client/commands.py
691 692 693 694 695 696 697 698 | |
set_ems_export_slot_end(idx, t)
¶
Set just the end of EMS plant export slot idx (1-3), or clear it if None.
Source code in givenergy_modbus/client/commands.py
706 707 708 | |
set_ems_export_slot_start(idx, t)
¶
Set just the start of EMS plant export slot idx (1-3), or clear it if None.
Source code in givenergy_modbus/client/commands.py
701 702 703 | |
set_ems_export_target_soc(idx, target_soc)
¶
Set the SoC target (0-100%) for EMS plant export slot idx (1-3).
Source code in givenergy_modbus/client/commands.py
711 712 713 714 715 716 717 718 | |
set_ems_plant(enabled)
¶
Enable EMS plant control.
Source code in givenergy_modbus/client/commands.py
595 596 597 | |
set_enable_charge(enabled)
¶
Enable the battery to charge, depending on the mode and slots set.
Source code in givenergy_modbus/client/commands.py
260 261 262 | |
set_enable_discharge(enabled)
¶
Enable the battery to discharge, depending on the mode and slots set.
Source code in givenergy_modbus/client/commands.py
265 266 267 | |
set_enable_eps(enabled)
¶
Enable or disable Emergency Power Supply (EPS) mode on AC-coupled inverters.
Confirmed writable on Model.AC via direct portal observations (hass#52).
Source code in givenergy_modbus/client/commands.py
495 496 497 498 499 500 | |
set_enable_ev_charger(enabled)
¶
Enable or disable the EV charger (HR333). Installer-tier.
Source code in givenergy_modbus/client/commands.py
960 961 962 | |
set_enable_export_limit_3ph(enabled)
¶
Enable or disable export limit on three-phase inverters (HR1103). Installer-tier.
Source code in givenergy_modbus/client/commands.py
1036 1037 1038 | |
set_enable_generator(enabled)
¶
Enable or disable the generator (HR343). Installer-tier.
Source code in givenergy_modbus/client/commands.py
973 974 975 | |
set_enable_import_limit_3ph(enabled)
¶
Enable or disable import limit on three-phase inverters (HR1131). Installer-tier.
Source code in givenergy_modbus/client/commands.py
1041 1042 1043 | |
set_enable_micro_grid(enabled)
¶
Enable or disable micro grid mode (HR332). Installer-tier.
Source code in givenergy_modbus/client/commands.py
955 956 957 | |
set_enable_plant_mode(enabled)
¶
Enable or disable plant mode (HR300). Installer-tier.
Source code in givenergy_modbus/client/commands.py
950 951 952 | |
set_enable_rtc(enabled)
¶
Enable the Real Time Clock register to persist settings to EEPROM.
Source code in givenergy_modbus/client/commands.py
473 474 475 | |
set_enable_smart_load(enabled)
¶
Enable or disable smart load (HR540). Installer-tier.
Source code in givenergy_modbus/client/commands.py
994 995 996 | |
set_ev_charger_soc_limit(soc)
¶
Set EV charger SOC limit (HR336). Installer-tier. Range: 0–100 %.
Source code in givenergy_modbus/client/commands.py
965 966 967 968 969 970 | |
set_export_power_rate(rate)
¶
Set the three-phase export power rate cap (HR1063) as a percentage of rated power. Installer-tier.
rate is a percentage in [0, 100]; the register is written in its native 0.1% units
(raw = round(rate * 10), 0~1000). HR1063 is confirmed present on three-phase hardware via the
installer app (EXPORT_LIMIT_POWER_SET), but the write itself hasn't been validated against a
real three-phase unit yet — see #263. Use export_power_rate to read it back.
Source code in givenergy_modbus/client/commands.py
1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 | |
set_export_priority(priority)
¶
Set the export priority for surplus power on AC-coupled inverters.
Determines where surplus energy goes: battery first, grid first, or load first. Confirmed writable on Model.AC via direct portal observations (hass#52).
Source code in givenergy_modbus/client/commands.py
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | |
set_export_slot(idx, slot)
¶
Set an export time slot by index (1–3), or clear it if slot is None.
Source code in givenergy_modbus/client/commands.py
619 620 621 622 623 624 | |
set_export_slot_end(idx, t)
¶
Set just the end of an export time slot by index (1–3), or clear it if t is None.
Source code in givenergy_modbus/client/commands.py
613 614 615 616 | |
set_export_slot_start(idx, t)
¶
Set just the start of an export time slot by index (1–3), or clear it if t is None.
Source code in givenergy_modbus/client/commands.py
607 608 609 610 | |
set_f_ac_high_limit_grid(freq, *, confirm=False)
¶
Set AC over-frequency grid-band threshold (HR82). Installer-tier. Range 40.0–70.0 Hz.
Part of the G98/G99/G100 grid band. Pass confirm=True after verifying grid-code compliance. Value is written as centi (int(freq × 100)).
Source code in givenergy_modbus/client/commands.py
1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 | |
set_f_ac_high_limit_reconnect(freq, *, confirm=False)
¶
Set AC over-frequency reconnect threshold (HR74). Installer-tier. Range 40.0–70.0 Hz.
Part of the G98/G99/G100 reconnect band. Pass confirm=True after verifying grid-code compliance. Value is written as centi (int(freq × 100)).
Source code in givenergy_modbus/client/commands.py
1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 | |
set_f_ac_high_limit_trip(freq, *, confirm=False)
¶
Set AC over-frequency trip threshold (HR66). Installer-tier. Range 40.0–70.0 Hz.
Part of the G98/G99/G100 trip band. Pass confirm=True after verifying grid-code compliance. Value is written as centi (int(freq × 100)).
Source code in givenergy_modbus/client/commands.py
1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 | |
set_f_ac_low_limit_grid(freq, *, confirm=False)
¶
Set AC under-frequency grid-band threshold (HR81). Installer-tier. Range 40.0–70.0 Hz.
Part of the G98/G99/G100 grid band. Pass confirm=True after verifying grid-code compliance. Value is written as centi (int(freq × 100)).
Source code in givenergy_modbus/client/commands.py
1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 | |
set_f_ac_low_limit_reconnect(freq, *, confirm=False)
¶
Set AC under-frequency reconnect threshold (HR73). Installer-tier. Range 40.0–70.0 Hz.
Part of the G98/G99/G100 reconnect band. Pass confirm=True after verifying grid-code compliance. Value is written as centi (int(freq × 100)).
Source code in givenergy_modbus/client/commands.py
1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 | |
set_f_ac_low_limit_trip(freq, *, confirm=False)
¶
Set AC under-frequency trip threshold (HR65). Installer-tier. Range 40.0–70.0 Hz.
Part of the G98/G99/G100 trip band. Pass confirm=True after verifying grid-code compliance. Value is written as centi (int(freq × 100)).
Source code in givenergy_modbus/client/commands.py
1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 | |
set_force_charge(enabled)
¶
Enable forced battery charging on three-phase inverters.
Source code in givenergy_modbus/client/commands.py
585 586 587 | |
set_force_discharge(enabled)
¶
Enable forced battery discharging on three-phase inverters.
Source code in givenergy_modbus/client/commands.py
590 591 592 | |
set_general_load_control_soc(soc)
¶
Set general load control SOC (HR543). Installer-tier. App range: 50–100 %.
Source code in givenergy_modbus/client/commands.py
1007 1008 1009 1010 1011 1012 | |
set_generator_control_soc(soc)
¶
Set generator control SOC (HR544). Installer-tier. App range: 10–90 %.
Source code in givenergy_modbus/client/commands.py
1015 1016 1017 1018 1019 1020 | |
set_generator_start_soc(soc)
¶
Set generator start SOC threshold (HR344). Installer-tier. Range: 0–100 %.
Source code in givenergy_modbus/client/commands.py
978 979 980 981 982 983 | |
set_generator_stop_soc(soc)
¶
Set generator stop SOC threshold (HR345). Installer-tier. Range: 0–100 %.
Source code in givenergy_modbus/client/commands.py
986 987 988 989 990 991 | |
set_grid_import_limit_enabled(enabled)
¶
Enable or disable the grid import limit (HR102). Installer-tier.
Source code in givenergy_modbus/client/commands.py
945 946 947 | |
set_inverter_reboot()
¶
Restart the inverter.
Source code in givenergy_modbus/client/commands.py
270 271 272 | |
set_mode_dynamic()
¶
Set system to Dynamic / Eco mode.
This mode is designed to maximise use of solar generation. The battery will charge from excess solar generation to avoid exporting power, and discharge to meet load demand when solar power is insufficient to avoid importing power. This mode is useful if you want to maximise self-consumption of renewable generation and minimise the amount of energy drawn from the grid.
Source code in givenergy_modbus/client/commands.py
860 861 862 863 864 865 866 867 868 869 | |
set_mode_storage(discharge_slot_1=TimeSlot.from_repr(1600, 700), discharge_slot_2=None, discharge_for_export=False, slot_map=SINGLE_PHASE_SLOTS)
¶
Set system to storage mode with specific discharge slots(s).
This mode stores excess solar generation during the day and holds that energy ready for use later in the day. By default, the battery will start to discharge from 4pm-7am to cover energy demand during typical peak hours. This mode is particularly useful if you get charged more for your electricity at certain times to utilise the battery when it is most effective. If the second time slot isn't specified, it will be cleared.
You can optionally also choose to export excess energy: instead of discharging to meet only your load demand, the battery will discharge at full power and any excess will be exported to the grid. This is useful if you have a variable export tariff (e.g. Agile export) and you want to target the peak times of day (e.g. 4pm-7pm) when it is most valuable to export energy.
Source code in givenergy_modbus/client/commands.py
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 | |
set_pause_slot(slot)
¶
Set the battery pause time slot, or clear it if slot is None.
Source code in givenergy_modbus/client/commands.py
550 551 552 553 554 | |
set_pause_slot_end(t)
¶
Set just the end of the battery pause slot, or clear it if t is None.
Source code in givenergy_modbus/client/commands.py
545 546 547 | |
set_pause_slot_start(t)
¶
Set just the start of the battery pause slot, or clear it if t is None.
Source code in givenergy_modbus/client/commands.py
540 541 542 | |
set_peak_shaving_enabled(enabled)
¶
Enable or disable peak shaving (HR20002). Installer-tier.
Source code in givenergy_modbus/client/commands.py
1052 1053 1054 | |
set_peak_shaving_export_limit_enabled(enabled)
¶
Enable or disable peak-shaving grid export limit (HR20000). Installer-tier.
Source code in givenergy_modbus/client/commands.py
1046 1047 1048 1049 | |
set_shallow_charge(val)
¶
Set the minimum level of charge to maintain.
Source code in givenergy_modbus/client/commands.py
319 320 321 322 | |
set_smart_load_control_soc(soc)
¶
Set smart load control SOC (HR541). Installer-tier. App range: 50–100 %.
Source code in givenergy_modbus/client/commands.py
999 1000 1001 1002 1003 1004 | |
set_smart_load_slot(idx, slot)
¶
Set Smart Load slot idx (1-based, 1–10) atomically, or clear it if slot is None.
Source code in givenergy_modbus/client/commands.py
573 574 575 576 577 | |
set_smart_load_slot_end(idx, t)
¶
Set the end time of Smart Load slot idx (1-based, 1–10), or clear it if t is None.
Source code in givenergy_modbus/client/commands.py
565 566 567 568 569 570 | |
set_smart_load_slot_start(idx, t)
¶
Set the start time of Smart Load slot idx (1-based, 1–10), or clear it if t is None.
Source code in givenergy_modbus/client/commands.py
557 558 559 560 561 562 | |
set_system_date_time(dt)
¶
Set the date & time of the inverter.
Source code in givenergy_modbus/client/commands.py
844 845 846 847 848 849 850 851 852 853 854 855 856 857 | |
set_t_ac_high_freq_reconnect(seconds, *, confirm=False)
¶
Set AC over-frequency reconnect time (HR78). Installer-tier. Value in seconds (centi-scaled).
Part of the G98/G99/G100 reconnect band. Pass confirm=True after verifying grid-code compliance. Value is written as centi (int(seconds × 100)).
Source code in givenergy_modbus/client/commands.py
1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 | |
set_t_ac_high_freq_trip(seconds, *, confirm=False)
¶
Set AC over-frequency trip time (HR70). Installer-tier. Value in seconds (centi-scaled).
Part of the G98/G99/G100 trip band. Pass confirm=True after verifying grid-code compliance. Value is written as centi (int(seconds × 100)).
Source code in givenergy_modbus/client/commands.py
1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 | |
set_t_ac_high_voltage_reconnect(seconds, *, confirm=False)
¶
Set AC over-voltage reconnect time (HR76). Installer-tier. Value in seconds (centi-scaled).
Part of the G98/G99/G100 reconnect band. Pass confirm=True after verifying grid-code compliance. Value is written as centi (int(seconds × 100)).
Source code in givenergy_modbus/client/commands.py
1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 | |
set_t_ac_high_voltage_trip(seconds, *, confirm=False)
¶
Set AC over-voltage trip time (HR68). Installer-tier. Value in seconds (centi-scaled).
Part of the G98/G99/G100 trip band. Pass confirm=True after verifying grid-code compliance. Value is written as centi (int(seconds × 100)).
Source code in givenergy_modbus/client/commands.py
1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 | |
set_t_ac_low_freq_reconnect(seconds, *, confirm=False)
¶
Set AC under-frequency reconnect time (HR77). Installer-tier. Value in seconds (centi-scaled).
Part of the G98/G99/G100 reconnect band. Pass confirm=True after verifying grid-code compliance. Value is written as centi (int(seconds × 100)).
Source code in givenergy_modbus/client/commands.py
1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 | |
set_t_ac_low_freq_trip(seconds, *, confirm=False)
¶
Set AC under-frequency trip time (HR69). Installer-tier. Value in seconds (centi-scaled).
Part of the G98/G99/G100 trip band. Pass confirm=True after verifying grid-code compliance. Value is written as centi (int(seconds × 100)).
Source code in givenergy_modbus/client/commands.py
1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 | |
set_t_ac_low_voltage_reconnect(seconds, *, confirm=False)
¶
Set AC under-voltage reconnect time (HR75). Installer-tier. Value in seconds (centi-scaled).
Part of the G98/G99/G100 reconnect band. Pass confirm=True after verifying grid-code compliance. Value is written as centi (int(seconds × 100)).
Source code in givenergy_modbus/client/commands.py
1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 | |
set_t_ac_low_voltage_trip(seconds, *, confirm=False)
¶
Set AC under-voltage trip time (HR67). Installer-tier. Value in seconds (centi-scaled).
Part of the G98/G99/G100 trip band. Pass confirm=True after verifying grid-code compliance. Value is written as centi (int(seconds × 100)).
Source code in givenergy_modbus/client/commands.py
1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 | |
set_v_ac_10min_protect(voltage, *, confirm=False)
¶
Set 10-minute mean AC voltage protection threshold (HR83). Installer-tier. Range 0.0–500.0 V.
G98/G99/G100 10-minute mean voltage protection. Pass confirm=True after verifying grid-code compliance. Value is written as deci (int(voltage × 10)).
Source code in givenergy_modbus/client/commands.py
1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 | |
set_v_ac_high_limit_grid(voltage, *, confirm=False)
¶
Set AC over-voltage grid-band threshold (HR80). Installer-tier. Range 0.0–500.0 V.
Part of the G98/G99/G100 grid band. Pass confirm=True after verifying grid-code compliance. Value is written as deci (int(voltage × 10)).
Source code in givenergy_modbus/client/commands.py
1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 | |
set_v_ac_high_limit_reconnect(voltage, *, confirm=False)
¶
Set AC over-voltage reconnect threshold (HR72). Installer-tier. Range 0.0–500.0 V.
Part of the G98/G99/G100 reconnect band. Pass confirm=True after verifying grid-code compliance. Value is written as deci (int(voltage × 10)).
Source code in givenergy_modbus/client/commands.py
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 | |
set_v_ac_high_limit_trip(voltage, *, confirm=False)
¶
Set AC over-voltage trip threshold (HR64). Installer-tier. Range 0.0–500.0 V.
Part of the G98/G99/G100 trip band. Pass confirm=True after verifying grid-code compliance. Value is written as deci (int(voltage × 10)).
Source code in givenergy_modbus/client/commands.py
1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 | |
set_v_ac_low_limit_grid(voltage, *, confirm=False)
¶
Set AC under-voltage grid-band threshold (HR79). Installer-tier. Range 0.0–500.0 V.
Part of the G98/G99/G100 grid band. Pass confirm=True after verifying grid-code compliance. Value is written as deci (int(voltage × 10)).
Source code in givenergy_modbus/client/commands.py
1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 | |
set_v_ac_low_limit_reconnect(voltage, *, confirm=False)
¶
Set AC under-voltage reconnect threshold (HR71). Installer-tier. Range 0.0–500.0 V.
Part of the G98/G99/G100 reconnect band. Pass confirm=True after verifying grid-code compliance. Value is written as deci (int(voltage × 10)).
Source code in givenergy_modbus/client/commands.py
1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 | |
set_v_ac_low_limit_trip(voltage, *, confirm=False)
¶
Set AC under-voltage trip threshold (HR63). Installer-tier. Range 0.0–500.0 V.
Part of the G98/G99/G100 trip band. Pass confirm=True after verifying grid-code compliance. Value is written as deci (int(voltage × 10)).
Source code in givenergy_modbus/client/commands.py
1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 | |
three_phase_factory_reset(*, confirm=False)
¶
Trigger three-phase factory reset without meter reset (HR1016). Irreversible.
Resets inverter configuration to factory defaults, excluding meter data. Pass confirm=True to proceed.
Source code in givenergy_modbus/client/commands.py
1359 1360 1361 1362 1363 1364 1365 1366 1367 | |
Model¶
Plant
¶
Bases: GivEnergyBaseModel
Representation of a complete GivEnergy plant.
Source code in givenergy_modbus/model/plant.py
699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 | |
aio_battery_modules
property
¶
Return per-module AIO battery models (#192), one per separate-address module cache.
All-in-One units expose each removable module at its own device address (0x50-0x53), each carrying 24 cell voltages, temperatures, and the module's own serial. Empty for non-AIO plants and until the module caches have been polled.
batteries
property
¶
Return Battery models for the Plant.
A capabilities-listed address with no register cache yields an all-None placeholder Battery at its index rather than being dropped (#213) — a transiently-absent pack (e.g. a BMS slow to answer after a restart) stays present-but-unavailable and index- aligned instead of shifting its siblings' entities. Subsequent refresh()es populate it if it responds.
devices
property
¶
Canonical flat topology walk (#106): root first, children with parent refs.
Returns exactly one root row (parent=None) — a GATEWAY, EMS, or
INVERTER row depending on plant shape, in that priority order — and
every other device as a flat child row parented to that root's
identity. Exactly one row is is_control_authority=True: the
root. Children are sorted by (device_type.value, identity) for a
deterministic order.
On an EMS plant, managed inverters are their own INVERTER child rows
(identity {serial}_managed when blinded, else the inverter's own
serial) rather than nested under the EMS row — a controller (EMS or
gateway) never appears as an INVERTER row, and #106's flat contract
means every device gets its own row with an explicit parent.
ems
property
¶
Return Ems model for EMS/EMS_COMMERCIAL device types; None otherwise.
gateway
property
¶
Return GatewayV1 or GatewayV2 model for GATEWAY device type; None otherwise.
hv_stacks
property
¶
Return HV battery stacks (BCU + per-module BMUs) for HV systems; [] for LV systems.
Each BMU is decoded from its own device-address cache (0x50 + running module index,
contiguous across stacks), matching the separate-address AIO layout. Single-stack
allocation is installer-confirmed; the multi-stack stride is not yet wire-confirmed
(#265). Module caches that haven't been polled (or don't respond) decode to all-None and
report is_valid() == False.
inverter
property
¶
Return the inverter model, dispatching on device type when capabilities are available.
Tolerates the inverter-address cache not yet existing — a pre-#189 persisted
capability may still point at 0x31, which detect() doesn't populate (it reads
identity at 0x11), so this would otherwise KeyError between detect() and the
first poll. Returns an empty-cache model in that window, matching the
.ems / .gateway accessors. Without capabilities the inverter is read at its
canonical address 0x11 (#352) — not 0x32, which is LV battery pack #1 — via
.get since 0x11 is not pre-allocated on a bare Plant. (#119, #189)
inverter_serial
property
¶
Single authoritative inverter serial, robust across the whole plant lifecycle (#227).
Resolves the earliest-available inverter identity by trying, in order:
- HR(13-17) in the capability-selected inverter cache (
inverter_address— 0x11 since #189; 0x31 only via a pre-#189 persisted capability); - HR(13-17) in the 0x11 cache —
detect()'sHR(0,60)identity read lands here for every model, so this covers the detect→first-refresh window when a stale capability still points at 0x31; - the
inverter_serial_numberenvelope field — populated atdetect()and the only home on a persisted/bare plant carrying no register caches.
A register block is only accepted if it decodes to a valid serial (is_valid_serial —
the same coherence gate _commit_bank ingestion uses), so a malformed/partial block in a
restored or tampered cache falls through to the envelope rather than outranking it.
Deliberately never reads the 0x32 battery cache, so a bare or pre-detect plant can't
surface a battery pack's serial as the inverter's. Reads via .get() so it never
mutates the (defaultdict) caches. Once consumers move to this accessor, the envelope
field can be deprecated.
inverters
property
¶
Return one :class:Inverter facade per inverter in this plant.
For an EMS plant without direct sources: yields one :class:Inverter per
non-empty managed-inverter slot in the EMS's IR(2040+) rollup
(data_source="ems_rollup").
For an EMS plant with direct sources (injected via :meth:add_direct_source):
reconciles EMS summaries with direct-inverter caches by serial number.
Matching serials produce merged inverters (data_source="merged"); EMS
slots without a matching direct source stay blinded; direct sources whose
serial is not in the EMS rollup appear as orphan data_source="direct"
entries (#106 Phase 3).
For a non-EMS plant: yields a single :class:Inverter wrapping the existing
:attr:inverter (data_source="direct"). The legacy :attr:inverter
(singular) accessor remains for back-compat.
last_updated_at
property
¶
Newest register-block ingestion time across the whole plant, or None if never seen.
The honest "is the cache being kept fresh" signal for a passive consumer (#65): it
advances whenever ANY bank commits — solicited or fanned-out from a peer client —
regardless of content, so a stale bus is visible as a signal that stops moving.
Because it keys off commit rather than value, it is meaningful even on a Gateway
(where the synthetic all-zeros inverter makes system_time spurious) and is
topology-agnostic. None before the first commit (cold). Consumers derive age as
now - last_updated_at.
lv_bcu
property
¶
Return the LV BCU stack-level block, or None when absent.
None when capabilities are unset, the block wasn't detected (firmware-gated — see model/lv_bcu.py), or its cache hasn't been populated yet.
meters
property
¶
Return Meter models keyed by device address.
A listed-but-uncached meter address yields an all-None placeholder Meter at its key rather than being omitted (#213), so a transiently-absent meter reads as present-but- unavailable and is repopulated on a later refresh() if it responds.
number_batteries
property
¶
Determine the number of batteries connected to the system based on whether the register data is valid.
remaining_battery_energy_wh
property
¶
Total remaining battery energy (Wh) summed over this Plant's LV packs (#374).
Nominal-voltage basis (Battery.remaining_energy_nominal_wh). This sums every pack on
this dongle, so on an inverter with a primary/secondary chain it includes the secondary
pack the EMS controller's own figure (Ems.remaining_battery_wh, IR2091) drops.
Returns None (not 0) when no pack decodes — e.g. an EMS-controller dongle has no
LV battery sub-bus, so its Plant returns None rather than a misleading 0 Wh.
Scope: one Plant is one dongle, and battery sub-bus addresses collide across managed inverters (each reuses 0x32-0x37), so this cannot span inverters. A consumer holding several inverter connections sums their per-Plant values for the site total.
serial_index
property
¶
Map each known inverter serial number to its :class:Inverter facade.
Built from :attr:inverters, so the same reconciliation logic applies:
merged entries (direct + EMS rollup) have data_source="merged",
blinded EMS-only entries have data_source="ems_rollup", and direct-only
entries have data_source="direct".
add_direct_source(caches)
¶
Store direct-inverter register caches for serial reconciliation (#106 Phase 3).
Caches are stored separately from register_caches to avoid the Modbus
address collision (both the EMS controller and a directly-connected inverter
live at 0x11). Call this on an EMS plant after collecting data from a second
Client pointing at one of the EMS-managed inverters; inverters and
serial_index will then return merged views for matching serials.
Source code in givenergy_modbus/model/plant.py
2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 | |
block_age(device_address, reg_type, base_register, register_count, *, now=None)
¶
Seconds since a register block was last committed, or None if never seen.
reg_type is "HR" or "IR". register_count must match the count used
when the block was stamped — typically 60 for standard GivEnergy IR/HR blocks. This
prevents a partial response (e.g. IR(0,1)) from being mistaken for a full IR(0,60)
block by the skip-if-fresh logic in refresh() (#196).
Used to reason about freshness and staleness in the fan-out skip (#196) and Pattern B all-zero rejection (#206).
Source code in givenergy_modbus/model/plant.py
1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 | |
block_present(device_address, reg_type, base_register, register_count)
¶
Return presence status of a register block: True = present, False = absent, None = unknown.
Parallel to block_age()'s None-for-never semantics. Present means a bank was committed
(update() stamped it); absent means mark_absent() was called (detect found nothing
usable); None means the block has never been attempted on this Plant instance.
Source code in givenergy_modbus/model/plant.py
1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 | |
content_unchanged_seconds(device_address, reg_type, base_register, register_count, *, now=None)
¶
Seconds a register block's content has been byte-identical, or None if never seen (#91).
Reports a raw duration, not a freeze verdict: a high value may indicate a frozen BMS cache (e.g. a battery whose BMS is in firmware-update bootloader mode), but on the real capture corpus healthy LV batteries also hold IR(60,60) content steady for long stretches (dongle fan-out + genuinely-static telemetry). Distinguishing a freeze from a live-but- static device needs a threshold validated against more freeze captures than currently exist, so this method deliberately makes no claim — callers compose it with their own policy. See #91.
reg_type is "HR" or "IR"; register_count must match the committed block.
Source code in givenergy_modbus/model/plant.py
1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 | |
from_caches(register_caches, prior=None, *, inverter_serial_number='', data_adapter_serial_number='')
classmethod
¶
Build a fully-typed Plant from an injected register-cache set, with no live client (#268).
Capabilities are derived from the caches (no wire I/O) via :func:_derive_capabilities, so
every typed view (.inverter/.batteries/.meters/.hv_stacks/.ems/
.inverters) works exactly as on a live-detected plant. The recipe for a capture dump is
Plant.from_caches(plant_from_capture(path).register_caches).
Raises :class:CommunicationError if HR(0) is absent at device 0x11.
Source code in givenergy_modbus/model/plant.py
845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 | |
invalidate_presence(device_address, reg_type, base_register, register_count)
¶
Drop the presence marker, cached registers, and freshness stamps for a block → UNKNOWN.
A stale "present" must not outlive a topology change: invalidating removes the marker so
the next poll resolves absence/presence from scratch, clears the cached registers so the
typed views don't serve stale data, and clears the freshness stamp so skip-if-fresh
(refresh(ir0_max_age=...)) does not suppress the re-probe.
Source code in givenergy_modbus/model/plant.py
1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 | |
mark_absent(device_address, reg_type, base_register, register_count)
¶
Record that a probe found this block absent (probe timeout, all-zero, or is_valid() False).
Only called from detect-helper rejection sites in client.py, not from update() — a rejected bank during a live refresh is not "absent", just noisy. Consumers can read this to distinguish "device never responded" from "device unknown" without grepping logs.
Source code in givenergy_modbus/model/plant.py
1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 | |
model_post_init(__context)
¶
Ensure a default register cache is always present.
Source code in givenergy_modbus/model/plant.py
840 841 842 843 | |
record_retry(device_address)
¶
Record a consumed read retry for a device (#284); called by the Client per retry.
Source code in givenergy_modbus/model/plant.py
947 948 949 | |
redact()
¶
Return a share-safe copy: every register cache redacted and the header serials cleared.
redact_serials() only covers the register caches; inverter_serial_number and
data_adapter_serial_number live on the Plant itself (populated from the PDU envelope),
so a dumped Plant still leaks both unless they're redacted here too. The original is left
untouched (#212/#214 share-safe-export guarantee).
Source code in givenergy_modbus/model/plant.py
919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 | |
register_age(device_address, register, *, now=None)
¶
Seconds since the freshest stamped block containing register was committed (#247).
Unlike block_age(), the caller doesn't need to know block boundaries or the
stamped count — every stamped window for the device whose [base, base+count) span
covers the register is considered, and the freshest wins. None if no stamped
window covers it. Pair with RegisterGetter.registers_of() to reason about a
model attribute's freshness.
Source code in givenergy_modbus/model/plant.py
1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 | |
update(pdu, *, received_at=None)
¶
Update the Plant state from a PDU message.
received_at overrides the ingestion timestamp recorded for a committed
register block (see register_block_updated_at / #65); it defaults to the
current UTC time and is provided mainly for deterministic testing and replay.
Source code in givenergy_modbus/model/plant.py
951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 | |
PlantCapabilities
¶
Bases: BaseModel
Describes the hardware topology discovered by Client.detect().
Returned by Client.detect(); callers assign it to plant.capabilities or persist it for faster restarts (see fork-merge-plan deferred items).
Legacy *_slave(s) keyword aliases are mapped to the canonical names
in __init__ (for PlantCapabilities(...) callers) and again in the
_accept_legacy_aliases model_validator (for model_validate({...})
callers). Both paths emit a DeprecationWarning.
Source code in givenergy_modbus/model/plant.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 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 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 | |
bcu_slaves
property
writable
¶
Deprecated alias for bcu_stacks.
has_ac_config_block
property
¶
Return True if this system exposes the HR(300-359) AC-output config block.
Covers export priority, EPS enable, AC charge/discharge limits and pause mode —
present on AC-coupled inverters and the All-in-One, absent (times out) on
DC-coupled/hybrid models. See manifest.CAPABILITIES["has_ac_config_block"] (#162).
Strictly a register-surface fact: block presence does not mean HR(313/314)
replaces the DC battery-rate pair HR(111/112) — on the All-in-One the DC pair
remains the operative battery-rate control (hass#281). Route control decisions
on is_ac_coupled instead (#302).
has_extended_slots
property
¶
Return True if this system supports the extended 10-slot map (HR 240–299).
has_hv_cabinet_block
property
¶
Return True if this system exposes a readable HR(499-510) HV cabinet topology block.
Currently False for every model: no inverter has been confirmed to answer the read on
real hardware. See manifest.CAPABILITIES["has_hv_cabinet_block"] (#265).
has_peak_shaving_block
property
¶
Return True if this system exposes a readable HR(20000-20051) peak-shaving block.
Currently False for every model: no inverter has been confirmed to answer the read on
real hardware. See manifest.CAPABILITIES["has_peak_shaving_block"].
has_smart_load_block
property
¶
Return True if this system exposes a readable HR(540-599) Smart Load block.
Currently False for every model: no inverter has been confirmed to answer the
read on real hardware, and HYBRID_GEN1 is confirmed to time out on it. See
manifest.CAPABILITIES["has_smart_load_block"] (#179).
inverter_slave
property
writable
¶
Deprecated alias for inverter_address.
is_ac_coupled
property
¶
Return True if this system is AC-coupled (no integrated DC battery).
is_ems
property
¶
Return True if this system is an EMS plant controller (HR/IR 2040-range).
is_gateway
property
¶
Return True if this system is a Gateway (IR 1600-range).
is_hv
property
¶
Return True if this system uses HV battery stacks (BCU/BMU) rather than LV packs.
is_three_phase
property
¶
Return True if this system uses three-phase registers (HR/IR 1000-range).
lv_battery_slaves
property
writable
¶
Deprecated alias for lv_battery_addresses.
meter_slaves
property
writable
¶
Deprecated alias for meter_addresses.
from_dict(data)
classmethod
¶
Reconstruct from a to_dict() payload.
Accepts two on-disk shapes:
- v2.0.0 (legacy, no
schema_version):device_typeas the enum value (e.g."2"), addresses as raw integers, noschema_versionkey. Persisted by the v2.0.0to_dict(). - v2.0.1+ (versioned):
schema_versionpresent and equal toSCHEMA_VERSION,device_typeas enum name (e.g."HYBRID_GEN1"), addresses as"0x..."hex strings.
A schema_version that's present but doesn't match SCHEMA_VERSION
raises ValueError — callers can catch and re-run detect() without
prior. Pre-rename *_slave(s) key aliases are normalised silently so
state persisted under the older conventions still loads cleanly.
Source code in givenergy_modbus/model/plant.py
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 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | |
to_dict()
¶
Serialise to a JSON-safe dict for caller-managed persistence.
Round-trips through from_dict(). Addresses render as 0x.. strings to
match the form used in logs, exceptions, and code. The schema_version
field gives future-us an escape hatch for format changes.
Source code in givenergy_modbus/model/plant.py
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | |
BatteryCalibrationStage
¶
Bases: int, Enum
Battery calibration stages.
Source code in givenergy_modbus/model/inverter.py
323 324 325 326 327 328 329 330 331 332 333 | |
BatteryPowerMode
¶
Bases: int, Enum
Battery discharge strategy.
Source code in givenergy_modbus/model/inverter.py
316 317 318 319 320 | |
BatteryType
¶
Bases: int, Enum
Installed battery type.
Source code in givenergy_modbus/model/inverter.py
343 344 345 346 347 | |
Certification
¶
Bases: IntEnum
Grid compliance certification.
Source code in givenergy_modbus/model/inverter.py
386 387 388 389 390 391 392 393 394 395 396 397 | |
ChargeStatus
¶
Bases: IntEnum
Known charge-status codes observed on single-phase inverters (IR(14), #222).
Raw int accessible via charge_status; typed label via charge_status_label.
Unknown codes decode to None via charge_status_label rather than raising.
Source code in givenergy_modbus/model/inverter.py
450 451 452 453 454 455 456 457 458 459 460 | |
Generation
¶
Bases: StrEnum
Inverter hardware generation.
Source code in givenergy_modbus/model/inverter.py
413 414 415 416 417 418 419 420 421 422 | |
InverterType
¶
Bases: IntEnum
Inverter phase and voltage type.
Source code in givenergy_modbus/model/inverter.py
400 401 402 403 404 405 406 407 408 409 410 | |
MeterType
¶
Bases: int, Enum
Installed meter type.
Source code in givenergy_modbus/model/inverter.py
336 337 338 339 340 | |
Model
¶
Bases: str, Enum
Known models of inverters.
Single-digit values are the coarse family (first digit of the DTC); these are
what Model(dtc_string) returns via _missing_ for backward compatibility.
Two-character and "20gN" values are more specific variants reachable via
resolve_model(raw_dtc, arm_fw) or by direct construction e.g. Model("81").
Note: Gen 2 inverters with an 'EA' serial prefix were previously mapped via a serial-prefix lookup table (removed in 1.0). Their device type code first digit is unknown — if EA-prefix units report a code not listed here, missing will raise ValueError. A field report from a Gen 2 owner is needed to add support.
Source code in givenergy_modbus/model/inverter.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
system_battery_voltage
property
¶
Represent nominal battery voltage for this system.
Phase
¶
Bases: IntEnum
Number of AC phases.
Source code in givenergy_modbus/model/inverter.py
436 437 438 439 440 441 442 443 444 445 446 447 | |
PowerFactorFunctionModel
¶
Bases: int, Enum
Power Factor function model.
Source code in givenergy_modbus/model/inverter.py
350 351 352 353 354 355 356 357 358 359 | |
SinglePhaseInverter
¶
Bases: _SinglePhaseInverterBase, _InverterCommands, RegisterMetadataMixin
GivEnergy single-phase inverter data model.
Composes the _InverterCommands mixin so consumers can call
inverter.set_*(...) directly instead of routing through
givenergy_modbus.client.commands.*. The mixin reads self.slot_map so
slot setters no longer need it threaded through by callers. Model-specific
command mixins (three-phase, EMS, pause-mode) will compose in additively
in later 2.x minors — see #75.
Source code in givenergy_modbus/model/inverter.py
1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 | |
battery_capacity_kwh
property
¶
Returns the nominal battery capacity in kWh, derived from Ah and model voltage.
battery_charge_power
property
¶
Non-negative battery charge power (W); zero when discharging or idle (#205).
battery_discharge_power
property
¶
Non-negative battery discharge power (W); zero when charging or idle (#205).
battery_max_power
property
¶
Returns the rated battery charge/discharge power in watts, derived from model and firmware.
e_battery_charge_today
property
¶
Canonical daily battery charge energy (kWh), routed by model (see #76).
e_battery_charge_total
property
¶
Canonical total battery charge energy (kWh), routed by model (see #76).
e_battery_discharge_today
property
¶
Canonical daily battery discharge energy (kWh), routed by model (see #76).
e_battery_discharge_total
property
¶
Canonical total battery discharge energy (kWh), routed by model (see #76).
e_consumption_today
property
¶
House consumption today (kWh), matching the GE app's "Consumption today".
DERIVED, not metered: single-phase units expose no consumption register, so the GE app computes this value. Sentinel cross-correlation against the app's Energy-today screen (#174) recovered the exact formula:
consumption = pv_generation + grid_import − grid_export − ac_charge
Battery DC charge/discharge throughput nets out and is not a term. The result carries the same conversion-loss bias the app shows (energy balance overshoots real consumption by a few %). This is the GE-universe definition of "consumption" specifically — other plant equipment may define it differently.
Three-phase units have a native e_load_today register and so do NOT get this computed field (it lives on SinglePhaseInverter only, not in the register LUT).
On AC-coupled and All-in-One units this returns None: manifest.py's IR44 identity routing (#293) already makes e_pv_generation_today None there (the register carries inverter output, not PV, on those models), so the pv term's own None-propagation below does the rest — no separate AC/AIO guard needed. A candidate corrected-AIO consumption formula was evaluated against wire evidence and failed the evidence gate; see manifest.py's module comment.
Returns None if any input is unavailable.
e_inverter_out_day
property
¶
Deprecated alias for e_inverter_out_today (AC/AIO) or e_pv_generation_today (hybrids, #293).
e_pv_direct_today
property
¶
PV energy used directly by load today (kWh): solar bypassing battery and grid.
DERIVED: (pv_generation − grid_export) − pv_to_battery, clamped to [0, pv − grid_export], where pv_to_battery = max(0, battery_charge − ac_charge).
e_battery_charge lumps PV-sourced and AC-sourced charge into one counter, so the PV portion that went to the battery is battery_charge − ac_charge — subtracting it leaves the PV that reached load directly. Without the ac_charge term the figure would under-count by the day's AC-charge energy on time-of-use tariffs (Octopus Go / Predbat); for pure-solar systems ac_charge is 0 and it's a no-op.
Both bounds matter. The lower clamp (≥ 0) handles export exceeding PV. The upper clamp (≤ pv − grid_export, via flooring pv_to_battery at 0) handles AC→DC conversion loss / counter skew making ac_charge momentarily exceed battery_charge: without it, direct PV could exceed total on-site PV self-consumption, which is nonsensical (a subset can't beat its superset) — Codex review on #313.
Effectively restricted to DC-coupled solar hybrids: on AC-coupled and All-in-One units the PV-generation registers (IR44/45-46) are mislabelled — they carry the inverter's battery-discharge AC output, not PV (#293) — and manifest.py's IR44 identity routing already makes e_pv_generation_today None there, so the pv term's None-propagation below returns None with no separate AC/AIO guard needed. A candidate corrected-AIO formula was evaluated against wire evidence and failed the evidence gate; see manifest.py's module comment. In practice e_battery_charge_today only routes on HYBRID_GEN1 today (see manifest.VALUE_SOURCES / #184), so the field is currently GEN1-effective and returns None on other DC models until that map widens.
Only daily is offered: the lifetime equivalent needs e_ac_charge_total, which single-phase firmware does not expose (three-phase only, IR1378/9).
NOT monotonically increasing intraday — a grid-export burst can dip it — so consumers using state_class TOTAL_INCREASING MUST apply their own monotonic clamp (e.g. HA's monotonic=True path). Returns None if any input is unavailable or the pv term is unavailable for this model (AC/AIO).
e_self_consumption_today
property
¶
Self-consumption energy today (kWh): PV generation used on-site (GivTCP parity).
DERIVED: PV generation today − grid export today, clamped at ≥ 0.
Two limitations to be aware of: - Battery-to-grid export is counted in grid_out, so this slightly under-counts true self-consumption when the battery discharges to grid. GivTCP accepts this approximation; we match it here. - NOT monotonically increasing: when battery exports to grid, grid_out rises without pv_generation rising, causing the difference to dip. Consumers that use state_class TOTAL_INCREASING (e.g. HA energy dashboard) MUST apply their own monotonic clamp rather than consuming the raw value directly.
On AC-coupled and All-in-One units this returns None via the same None-propagation as e_consumption_today: manifest.py's IR44 identity routing (#293) already makes e_pv_generation_today None there.
Returns None if any input is unavailable.
e_self_consumption_total
property
¶
Lifetime self-consumption energy (kWh): PV generation used on-site (GivTCP parity).
DERIVED: PV generation total − grid export total, clamped at ≥ 0.
Same battery-to-grid under-count and non-monotonicity caveats as e_self_consumption_today: the difference of two running counters is not guaranteed to increase monotonically. Consumers using state_class TOTAL_INCREASING MUST apply a monotonic clamp (e.g. HA's monotonic=True sensor path) rather than consuming the raw value directly.
On AC-coupled and All-in-One units this returns None: manifest.py's IR44 identity routing (#293) already makes e_pv_generation_total None there.
Returns None if any input is unavailable.
enable_standard_self_consumption_logic
property
¶
Deprecated alias for enable_inverter_parallel_mode.
f_ac_high_limit_1
property
¶
Deprecated alias for f_ac_high_limit_trip.
f_ac_high_limit_2
property
¶
Deprecated alias for f_ac_high_limit_reconnect.
f_ac_high_limit_3
property
¶
Deprecated alias for f_ac_high_limit_grid.
f_ac_low_limit_1
property
¶
Deprecated alias for f_ac_low_limit_trip.
f_ac_low_limit_2
property
¶
Deprecated alias for f_ac_low_limit_reconnect.
f_ac_low_limit_3
property
¶
Deprecated alias for f_ac_low_limit_grid.
fault_code
property
¶
Deprecated alias for inverter_fault_code + inverter_warning_code (recombined).
grid_export_power
property
¶
Non-negative grid export power (W); zero when importing or idle (#205).
grid_import_power
property
¶
Non-negative grid import power (W); zero when exporting or idle (#205).
inverter_max_power
property
¶
Returns the rated inverter power in watts, derived from the device type code.
is_ac_coupled
property
¶
True for AC-coupled inverters (no integrated DC battery).
Coarse-family resolution is correct here: AC DTCs resolve to Model.AC / Model.AC_3PH and neither has specific sub-variants. False when the model is unknown (DTC unread).
slot_map
property
¶
Register address pairs for the charge/discharge time slots on this model.
t_ac_high_freq_1
property
¶
Deprecated alias for t_ac_high_freq_trip.
t_ac_high_freq_2
property
¶
Deprecated alias for t_ac_high_freq_reconnect.
t_ac_high_voltage_1
property
¶
Deprecated alias for t_ac_high_voltage_trip.
t_ac_high_voltage_2
property
¶
Deprecated alias for t_ac_high_voltage_reconnect.
t_ac_low_freq_1
property
¶
Deprecated alias for t_ac_low_freq_trip.
t_ac_low_freq_2
property
¶
Deprecated alias for t_ac_low_freq_reconnect.
t_ac_low_voltage_1
property
¶
Deprecated alias for t_ac_low_voltage_trip.
t_ac_low_voltage_2
property
¶
Deprecated alias for t_ac_low_voltage_reconnect.
v_ac_high_limit_1
property
¶
Deprecated alias for v_ac_high_limit_trip.
v_ac_high_limit_2
property
¶
Deprecated alias for v_ac_high_limit_reconnect.
v_ac_high_limit_3
property
¶
Deprecated alias for v_ac_high_limit_grid.
v_ac_low_limit_1
property
¶
Deprecated alias for v_ac_low_limit_trip.
v_ac_low_limit_2
property
¶
Deprecated alias for v_ac_low_limit_reconnect.
v_ac_low_limit_3
property
¶
Deprecated alias for v_ac_low_limit_grid.
work_time_total
property
¶
Deprecated alias for work_time_total_hours.
e_pv_day()
¶
Computes the total PV energy for the day, or None if either input is unavailable.
Source code in givenergy_modbus/model/inverter.py
1045 1046 1047 1048 1049 | |
from_register_cache(register_cache)
classmethod
¶
Construct a SinglePhaseInverter from a RegisterCache.
Source code in givenergy_modbus/model/inverter.py
1034 1035 1036 1037 | |
p_pv()
¶
Computes the total PV power, or None if either input is unavailable.
Source code in givenergy_modbus/model/inverter.py
1039 1040 1041 1042 1043 | |
SinglePhaseInverterRegisterGetter
¶
Bases: RegisterGetter
Structured format for all inverter attributes.
Source code in givenergy_modbus/model/inverter.py
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 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 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 | |
Status
¶
Bases: int, Enum
Inverter status.
Source code in givenergy_modbus/model/inverter.py
362 363 364 365 366 367 368 369 | |
UsbDevice
¶
Bases: int, Enum
USB devices that can be inserted into inverters.
Source code in givenergy_modbus/model/inverter.py
308 309 310 311 312 313 | |
WorkMode
¶
Bases: IntEnum
Inverter work mode.
Source code in givenergy_modbus/model/inverter.py
372 373 374 375 376 377 378 379 380 381 382 383 | |
__getattr__(name)
¶
PEP 562 module attribute deprecation shim.
Serves two deprecated names — the pre-existing Inverter rename alias, and
AC_COUPLED_MODELS (moved to manifest.CAPABILITIES["is_ac_coupled"], #293 Slice B).
Both are kept accessible here for backward compatibility until the 3.0
deprecation horizon. Deliberately a single __getattr__: Python only honours the
last one defined at module scope, so a second definition would silently shadow
this one rather than raising or merging.
Source code in givenergy_modbus/model/inverter.py
1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 | |
inverter_address_for(model)
¶
Return the modbus device address the inverter's registers are served at.
0x11 is the canonical inverter address for all models. AC and HYBRID_GEN1
units additionally expose their registers at 0x31 — a facade over the same
register file (value-equality verified across 114 shared HR registers on a
live HYBRID_GEN1, and byte-identical HR banks on two live AC units; #189) —
but 0x11 is where the official app reads and writes, and where detect()
always reads identity. EMS and All-in-One controllers likewise serve all
their data — including the IR/HR(2040) rollup — at 0x11.
Capabilities persisted before the 0x31 retirement may still carry an
explicit inverter_address of 0x31; that keeps working (the hardware
facade still answers there) and self-heals to 0x11 on the next
detect().
Source code in givenergy_modbus/model/inverter.py
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | |
resolve_model(raw_dtc, arm_fw)
¶
Return the most specific Model for a given device type code and ARM firmware version.
raw_dtc is the raw integer value of HR(0) (e.g. 0x2001).
arm_fw is the raw ARM firmware version integer from HR(21).
Use this in preference to plain Model(dtc) when you have both values available.
Model(dtc) continues to work and returns the coarse family for backward compat.
Source code in givenergy_modbus/model/inverter.py
273 274 275 276 277 278 279 280 281 282 283 284 285 286 | |
Battery
¶
Bases: _BatteryBase, RegisterMetadataMixin
GivEnergy battery data model.
Source code in givenergy_modbus/model/battery.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
remaining_energy_measured_wh
property
¶
Remaining stored energy (Wh), measured-voltage basis: cap_remaining × v_out.
Instantaneous; fluctuates ~2-3% with SOC and sags under load. None if cap_remaining or v_out is None.
remaining_energy_nominal_wh
property
¶
Remaining stored energy (Wh), nominal-voltage basis: cap_remaining × num_cells × 3.2 V.
Nominal voltage is stable across load/SOC (the basis nameplate capacity is quoted on), so this is the figure to sum for a slowly-varying "remaining energy" reading (#374). If the pack doesn't report num_cells, fall back to the measured pack voltage so it still contributes to a plant-level sum rather than silently dropping — the exact failure mode
318 is about. None if cap_remaining is None or no voltage basis is available.¶
from_register_cache(register_cache)
classmethod
¶
Construct a Battery from a RegisterCache.
Source code in givenergy_modbus/model/battery.py
116 117 118 119 | |
is_valid()
¶
Try to detect if a battery exists based on its attributes.
Source code in givenergy_modbus/model/battery.py
121 122 123 | |
BatteryMaintenance
¶
Bases: IntEnum
Battery maintenance mode.
Source code in givenergy_modbus/model/battery.py
199 200 201 202 203 204 205 206 207 208 209 | |
BatteryPauseMode
¶
Bases: IntEnum
Battery pause mode.
Source code in givenergy_modbus/model/battery.py
186 187 188 189 190 191 192 193 194 195 196 | |
BatteryRegisterGetter
¶
Bases: RegisterGetter
Structured format for all battery attributes.
Source code in givenergy_modbus/model/battery.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
ExportPriority
¶
Bases: IntEnum
Dispatch priority for surplus power on AC-coupled inverters.
HR(311) was identified as Export Priority via hass#52 wire captures. The integer↔label mapping
is tester-confirmed (hass#218, #303): cycling the GE portal and reading the round-tripped raw
value gave 0 = Load First, 1 = Battery First, 2 = Grid First. (The earlier
provisional mapping had all three rotated — it guessed a 2↔0 swap, but the field data showed a
full rotation.)
Source code in givenergy_modbus/model/battery.py
171 172 173 174 175 176 177 178 179 180 181 182 183 | |
State
¶
Bases: IntEnum
Battery charge/discharge state.
Source code in givenergy_modbus/model/battery.py
159 160 161 162 163 164 165 166 167 168 | |
RegisterCache
¶
Bases: defaultdict[Register, int]
Holds a cache of Registers populated after querying a device.
Source code in givenergy_modbus/model/register_cache.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
from_json(data)
classmethod
¶
Instantiate a RegisterCache from its JSON form.
Source code in givenergy_modbus/model/register_cache.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
json()
¶
Return JSON representation of the register cache, to mirror from_json().
.. warning::
This emits unredacted serial-number registers (and any other raw values).
For a share-safe export, redact first: cache.redact_serials().json().
Source code in givenergy_modbus/model/register_cache.py
90 91 92 93 94 95 96 97 | |
redact_serials()
¶
Return a copy of this cache with all known serial-number registers redacted.
Identifies every register group tagged as Converter.serial in the model
LUTs (plus BMU serial groups, which are decoded manually), decodes each fully-
present group, and date-redacts values that match a known GE serial pattern
(prefix + manufacture date kept, unit digits zeroed).
Fails open for HR/IR groups by necessity. Serial groups are applied without
device-type context and overlap: the BMU serial groups (e.g. IR(114-118)) are
real serials only on HV BMU stacks, but on an LV battery those addresses hold the
battery serial's last register (IR114) and ordinary data (IR115 = usb_device_inserted).
With no way to tell a non-GE serial from non-serial data, anything that doesn't
match a serial pattern is left unchanged — blanking it would destroy legitimate
data and corrupt overlapping serials. The share-safe-export guarantee (#212/#214)
is enforced fail-closed where it is unambiguous: the inverter/dongle header serials
(:meth:Plant.redact) and the meter product identifier (MR, a distinct register
namespace, blanked below).
Produces the same AAYYWWA000-style placeholders as :class:FrameRedactor,
so a redacted export is indistinguishable from a redacted capture.
Source code in givenergy_modbus/model/register_cache.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
to_datetime(y, m, d, h, min, s)
¶
Combine 6 registers into a datetime, with safe defaults for zeroes.
Source code in givenergy_modbus/model/register_cache.py
172 173 174 | |
to_duint8(*registers)
¶
Split registers into two unsigned 8-bit integers each.
Source code in givenergy_modbus/model/register_cache.py
164 165 166 | |
to_hex_string(*registers)
¶
Render a register as a 2-byte hexadecimal value.
Source code in givenergy_modbus/model/register_cache.py
154 155 156 157 158 159 160 161 162 | |
to_string(*registers)
¶
Combine registers into an ASCII string.
Source code in givenergy_modbus/model/register_cache.py
149 150 151 152 | |
to_timeslot(start, end)
¶
Combine two registers into a time slot, or None if either is unset.
Mirrors Converter.timeslot: a missing/None endpoint, or the raw value 60 (a hardware sentinel for an unset slot — the portal shows '--:--'), means "unset". Both would otherwise raise ValueError in TimeSlot.from_repr.
Source code in givenergy_modbus/model/register_cache.py
228 229 230 231 232 233 234 235 236 237 238 239 240 | |
to_uint32(high_register, low_register)
¶
Combine two registers into an unsigned 32-bit integer.
Source code in givenergy_modbus/model/register_cache.py
168 169 170 | |
parse_compact(text)
¶
Parse a compact probe-dump back into device caches (inverse of :func:to_compact).
Lenient and order-agnostic — the input is human-pasted diagnostic text. Accepts the
device-inline grammar emitted by :func:to_compact and (transitionally) the legacy
header format. Hex reflowed across lines by copy-paste is reassembled; a row that still
doesn't reach its declared length is skipped without aborting the rest. # comments
(provenance), Probing … status, .. timed-out ranges and blank lines are ignored.
Source code in givenergy_modbus/model/register_cache.py
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 354 355 356 357 358 359 360 361 362 | |
to_compact(caches)
¶
Serialise device register caches to the compact hex probe-dump format.
Peer to :meth:RegisterCache.json — a pure str projection with no file I/O. Each
row is self-describing::
0x32:HR(0,60) 0000000500ff…
0x<dev> is the device address, HR/IR/MR the bank, (<base>,<count>) the
range, then count × 4 lowercase hex chars (one 16-bit register per 4). Blocks are split
on the 60-register grid GivEnergy probes read on, so whole-block caches round-trip as clean,
non-overlapping rows. Rows are emitted in (device, bank, base) order for stable output.
Provenance (host:port) is the caller's to add as an ignored # comment.
Source code in givenergy_modbus/model/register_cache.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
Data model.
DefaultUnknownIntEnum
¶
Bases: IntEnum
Enum that returns unknown instead of blowing up.
Source code in givenergy_modbus/model/__init__.py
24 25 26 27 28 29 | |
GivEnergyBaseModel
¶
Bases: BaseModel
Structured format for all other attributes.
Source code in givenergy_modbus/model/__init__.py
13 14 15 16 17 18 19 20 21 | |
from_registers(register_cache)
classmethod
¶
Constructor parsing registers directly.
Source code in givenergy_modbus/model/__init__.py
18 19 20 21 | |
TimeSlot
¶
Represents a time slot with a start and end time.
Source code in givenergy_modbus/model/__init__.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
__get_pydantic_core_schema__(source_type, handler)
classmethod
¶
Keep TimeSlot instances as-is in model_dump(mode='python').
Source code in givenergy_modbus/model/__init__.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
from_components(start_hour, start_minute, end_hour, end_minute)
classmethod
¶
Shorthand for the individual datetime.time constructors.
Source code in givenergy_modbus/model/__init__.py
63 64 65 66 | |
from_repr(start, end)
classmethod
¶
Converts from human-readable/ASCII representation: '0034' -> 00:34.
Source code in givenergy_modbus/model/__init__.py
68 69 70 71 72 73 74 75 76 77 78 79 | |
PDU¶
Package for the tree of PDU messages.
BasePDU
¶
Bases: ABC
Base of the PDU Message network_timeout_handler class tree.
The Protocol Data Unit (PDU) defines the basic unit of message exchange for Modbus. It is routed to devices with specific addresses, and targets specific operations through function codes. This tree defines the hierarchy of functions, along with the attributes they specify and how they are encoded.
The tree branches at the top based on the directionality of the messages – either client-focused (messages a client should expect to receive and send) or server-focused (less important for this library, but messages that a server would emit and expect to receive). It is mirrored in that a Request message from a client would have a matching Response message the server should reply with.
The PDU classes are also codecs – they know how to convert between binary network frames and instantiated objects that can be manipulated programmatically.
Source code in givenergy_modbus/pdu/base.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
decode_bytes(data)
classmethod
¶
Decode raw byte frame to populated PDU instance.
Source code in givenergy_modbus/pdu/base.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
encode()
¶
Encode PDU message from instance attributes.
Source code in givenergy_modbus/pdu/base.py
39 40 41 42 43 44 45 46 47 48 49 | |
ensure_valid_state()
¶
Sanity check our internal state.
Source code in givenergy_modbus/pdu/base.py
111 112 113 | |
has_same_shape(o)
¶
Calculates whether a given message has the "same shape".
Messages are similarly shaped when they match message type (response, error state), location (device address, register type, register indexes) etc. but not data / register values.
This is not an identity check but could be used both for creating template expected responses from outgoing requests (to facilitate tracking future responses), but also allows incoming messages to be hashed consistently to avoid (e.g.) multiple messages of the same shape getting enqueued unnecessarily – the theory being that newer messages being enqueued might as well replace older ones of the same shape.
Source code in givenergy_modbus/pdu/base.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
shape_hash()
¶
Calculates the "shape hash" for a given message.
Source code in givenergy_modbus/pdu/base.py
130 131 132 | |
ClientIncomingMessage
¶
Bases: BasePDU, ABC
Root of the hierarchy for PDUs clients are expected to receive and handle.
Source code in givenergy_modbus/pdu/base.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
expected_response()
¶
Create a template of a correctly shaped Response expected for this Request.
Source code in givenergy_modbus/pdu/base.py
157 158 159 | |
ClientOutgoingMessage
¶
Bases: BasePDU, ABC
Root of the hierarchy for PDUs clients are expected to send to servers.
Source code in givenergy_modbus/pdu/base.py
162 163 164 165 166 167 168 169 170 171 172 173 174 | |
HeartbeatMessage
¶
Bases: BasePDU, ABC
Root of the hierarchy for 1/Heartbeat function PDUs.
Source code in givenergy_modbus/pdu/heartbeat.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
ensure_valid_state()
¶
Sanity check our internal state.
Source code in givenergy_modbus/pdu/heartbeat.py
41 42 | |
HeartbeatRequest
¶
Bases: HeartbeatMessage, ClientIncomingMessage, ABC
PDU sent by remote server to check liveness of client.
Source code in givenergy_modbus/pdu/heartbeat.py
52 53 54 55 56 57 | |
expected_response()
¶
Create an appropriate response for an incoming HeartbeatRequest.
Source code in givenergy_modbus/pdu/heartbeat.py
55 56 57 | |
HeartbeatResponse
¶
Bases: HeartbeatMessage, ClientOutgoingMessage, ABC
PDU returned by client (within 5s) to confirm liveness.
Source code in givenergy_modbus/pdu/heartbeat.py
60 61 62 63 64 65 66 67 68 69 70 71 | |
decode(data)
¶
Decode response PDU message and populate instance attributes.
Source code in givenergy_modbus/pdu/heartbeat.py
63 64 65 66 67 68 | |
expected_response()
¶
No replies expected for HeartbeatResponse.
Source code in givenergy_modbus/pdu/heartbeat.py
70 71 | |
LanConfigBroadcast
¶
Bases: ClientIncomingMessage
Dongle LAN-configuration broadcast (function 0x02 / CSV body).
Some WO-prefix inverter dongles periodically broadcast their network configuration as a function-code 2 frame whose body is:
adapter_serial[10] 6_zeros[6] null[1] ,<ip>,<netmask>,<gateway>\r\n\r\n check[2]
The standard transparent decoder reads the null byte as transparent_function_code (0x30 / '0') and bails to InvalidFrame. This class intercepts those frames at decode time before the transparent path is attempted (discriminator: remaining_payload[6]0 and remaining_payload[7]',').
Refs: #100 (original discovery), #158 (B-3 redactor).
Source code in givenergy_modbus/pdu/lan_config.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
decode_main_function(decoder, **attrs)
classmethod
¶
Called by TransparentMessage.decode_main_function after reading the serial.
attrs already contains data_adapter_serial_number. Consume the 7 padding bytes
then parse the CSV from the remaining payload.
Source code in givenergy_modbus/pdu/lan_config.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
encode()
¶
Re-encode to wire bytes; length-preserving. CRC is not recomputed.
Source code in givenergy_modbus/pdu/lan_config.py
97 98 99 100 101 102 103 104 105 106 107 | |
ensure_valid_state()
¶
No state validation required for LAN-config broadcast frames.
Source code in givenergy_modbus/pdu/lan_config.py
109 110 | |
expected_response()
¶
No response expected for LAN-config broadcasts.
Source code in givenergy_modbus/pdu/lan_config.py
112 113 114 | |
is_lan_config(remaining_after_serial)
classmethod
¶
Return True if the remaining decoder bytes look like a LAN config broadcast.
Source code in givenergy_modbus/pdu/lan_config.py
49 50 51 52 53 54 55 56 57 58 59 60 | |
lookup_main_function_decoder(function_code)
classmethod
¶
Not used — LanConfigBroadcast is decoded directly, not via lookup.
Source code in givenergy_modbus/pdu/lan_config.py
119 120 121 122 | |
redact()
¶
Return a new instance with the adapter serial and all IP fields zeroed.
The trailing 2-byte check field is carried through verbatim. Its
derivation for this non-standard frame type is unknown — verified to not
follow the CRC16/Modbus(payload[18:], byte-swapped) scheme used by
all other GivEnergy frames (no candidate span produces a match). This is
consistent with the fact that real captures arrive with the IPs already
zeroed and a check value computed by the dongle over those zeroed bytes;
redaction of a live frame would leave the check inconsistent with the new CSV
bytes, but without understanding the formula it cannot be corrected. A comment
in the test documents the implication.
Source code in givenergy_modbus/pdu/lan_config.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
NullResponse
¶
Bases: TransparentResponse
Concrete PDU implementation for handling function #0/Null Response messages.
This seems to be a quirk of the GivEnergy implementation – from time to time these responses will be sent unprompted by the remote device and this just handles it gracefully and allows further debugging. The function data payload seems to be invariably just a series of nulls.
Source code in givenergy_modbus/pdu/null.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
ensure_valid_state()
¶
Sanity check our internal state.
Source code in givenergy_modbus/pdu/null.py
46 47 48 49 50 51 52 53 54 | |
expected_response()
¶
No response expected.
Source code in givenergy_modbus/pdu/null.py
43 44 | |
ReadHoldingRegisters
¶
Bases: ReadRegistersMessage, ABC
Request & Response PDUs for function #3/Read Holding Registers.
Source code in givenergy_modbus/pdu/read_registers.py
194 195 196 197 | |
ReadHoldingRegistersRequest
¶
Bases: ReadHoldingRegisters, ReadRegistersRequest
Concrete PDU implementation for handling function #3/Read Holding Registers request messages.
Source code in givenergy_modbus/pdu/read_registers.py
200 201 202 203 204 205 206 | |
ReadHoldingRegistersResponse
¶
Bases: ReadHoldingRegisters, ReadRegistersResponse
Concrete PDU implementation for handling function #3/Read Holding Registers response messages.
Source code in givenergy_modbus/pdu/read_registers.py
209 210 211 212 213 | |
ReadInputRegisters
¶
Bases: ReadRegistersMessage, ABC
Request & Response PDUs for function #4/Read Input Registers.
Source code in givenergy_modbus/pdu/read_registers.py
216 217 218 219 | |
ReadInputRegistersRequest
¶
Bases: ReadInputRegisters, ReadRegistersRequest
Concrete PDU implementation for handling function #4/Read Input Registers request messages.
Source code in givenergy_modbus/pdu/read_registers.py
222 223 224 225 226 227 228 | |
ReadInputRegistersResponse
¶
Bases: ReadInputRegisters, ReadRegistersResponse
Concrete PDU implementation for handling function #4/Read Input Registers response messages.
Source code in givenergy_modbus/pdu/read_registers.py
231 232 233 234 235 | |
ReadMeterProductRegisters
¶
Bases: ReadRegistersMessage, ABC
Request & Response PDUs for function #0x16/Read Meter Product Registers.
Source code in givenergy_modbus/pdu/read_registers.py
238 239 240 241 | |
ReadMeterProductRegistersRequest
¶
Bases: ReadMeterProductRegisters, ReadRegistersRequest
Concrete PDU implementation for handling function #0x16/Read Meter Product Registers request messages.
Source code in givenergy_modbus/pdu/read_registers.py
244 245 246 247 248 249 250 | |
ReadMeterProductRegistersResponse
¶
Bases: ReadMeterProductRegisters, ReadRegistersResponse
Concrete PDU implementation for handling function #0x16/Read Meter Product Registers response messages.
Source code in givenergy_modbus/pdu/read_registers.py
257 258 259 260 261 | |
ReadRegistersMessage
¶
Bases: TransparentMessage, ABC
Mixin for commands that specify base register and register count semantics.
Source code in givenergy_modbus/pdu/read_registers.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
ReadRegistersRequest
¶
Bases: ReadRegistersMessage, TransparentRequest, ABC
Handles all messages that request a range of registers.
Source code in givenergy_modbus/pdu/read_registers.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
ensure_valid_state()
¶
Sanity check our internal state.
Source code in givenergy_modbus/pdu/read_registers.py
61 62 63 64 65 66 67 68 69 70 | |
ReadRegistersResponse
¶
Bases: ReadRegistersMessage, TransparentResponse, ABC
Handles all messages that respond with a range of registers.
Source code in givenergy_modbus/pdu/read_registers.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
ensure_valid_state()
¶
Sanity check our internal state.
Source code in givenergy_modbus/pdu/read_registers.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
is_suspicious()
¶
Try to identify known-bad data in register lookup calls and prevent them from entering the dispatching.
Source code in givenergy_modbus/pdu/read_registers.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
to_dict()
¶
Return the registers as a dict of register_index:value. Accounts for base_register offsets.
Source code in givenergy_modbus/pdu/read_registers.py
159 160 161 | |
TransparentMessage
¶
Bases: BasePDU, ABC
Root of the hierarchy for 2/Transparent PDUs.
Source code in givenergy_modbus/pdu/transparent.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
TransparentRequest
¶
Bases: TransparentMessage, ClientOutgoingMessage, ABC
Root of the hierarchy for Transparent Request PDUs.
Source code in givenergy_modbus/pdu/transparent.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
expected_response()
¶
Create a template of a correctly shaped Response expected for this Request.
Source code in givenergy_modbus/pdu/transparent.py
191 192 193 | |
TransparentResponse
¶
Bases: TransparentMessage, ClientIncomingMessage, ABC
Root of the hierarchy for Transparent Response PDUs.
Source code in givenergy_modbus/pdu/transparent.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
WriteHoldingRegister
¶
Bases: TransparentMessage, ABC
Request & Response PDUs for function #6/Write Holding Register.
Source code in givenergy_modbus/pdu/write_registers.py
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | |
ensure_valid_state()
¶
Sanity check our internal state.
Source code in givenergy_modbus/pdu/write_registers.py
397 398 399 400 401 402 403 404 405 | |
WriteHoldingRegisterRequest
¶
Bases: WriteHoldingRegister, TransparentRequest
Concrete PDU implementation for handling function #6/Write Holding Register request messages.
Source code in givenergy_modbus/pdu/write_registers.py
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | |
ensure_valid_state()
¶
Sanity check our internal state.
Source code in givenergy_modbus/pdu/write_registers.py
422 423 424 425 426 427 428 429 | |
WriteHoldingRegisterResponse
¶
Bases: WriteHoldingRegister, TransparentResponse
Concrete PDU implementation for handling function #6/Write Holding Register response messages.
Source code in givenergy_modbus/pdu/write_registers.py
437 438 439 440 441 442 443 444 445 | |
ensure_valid_state()
¶
Sanity check our internal state.
Source code in givenergy_modbus/pdu/write_registers.py
440 441 442 443 444 445 | |
Codec¶
PayloadDecoder
¶
Decoder to unpack a raw binary payload into sequential typed fields.
Source code in givenergy_modbus/codec.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
decoded_bytes
property
¶
Return the number of bytes of the payload that have been decoded.
decoding_complete
property
¶
Returns whether the payload has been completely decoded.
payload_size
property
¶
Return the number of bytes the payload consists of.
remaining_bytes
property
¶
Return the number of bytes of the payload that have been decoded.
remaining_payload
property
¶
Return the unprocessed / remaining tail of the payload.
decode_16bit_uint()
¶
Decodes a 16-bit unsigned int from the buffer.
Source code in givenergy_modbus/codec.py
28 29 30 31 32 | |
decode_32bit_uint()
¶
Decodes a 32-bit unsigned int from the buffer.
Source code in givenergy_modbus/codec.py
34 35 36 37 38 | |
decode_64bit_uint()
¶
Decodes a 64-bit unsigned int from the buffer.
Source code in givenergy_modbus/codec.py
40 41 42 43 44 | |
decode_8bit_uint()
¶
Decodes an 8-bit unsigned int from the buffer.
Source code in givenergy_modbus/codec.py
22 23 24 25 26 | |
decode_string(size=1)
¶
Decodes a string from the buffer.
Source code in givenergy_modbus/codec.py
46 47 48 49 50 51 52 53 | |
PayloadEncoder
¶
Encode sequential typed fields into a raw binary payload.
Source code in givenergy_modbus/codec.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
crc
property
¶
Calculate a Modbus-compatible CRC based on the buffer contents.
payload
property
¶
Return the payload buffer.
add_16bit_uint(value)
¶
Adds a 16-bit unsigned int to the buffer.
Source code in givenergy_modbus/codec.py
109 110 111 112 | |
add_32bit_uint(value)
¶
Adds a 32-bit unsigned int to the buffer.
Source code in givenergy_modbus/codec.py
114 115 116 117 | |
add_64bit_uint(value)
¶
Adds a 64-bit unsigned int to the buffer.
Source code in givenergy_modbus/codec.py
119 120 121 122 | |
add_8bit_uint(value)
¶
Adds an 8-bit unsigned int to the buffer.
Source code in givenergy_modbus/codec.py
104 105 106 107 | |
add_string(value, length)
¶
Adds a string to the buffer.
Source code in givenergy_modbus/codec.py
124 125 126 127 128 | |
reset()
¶
Reset the payload buffer.
Source code in givenergy_modbus/codec.py
90 91 92 | |
Exceptions¶
CommunicationError
¶
Bases: ExceptionBase
Exception to indicate a communication error.
Source code in givenergy_modbus/exceptions.py
37 38 | |
ConnectionLost
¶
Bases: CommunicationError, TimeoutError
The TCP connection dropped mid-operation (peer disconnect, half-open stall).
Deliberately inherits BOTH CommunicationError and TimeoutError (#356): the
dual base is a compatibility contract, not an accident. Consumers that catch
bare TimeoutError (the historical error type for a dead connection) see
no behaviour change; consumers may catch ConnectionLost explicitly —
ordered before TimeoutError — to opt into immediate-reconnect policy.
Do not "simplify" to a single base.
Source code in givenergy_modbus/exceptions.py
41 42 43 44 45 46 47 48 49 50 | |
ExceptionBase
¶
Bases: Exception
Base exception.
Source code in givenergy_modbus/exceptions.py
9 10 11 12 13 14 15 16 | |
InvalidFrame
¶
Bases: ExceptionBase
Thrown during framing when a message cannot be extracted from a frame buffer.
Source code in givenergy_modbus/exceptions.py
27 28 29 30 31 32 33 34 | |
InvalidPduState
¶
Bases: ExceptionBase
Thrown during PDU self-validation.
Source code in givenergy_modbus/exceptions.py
19 20 21 22 23 24 | |
PlantNotDetected
¶
Bases: CommunicationError
Raised when a capability-aware poll is attempted before detect() has run.
load_config() / refresh() route by plant.capabilities (device kind,
inverter address, slot layout). With no capabilities there is no safe default —
guessing an inverter address (historically 0x32) silently times out on models
that answer elsewhere (e.g. an All-in-One at 0x11). Rather than guess, the poll
refuses: call detect() once first, or restore a persisted PlantCapabilities
onto client.plant.capabilities before polling.
Source code in givenergy_modbus/exceptions.py
53 54 55 56 57 58 59 60 61 62 | |
PlantTopologyMismatch
¶
Bases: CommunicationError
Raised when detect(prior=...) finds the plant doesn't match the supplied prior.
Carries both prior (what the caller asserted) and actual (a PlantCapabilities
reflecting what confirmed on this run). On raise, the Client's plant.capabilities
is left as None — callers that wish to accept the new topology must explicitly
assign client.plant.capabilities = exc.actual.
Caller policy decides whether to retry (e.g. with longer timeouts), fall back to detect() without prior, or surface the change to the user.
Source code in givenergy_modbus/exceptions.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
ReadFailure
¶
Bases: NamedTuple
Identifies a single register read that failed (after retries) during a poll.
Structured so a consumer can reason about which device and bank dropped (e.g. "battery 0x34 is offline") without parsing log lines.
Source code in givenergy_modbus/exceptions.py
88 89 90 91 92 93 94 95 96 97 98 | |
RefreshError
¶
Bases: CommunicationError
Base for a refresh()/load_config() that did not fully succeed.
Carries the structured set of reads that failed (failures) plus the raw
underlying exceptions grouped as an ExceptionGroup (cause) for
tracebacks / drill-down.
Source code in givenergy_modbus/exceptions.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
RefreshFailed
¶
Bases: RefreshError
Every register read in the poll failed — the link is effectively dead.
No usable data came back, so (unlike RefreshPartiallySucceeded) there is
no partial plant to hand over; callers should treat the device as
unavailable.
Source code in givenergy_modbus/exceptions.py
136 137 138 139 140 141 142 | |
RefreshPartiallySucceeded
¶
Bases: RefreshError
Some — but not all — register reads in a poll failed.
The data that was collected is attached as plant. This exception is
the consumer's one opportunity to do something useful with that partial
data — cache it, surface it, count the gap — before deciding how to treat
the missing reads. Catching it and carrying on (even ignoring it) is a
legitimate choice; the point is that it's the consumer's choice, made
here, rather than something the library silently decided for them.
Source code in givenergy_modbus/exceptions.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |