Merge pull request #67 from s-allius/s-allius/issue65

S allius/issue65
This commit is contained in:
Stefan Allius
2024-05-07 22:31:40 +02:00
committed by GitHub
20 changed files with 993 additions and 360 deletions

View File

@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
- add timeout monitoring for received packets
- parse Modbus values and store them in the database
- add cron task to request the output power every minute
- GEN3PLUS: add MQTT topics to send AT commands to the inverter
- add MQTT topics to send Modbus commands to the inverter
- convert data collect interval to minutes - convert data collect interval to minutes
- add postfix for rc and dev versions to the version number - add postfix for rc and dev versions to the version number
- change logging level to DEBUG for some logs - change logging level to DEBUG for some logs

View File

@@ -39,12 +39,15 @@ If you use a Pi-hole, you can also store the host entry in the Pi-hole.
## Features ## Features
- supports TSUN GEN3 PLUS inverters: TSOL-MS2000, MS1800 and MS1600 - Supports TSUN GEN3 PLUS inverters: TSOL-MS2000, MS1800 and MS1600
- supports TSUN GEN3 inverters: TSOL-MS800, MS700, MS600, MS400, MS350 and MS300 - Supports TSUN GEN3 inverters: TSOL-MS800, MS700, MS600, MS400, MS350 and MS300
- `MQTT` support - `MQTT` support
- `Home-Assistant` auto-discovery support - `Home-Assistant` auto-discovery support
- `MODBUS` support via MQTT topics
- `AT Command` support via MQTT topics (GEN3PLUS only)
- Faster DataUp interval sends measurement data to the MQTT broker every minute
- Self-sufficient island operation without internet - Self-sufficient island operation without internet
- runs in a non-root Docker Container - Runs in a non-root Docker Container
## Home Assistant Screenshots ## Home Assistant Screenshots

View File

@@ -4,340 +4,372 @@
<!-- Generated by graphviz version 2.40.1 (20161225.0304) <!-- Generated by graphviz version 2.40.1 (20161225.0304)
--> -->
<!-- Title: G Pages: 1 --> <!-- Title: G Pages: 1 -->
<svg width="511pt" height="1204pt" <svg width="673pt" height="1216pt"
viewBox="0.00 0.00 511.39 1204.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> viewBox="0.00 0.00 673.35 1216.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 1200)"> <g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 1212)">
<title>G</title> <title>G</title>
<polygon fill="#ffffff" stroke="transparent" points="-4,4 -4,-1200 507.3928,-1200 507.3928,4 -4,4"/> <polygon fill="#ffffff" stroke="transparent" points="-4,4 -4,-1212 669.348,-1212 669.348,4 -4,4"/>
<!-- A0 --> <!-- A0 -->
<g id="node1" class="node"> <g id="node1" class="node">
<title>A0</title> <title>A0</title>
<polygon fill="#fff8dc" stroke="#000000" points="148.1964,-1100 39.8036,-1100 39.8036,-1064 154.1964,-1064 154.1964,-1094 148.1964,-1100"/> <polygon fill="#fff8dc" stroke="#000000" points="108.5444,-1112 .1516,-1112 .1516,-1076 114.5444,-1076 114.5444,-1106 108.5444,-1112"/>
<polyline fill="none" stroke="#000000" points="148.1964,-1100 148.1964,-1094 "/> <polyline fill="none" stroke="#000000" points="108.5444,-1112 108.5444,-1106 "/>
<polyline fill="none" stroke="#000000" points="154.1964,-1094 148.1964,-1094 "/> <polyline fill="none" stroke="#000000" points="114.5444,-1106 108.5444,-1106 "/>
<text text-anchor="middle" x="97" y="-1085" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">You can stick notes</text> <text text-anchor="middle" x="57.348" y="-1097" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">You can stick notes</text>
<text text-anchor="middle" x="97" y="-1073" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">on diagrams too!</text> <text text-anchor="middle" x="57.348" y="-1085" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">on diagrams too!</text>
</g> </g>
<!-- A1 --> <!-- A1 -->
<g id="node2" class="node"> <g id="node2" class="node">
<title>A1</title> <title>A1</title>
<polygon fill="none" stroke="#000000" points="95.6817,-804 26.3183,-804 26.3183,-768 95.6817,-768 95.6817,-804"/> <polygon fill="none" stroke="#000000" points="639.0297,-816 569.6663,-816 569.6663,-780 639.0297,-780 639.0297,-816"/>
<text text-anchor="middle" x="61" y="-783" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">Singleton</text> <text text-anchor="middle" x="604.348" y="-795" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">Singleton</text>
</g> </g>
<!-- A2 --> <!-- A2 -->
<g id="node3" class="node"> <g id="node3" class="node">
<title>A2</title> <title>A2</title>
<polygon fill="none" stroke="#000000" points="0,-518 0,-550 122,-550 122,-518 0,-518"/> <polygon fill="none" stroke="#000000" points="543.348,-524 543.348,-556 665.348,-556 665.348,-524 543.348,-524"/>
<text text-anchor="start" x="51.277" y="-531" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">Mqtt</text> <text text-anchor="start" x="594.625" y="-537" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">Mqtt</text>
<polygon fill="none" stroke="#000000" points="0,-462 0,-518 122,-518 122,-462 0,-462"/> <polygon fill="none" stroke="#000000" points="543.348,-468 543.348,-524 665.348,-524 665.348,-468 543.348,-468"/>
<text text-anchor="start" x="18.4875" y="-499" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;static&gt;ha_restarts</text> <text text-anchor="start" x="561.8355" y="-505" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;static&gt;ha_restarts</text>
<text text-anchor="start" x="26.2665" y="-487" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;static&gt;__client</text> <text text-anchor="start" x="569.6145" y="-493" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;static&gt;__client</text>
<text text-anchor="start" x="9.8735" y="-475" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;static&gt;__cb_MqttIsUp</text> <text text-anchor="start" x="553.2215" y="-481" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;static&gt;__cb_MqttIsUp</text>
<polygon fill="none" stroke="#000000" points="0,-418 0,-462 122,-462 122,-418 0,-418"/> <polygon fill="none" stroke="#000000" points="543.348,-424 543.348,-468 665.348,-468 665.348,-424 543.348,-424"/>
<text text-anchor="start" x="22.936" y="-443" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;publish()</text> <text text-anchor="start" x="566.284" y="-449" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;publish()</text>
<text text-anchor="start" x="27.1045" y="-431" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;close()</text> <text text-anchor="start" x="570.4525" y="-437" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;close()</text>
</g> </g>
<!-- A1&#45;&gt;A2 --> <!-- A1&#45;&gt;A2 -->
<g id="edge1" class="edge"> <g id="edge1" class="edge">
<title>A1&#45;&gt;A2</title> <title>A1&#45;&gt;A2</title>
<path fill="none" stroke="#000000" d="M61,-757.4632C61,-710.3291 61,-615.0013 61,-550.3153"/> <path fill="none" stroke="#000000" d="M604.348,-769.6429C604.348,-721.5141 604.348,-622.6159 604.348,-556.2865"/>
<polygon fill="none" stroke="#000000" points="57.5001,-757.5631 61,-767.5632 64.5001,-757.5632 57.5001,-757.5631"/> <polygon fill="none" stroke="#000000" points="600.8481,-769.6555 604.348,-779.6556 607.8481,-769.6556 600.8481,-769.6555"/>
</g>
<!-- A10 -->
<g id="node11" class="node">
<title>A10</title>
<polygon fill="none" stroke="#000000" points="7,-282 7,-314 115,-314 115,-282 7,-282"/>
<text text-anchor="start" x="44.0535" y="-295" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">Inverter</text>
<polygon fill="none" stroke="#000000" points="7,-190 7,-282 115,-282 115,-190 7,-190"/>
<text text-anchor="start" x="37.104" y="-263" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">cls.db_stat</text>
<text text-anchor="start" x="30.4405" y="-251" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">cls.entity_prfx</text>
<text text-anchor="start" x="21.2755" y="-239" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">cls.discovery_prfx</text>
<text text-anchor="start" x="20.7115" y="-227" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">cls.proxy_node_id</text>
<text text-anchor="start" x="16.8225" y="-215" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">cls.proxy_unique_id</text>
<text text-anchor="start" x="32.6655" y="-203" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">cls.mqtt:Mqtt</text>
<polygon fill="none" stroke="#000000" points="7,-170 7,-190 115,-190 115,-170 7,-170"/>
</g>
<!-- A2&#45;&gt;A10 -->
<g id="edge11" class="edge">
<title>A2&#45;&gt;A10</title>
<path fill="none" stroke="#000000" d="M61,-417.8724C61,-385.8251 61,-347.2624 61,-314.4235"/>
</g>
<!-- A3 -->
<g id="node4" class="node">
<title>A3</title>
<polygon fill="none" stroke="#000000" points="173,-1092 173,-1124 244,-1124 244,-1092 173,-1092"/>
<text text-anchor="start" x="182.945" y="-1105" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">IterRegistry</text>
<polygon fill="none" stroke="#000000" points="173,-1072 173,-1092 244,-1092 244,-1072 173,-1072"/>
<polygon fill="none" stroke="#000000" points="173,-1040 173,-1072 244,-1072 244,-1040 173,-1040"/>
<text text-anchor="start" x="190.439" y="-1053" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">__iter__</text>
</g>
<!-- A4 -->
<g id="node5" class="node">
<title>A4</title>
<polygon fill="none" stroke="#000000" points="141,-886 141,-918 275,-918 275,-886 141,-886"/>
<text text-anchor="start" x="187.7175" y="-899" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">Message</text>
<polygon fill="none" stroke="#000000" points="141,-722 141,-886 275,-886 275,-722 141,-722"/>
<text text-anchor="start" x="171.3265" y="-867" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">server_side:bool</text>
<text text-anchor="start" x="168.543" y="-855" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">header_valid:bool</text>
<text text-anchor="start" x="161.314" y="-843" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">header_len:unsigned</text>
<text text-anchor="start" x="167.148" y="-831" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">data_len:unsigned</text>
<text text-anchor="start" x="186.3245" y="-819" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">unique_id</text>
<text text-anchor="start" x="190.2135" y="-807" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">node_id</text>
<text text-anchor="start" x="187.1585" y="-795" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">sug_area</text>
<text text-anchor="start" x="157.989" y="-783" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">_recv_buffer:bytearray</text>
<text text-anchor="start" x="156.5945" y="-771" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">_send_buffer:bytearray</text>
<text text-anchor="start" x="150.7665" y="-759" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">_forward_buffer:bytearray</text>
<text text-anchor="start" x="190.2135" y="-747" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">db:Infos</text>
<text text-anchor="start" x="178.826" y="-735" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">new_data:list</text>
<polygon fill="none" stroke="#000000" points="141,-654 141,-722 275,-722 275,-654 141,-654"/>
<text text-anchor="start" x="157.7095" y="-703" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">_read():void&lt;abstract&gt;</text>
<text text-anchor="start" x="182.4445" y="-691" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">close():void</text>
<text text-anchor="start" x="168.2725" y="-679" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">inc_counter():void</text>
<text text-anchor="start" x="166.6025" y="-667" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">dec_counter():void</text>
</g>
<!-- A3&#45;&gt;A4 -->
<g id="edge2" class="edge">
<title>A3&#45;&gt;A4</title>
<path fill="none" stroke="#000000" d="M208,-1029.7414C208,-998.6043 208,-957.5621 208,-918.0536"/>
<polygon fill="none" stroke="#000000" points="204.5001,-1029.9047 208,-1039.9048 211.5001,-1029.9048 204.5001,-1029.9047"/>
</g>
<!-- A5 -->
<g id="node6" class="node">
<title>A5</title>
<polygon fill="none" stroke="#000000" points="145,-566 145,-598 259,-598 259,-566 145,-566"/>
<text text-anchor="start" x="188.108" y="-579" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">Talent</text>
<polygon fill="none" stroke="#000000" points="145,-486 145,-566 259,-566 259,-486 145,-486"/>
<text text-anchor="start" x="154.763" y="-547" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">await_conn_resp_cnt</text>
<text text-anchor="start" x="189.7775" y="-535" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">id_str</text>
<text text-anchor="start" x="170.6" y="-523" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">contact_name</text>
<text text-anchor="start" x="173.94" y="-511" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">contact_mail</text>
<text text-anchor="start" x="188.112" y="-499" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">switch</text>
<polygon fill="none" stroke="#000000" points="145,-370 145,-486 259,-486 259,-370 145,-370"/>
<text text-anchor="start" x="159.4925" y="-467" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">msg_contact_info()</text>
<text text-anchor="start" x="161.4325" y="-455" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">msg_ota_update()</text>
<text text-anchor="start" x="167.2765" y="-443" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">msg_get_time()</text>
<text text-anchor="start" x="155.3285" y="-431" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">msg_collector_data()</text>
<text text-anchor="start" x="157.2735" y="-419" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">msg_inverter_data()</text>
<text text-anchor="start" x="166.4405" y="-407" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">msg_unknown()</text>
<text text-anchor="start" x="187.0025" y="-383" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">close()</text>
</g>
<!-- A4&#45;&gt;A5 -->
<g id="edge3" class="edge">
<title>A4&#45;&gt;A5</title>
<path fill="none" stroke="#000000" d="M205.1775,-643.9363C204.8732,-628.6188 204.5665,-613.1783 204.2698,-598.2481"/>
<polygon fill="none" stroke="#000000" points="201.679,-644.0493 205.377,-653.9777 208.6776,-643.9102 201.679,-644.0493"/>
</g>
<!-- A6 -->
<g id="node7" class="node">
<title>A6</title>
<polygon fill="none" stroke="#000000" points="412,-530 412,-562 503,-562 503,-530 412,-530"/>
<text text-anchor="start" x="429.995" y="-543" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">SolarmanV5</text>
<polygon fill="none" stroke="#000000" points="412,-462 412,-530 503,-530 503,-462 412,-462"/>
<text text-anchor="start" x="442.498" y="-511" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">control</text>
<text text-anchor="start" x="445.5575" y="-499" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">serial</text>
<text text-anchor="start" x="450.556" y="-487" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">snr</text>
<text text-anchor="start" x="443.612" y="-475" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">switch</text>
<polygon fill="none" stroke="#000000" points="412,-406 412,-462 503,-462 503,-406 412,-406"/>
<text text-anchor="start" x="421.9405" y="-443" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">msg_unknown()</text>
<text text-anchor="start" x="442.5025" y="-419" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">close()</text>
</g>
<!-- A4&#45;&gt;A6 -->
<g id="edge4" class="edge">
<title>A4&#45;&gt;A6</title>
<path fill="none" stroke="#000000" d="M281.898,-681.5056C290.821,-671.6784 300.2479,-662.304 310,-654 345.4324,-623.8293 370.2318,-638.0075 402,-604 413.2639,-591.9422 422.5424,-577.1747 430.0614,-562.1755"/>
<polygon fill="none" stroke="#000000" points="279.184,-679.2912 275.1758,-689.0986 284.4251,-683.9313 279.184,-679.2912"/>
</g>
<!-- A7 -->
<g id="node8" class="node">
<title>A7</title>
<polygon fill="none" stroke="#000000" points="133,-258 133,-290 283,-290 283,-258 133,-258"/>
<text text-anchor="start" x="176.0455" y="-271" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">ConnectionG3</text>
<polygon fill="none" stroke="#000000" points="133,-226 133,-258 283,-258 283,-226 133,-226"/>
<text text-anchor="start" x="142.987" y="-239" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">remoteStream:ConnectionG3</text>
<polygon fill="none" stroke="#000000" points="133,-194 133,-226 283,-226 283,-194 133,-194"/>
<text text-anchor="start" x="193.0025" y="-207" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">close()</text>
</g>
<!-- A5&#45;&gt;A7 -->
<g id="edge5" class="edge">
<title>A5&#45;&gt;A7</title>
<path fill="none" stroke="#000000" d="M205.0858,-359.5407C205.6971,-334.8843 206.3036,-310.4196 206.8038,-290.2462"/>
<polygon fill="none" stroke="#000000" points="201.5821,-359.6485 204.8331,-369.7323 208.58,-359.8221 201.5821,-359.6485"/>
</g>
<!-- A8 -->
<g id="node9" class="node">
<title>A8</title>
<polygon fill="none" stroke="#000000" points="319,-258 319,-290 475,-290 475,-258 319,-258"/>
<text text-anchor="start" x="361.711" y="-271" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">ConnectionG3P</text>
<polygon fill="none" stroke="#000000" points="319,-226 319,-258 475,-258 475,-226 319,-226"/>
<text text-anchor="start" x="328.6525" y="-239" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">remoteStream:ConnectionG3P</text>
<polygon fill="none" stroke="#000000" points="319,-194 319,-226 475,-226 475,-194 319,-194"/>
<text text-anchor="start" x="382.0025" y="-207" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">close()</text>
</g>
<!-- A6&#45;&gt;A8 -->
<g id="edge6" class="edge">
<title>A6&#45;&gt;A8</title>
<path fill="none" stroke="#000000" d="M435.1335,-395.8051C426.2731,-360.0682 416.3888,-320.2015 408.9039,-290.0125"/>
<polygon fill="none" stroke="#000000" points="431.7989,-396.8999 437.6026,-405.7637 438.5932,-395.2153 431.7989,-396.8999"/>
</g>
<!-- A7&#45;&gt;A7 -->
<g id="edge13" class="edge">
<title>A7&#45;&gt;A7</title>
<path fill="none" stroke="#000000" d="M283.1684,-272.6238C293.8394,-267.6708 301,-257.4629 301,-242 301,-231.1277 297.4599,-222.8533 291.6486,-217.1769"/>
<polygon fill="#000000" stroke="#000000" points="283.1684,-211.3762 293.9628,-213.3079 287.2953,-214.1991 291.4222,-217.0221 291.4222,-217.0221 291.4222,-217.0221 287.2953,-214.1991 288.8816,-220.7363 283.1684,-211.3762 283.1684,-211.3762"/>
<text text-anchor="middle" x="302.9014" y="-211.6335" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">0..1</text>
<text text-anchor="middle" x="295.2075" y="-253.6532" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">has</text>
</g> </g>
<!-- A11 --> <!-- A11 -->
<g id="node12" class="node"> <g id="node12" class="node">
<title>A11</title> <title>A11</title>
<polygon fill="none" stroke="#000000" points="73,-88 73,-120 195,-120 195,-88 73,-88"/> <polygon fill="none" stroke="#000000" points="550.348,-282 550.348,-314 658.348,-314 658.348,-282 550.348,-282"/>
<text text-anchor="start" x="110.3845" y="-101" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">InverterG3</text> <text text-anchor="start" x="587.4015" y="-295" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">Inverter</text>
<polygon fill="none" stroke="#000000" points="73,-56 73,-88 195,-88 195,-56 73,-56"/> <polygon fill="none" stroke="#000000" points="550.348,-190 550.348,-282 658.348,-282 658.348,-190 550.348,-190"/>
<text text-anchor="start" x="103.4355" y="-69" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">__ha_restarts</text> <text text-anchor="start" x="580.452" y="-263" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">cls.db_stat</text>
<polygon fill="none" stroke="#000000" points="73,0 73,-56 195,-56 195,0 73,0"/> <text text-anchor="start" x="573.7885" y="-251" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">cls.entity_prfx</text>
<text text-anchor="start" x="82.6035" y="-37" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">async_create_remote()</text> <text text-anchor="start" x="564.6235" y="-239" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">cls.discovery_prfx</text>
<text text-anchor="start" x="119.0025" y="-13" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">close()</text> <text text-anchor="start" x="564.0595" y="-227" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">cls.proxy_node_id</text>
<text text-anchor="start" x="560.1705" y="-215" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">cls.proxy_unique_id</text>
<text text-anchor="start" x="576.0135" y="-203" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">cls.mqtt:Mqtt</text>
<polygon fill="none" stroke="#000000" points="550.348,-170 550.348,-190 658.348,-190 658.348,-170 550.348,-170"/>
</g> </g>
<!-- A7&#45;&gt;A11 --> <!-- A2&#45;&gt;A11 -->
<g id="edge12" class="edge"> <g id="edge13" class="edge">
<title>A7&#45;&gt;A11</title> <title>A2&#45;&gt;A11</title>
<path fill="none" stroke="#000000" d="M184.5103,-184.2281C176.2169,-163.8307 166.8737,-140.8515 158.4988,-120.2539"/> <path fill="none" stroke="#000000" d="M604.348,-423.8663C604.348,-390.0029 604.348,-348.7174 604.348,-314.0468"/>
<polygon fill="none" stroke="#000000" points="181.3548,-185.7599 188.3636,-193.7052 187.8393,-183.1233 181.3548,-185.7599"/>
</g> </g>
<!-- A8&#45;&gt;A8 --> <!-- A3 -->
<g id="edge15" class="edge"> <g id="node4" class="node">
<title>A8&#45;&gt;A8</title> <title>A3</title>
<path fill="none" stroke="#000000" d="M475.3471,-272.2739C485.9443,-267.1987 493,-257.1074 493,-242 493,-231.3776 489.5118,-223.2351 483.7569,-217.5725"/> <polygon fill="none" stroke="#000000" points="274.348,-270 274.348,-302 346.348,-302 346.348,-270 274.348,-270"/>
<polygon fill="#000000" stroke="#000000" points="475.3471,-211.7261 486.1266,-213.7393 479.4525,-214.5802 483.5579,-217.4342 483.5579,-217.4342 483.5579,-217.4342 479.4525,-214.5802 480.9893,-221.1291 475.3471,-211.7261 475.3471,-211.7261"/> <text text-anchor="start" x="292.5655" y="-283" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">Modbus</text>
<text text-anchor="middle" x="495.0548" y="-212.1325" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">0..1</text> <polygon fill="none" stroke="#000000" points="274.348,-250 274.348,-270 346.348,-270 346.348,-250 274.348,-250"/>
<text text-anchor="middle" x="487.2174" y="-253.1774" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">has</text> <polygon fill="none" stroke="#000000" points="274.348,-182 274.348,-250 346.348,-250 346.348,-182 274.348,-182"/>
<text text-anchor="start" x="284.238" y="-231" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">build_msg()</text>
<text text-anchor="start" x="287.572" y="-219" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">recv_req()</text>
<text text-anchor="start" x="285.072" y="-207" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">recv_resp()</text>
<text text-anchor="start" x="284.516" y="-195" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">check_crc()</text>
</g> </g>
<!-- A12 --> <!-- A4 -->
<g id="node13" class="node"> <g id="node5" class="node">
<title>A12</title> <title>A4</title>
<polygon fill="none" stroke="#000000" points="274,-88 274,-120 396,-120 396,-88 274,-88"/> <polygon fill="none" stroke="#000000" points="263.348,-1104 263.348,-1136 334.348,-1136 334.348,-1104 263.348,-1104"/>
<text text-anchor="start" x="308.05" y="-101" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">InverterG3P</text> <text text-anchor="start" x="273.293" y="-1117" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">IterRegistry</text>
<polygon fill="none" stroke="#000000" points="274,-56 274,-88 396,-88 396,-56 274,-56"/> <polygon fill="none" stroke="#000000" points="263.348,-1084 263.348,-1104 334.348,-1104 334.348,-1084 263.348,-1084"/>
<text text-anchor="start" x="304.4355" y="-69" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">__ha_restarts</text> <polygon fill="none" stroke="#000000" points="263.348,-1052 263.348,-1084 334.348,-1084 334.348,-1052 263.348,-1052"/>
<polygon fill="none" stroke="#000000" points="274,0 274,-56 396,-56 396,0 274,0"/> <text text-anchor="start" x="280.787" y="-1065" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">__iter__</text>
<text text-anchor="start" x="283.6035" y="-37" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">async_create_remote()</text>
<text text-anchor="start" x="320.0025" y="-13" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">close()</text>
</g> </g>
<!-- A8&#45;&gt;A12 --> <!-- A5 -->
<g id="edge14" class="edge"> <g id="node6" class="node">
<title>A8&#45;&gt;A12</title> <title>A5</title>
<path fill="none" stroke="#000000" d="M377.3195,-184.2281C370.3709,-163.8307 362.5428,-140.8515 355.526,-120.2539"/> <polygon fill="none" stroke="#000000" points="231.348,-898 231.348,-930 365.348,-930 365.348,-898 231.348,-898"/>
<polygon fill="none" stroke="#000000" points="374.0102,-185.368 380.5479,-193.7052 380.6363,-183.1107 374.0102,-185.368"/> <text text-anchor="start" x="278.0655" y="-911" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">Message</text>
<polygon fill="none" stroke="#000000" points="231.348,-734 231.348,-898 365.348,-898 365.348,-734 231.348,-734"/>
<text text-anchor="start" x="261.6745" y="-879" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">server_side:bool</text>
<text text-anchor="start" x="258.891" y="-867" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">header_valid:bool</text>
<text text-anchor="start" x="251.662" y="-855" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">header_len:unsigned</text>
<text text-anchor="start" x="257.496" y="-843" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">data_len:unsigned</text>
<text text-anchor="start" x="276.6725" y="-831" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">unique_id</text>
<text text-anchor="start" x="280.5615" y="-819" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">node_id</text>
<text text-anchor="start" x="277.5065" y="-807" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">sug_area</text>
<text text-anchor="start" x="248.337" y="-795" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">_recv_buffer:bytearray</text>
<text text-anchor="start" x="246.9425" y="-783" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">_send_buffer:bytearray</text>
<text text-anchor="start" x="241.1145" y="-771" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">_forward_buffer:bytearray</text>
<text text-anchor="start" x="280.5615" y="-759" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">db:Infos</text>
<text text-anchor="start" x="269.174" y="-747" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">new_data:list</text>
<polygon fill="none" stroke="#000000" points="231.348,-666 231.348,-734 365.348,-734 365.348,-666 231.348,-666"/>
<text text-anchor="start" x="248.0575" y="-715" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">_read():void&lt;abstract&gt;</text>
<text text-anchor="start" x="272.7925" y="-703" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">close():void</text>
<text text-anchor="start" x="258.6205" y="-691" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">inc_counter():void</text>
<text text-anchor="start" x="256.9505" y="-679" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">dec_counter():void</text>
</g>
<!-- A4&#45;&gt;A5 -->
<g id="edge2" class="edge">
<title>A4&#45;&gt;A5</title>
<path fill="none" stroke="#000000" d="M298.348,-1041.7414C298.348,-1010.6043 298.348,-969.5621 298.348,-930.0536"/>
<polygon fill="none" stroke="#000000" points="294.8481,-1041.9047 298.348,-1051.9048 301.8481,-1041.9048 294.8481,-1041.9047"/>
</g>
<!-- A6 -->
<g id="node7" class="node">
<title>A6</title>
<polygon fill="none" stroke="#000000" points="370.348,-584 370.348,-616 484.348,-616 484.348,-584 370.348,-584"/>
<text text-anchor="start" x="413.456" y="-597" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">Talent</text>
<polygon fill="none" stroke="#000000" points="370.348,-480 370.348,-584 484.348,-584 484.348,-480 370.348,-480"/>
<text text-anchor="start" x="380.111" y="-565" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">await_conn_resp_cnt</text>
<text text-anchor="start" x="415.1255" y="-553" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">id_str</text>
<text text-anchor="start" x="395.948" y="-541" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">contact_name</text>
<text text-anchor="start" x="399.288" y="-529" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">contact_mail</text>
<text text-anchor="start" x="402.8925" y="-517" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">db:InfosG3</text>
<text text-anchor="start" x="401.232" y="-505" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">mb:Modbus</text>
<text text-anchor="start" x="413.46" y="-493" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">switch</text>
<polygon fill="none" stroke="#000000" points="370.348,-364 370.348,-480 484.348,-480 484.348,-364 370.348,-364"/>
<text text-anchor="start" x="384.8405" y="-461" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">msg_contact_info()</text>
<text text-anchor="start" x="386.7805" y="-449" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">msg_ota_update()</text>
<text text-anchor="start" x="392.6245" y="-437" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">msg_get_time()</text>
<text text-anchor="start" x="380.6765" y="-425" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">msg_collector_data()</text>
<text text-anchor="start" x="382.6215" y="-413" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">msg_inverter_data()</text>
<text text-anchor="start" x="391.7885" y="-401" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">msg_unknown()</text>
<text text-anchor="start" x="412.3505" y="-377" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">close()</text>
</g>
<!-- A5&#45;&gt;A6 -->
<g id="edge3" class="edge">
<title>A5&#45;&gt;A6</title>
<path fill="none" stroke="#000000" d="M357.819,-656.0073C363.3477,-642.8069 368.9261,-629.488 374.3902,-616.442"/>
<polygon fill="none" stroke="#000000" points="354.4392,-655.017 353.8043,-665.5928 360.8958,-657.7213 354.4392,-655.017"/>
</g>
<!-- A7 -->
<g id="node8" class="node">
<title>A7</title>
<polygon fill="none" stroke="#000000" points="127.348,-548 127.348,-580 218.348,-580 218.348,-548 127.348,-548"/>
<text text-anchor="start" x="145.343" y="-561" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">SolarmanV5</text>
<polygon fill="none" stroke="#000000" points="127.348,-456 127.348,-548 218.348,-548 218.348,-456 127.348,-456"/>
<text text-anchor="start" x="157.846" y="-529" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">control</text>
<text text-anchor="start" x="160.9055" y="-517" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">serial</text>
<text text-anchor="start" x="165.904" y="-505" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">snr</text>
<text text-anchor="start" x="145.058" y="-493" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">db:InfosG3P</text>
<text text-anchor="start" x="146.732" y="-481" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">mb:Modbus</text>
<text text-anchor="start" x="158.96" y="-469" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">switch</text>
<polygon fill="none" stroke="#000000" points="127.348,-400 127.348,-456 218.348,-456 218.348,-400 127.348,-400"/>
<text text-anchor="start" x="137.2885" y="-437" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">msg_unknown()</text>
<text text-anchor="start" x="157.8505" y="-413" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">close()</text>
</g>
<!-- A5&#45;&gt;A7 -->
<g id="edge4" class="edge">
<title>A5&#45;&gt;A7</title>
<path fill="none" stroke="#000000" d="M240.2947,-656.0919C229.716,-630.2328 218.9501,-603.9162 209.2,-580.0827"/>
<polygon fill="none" stroke="#000000" points="237.1556,-657.6626 244.1814,-665.5928 243.6344,-655.0121 237.1556,-657.6626"/>
</g>
<!-- A6&#45;&gt;A3 -->
<g id="edge6" class="edge">
<title>A6&#45;&gt;A3</title>
<path fill="none" stroke="#000000" d="M370.219,-368.906C360.883,-349.1169 351.5004,-329.2289 343.023,-311.2598"/>
<polygon fill="#000000" stroke="#000000" points="338.6774,-302.0487 347.0141,-309.1727 340.8108,-306.5707 342.9442,-311.0928 342.9442,-311.0928 342.9442,-311.0928 340.8108,-306.5707 338.8744,-313.0128 338.6774,-302.0487 338.6774,-302.0487"/>
<text text-anchor="middle" x="354.0558" y="-311.8357" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">1</text>
<text text-anchor="middle" x="354.8406" y="-353.119" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">has</text>
</g>
<!-- A8 -->
<g id="node9" class="node">
<title>A8</title>
<polygon fill="none" stroke="#000000" points="364.348,-258 364.348,-290 514.348,-290 514.348,-258 364.348,-258"/>
<text text-anchor="start" x="407.3935" y="-271" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">ConnectionG3</text>
<polygon fill="none" stroke="#000000" points="364.348,-226 364.348,-258 514.348,-258 514.348,-226 364.348,-226"/>
<text text-anchor="start" x="374.335" y="-239" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">remoteStream:ConnectionG3</text>
<polygon fill="none" stroke="#000000" points="364.348,-194 364.348,-226 514.348,-226 514.348,-194 364.348,-194"/>
<text text-anchor="start" x="424.3505" y="-207" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">close()</text>
</g>
<!-- A6&#45;&gt;A8 -->
<g id="edge5" class="edge">
<title>A6&#45;&gt;A8</title>
<path fill="none" stroke="#000000" d="M433.943,-353.7029C435.0429,-330.9727 436.1158,-308.7991 437.012,-290.2778"/>
<polygon fill="none" stroke="#000000" points="430.441,-353.6629 433.4535,-363.8204 437.4328,-354.0013 430.441,-353.6629"/>
</g>
<!-- A7&#45;&gt;A3 -->
<g id="edge8" class="edge">
<title>A7&#45;&gt;A3</title>
<path fill="none" stroke="#000000" d="M208.5342,-399.8871C214.3752,-387.5945 220.7034,-375.3217 227.348,-364 241.4757,-339.9278 249.4905,-336.9696 265.348,-314 266.3556,-312.5405 267.3678,-311.0592 268.3821,-309.5614"/>
<polygon fill="#000000" stroke="#000000" points="274.1947,-300.8381 272.3944,-311.6552 271.4221,-304.999 268.6496,-309.1599 268.6496,-309.1599 268.6496,-309.1599 271.4221,-304.999 264.9048,-306.6646 274.1947,-300.8381 274.1947,-300.8381"/>
<text text-anchor="middle" x="271.1774" y="-317.6092" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">1</text>
<text text-anchor="middle" x="208.7462" y="-376.8883" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">has</text>
</g> </g>
<!-- A9 --> <!-- A9 -->
<g id="node10" class="node"> <g id="node10" class="node">
<title>A9</title> <title>A9</title>
<polygon fill="none" stroke="#000000" points="277,-572 277,-604 393,-604 393,-572 277,-572"/> <polygon fill="none" stroke="#000000" points="82.348,-258 82.348,-290 238.348,-290 238.348,-258 82.348,-258"/>
<text text-anchor="start" x="305.274" y="-585" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">AsyncStream</text> <text text-anchor="start" x="125.059" y="-271" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">ConnectionG3P</text>
<polygon fill="none" stroke="#000000" points="277,-492 277,-572 393,-572 393,-492 277,-492"/> <polygon fill="none" stroke="#000000" points="82.348,-226 82.348,-258 238.348,-258 238.348,-226 82.348,-226"/>
<text text-anchor="start" x="320.553" y="-553" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">reader</text> <text text-anchor="start" x="92.0005" y="-239" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">remoteStream:ConnectionG3P</text>
<text text-anchor="start" x="322.783" y="-541" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">writer</text> <polygon fill="none" stroke="#000000" points="82.348,-194 82.348,-226 238.348,-226 238.348,-194 82.348,-194"/>
<text text-anchor="start" x="324.997" y="-529" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">addr</text> <text text-anchor="start" x="145.3505" y="-207" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">close()</text>
<text text-anchor="start" x="320.553" y="-517" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">r_addr</text>
<text text-anchor="start" x="321.108" y="-505" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">l_addr</text>
<polygon fill="none" stroke="#000000" points="277,-364 277,-492 393,-492 393,-364 277,-364"/>
<text text-anchor="start" x="286.6575" y="-473" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;server_loop()</text>
<text text-anchor="start" x="288.878" y="-461" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;client_loop()</text>
<text text-anchor="start" x="306.654" y="-449" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;loop</text>
<text text-anchor="start" x="322.782" y="-437" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">disc()</text>
<text text-anchor="start" x="320.0025" y="-425" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">close()</text>
<text text-anchor="start" x="300.2705" y="-401" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">__async_read()</text>
<text text-anchor="start" x="299.721" y="-389" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">__async_write()</text>
<text text-anchor="start" x="293.607" y="-377" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">__async_forward()</text>
</g> </g>
<!-- A9&#45;&gt;A7 --> <!-- A7&#45;&gt;A9 -->
<g id="edge7" class="edge"> <g id="edge7" class="edge">
<title>A9&#45;&gt;A7</title> <title>A7&#45;&gt;A9</title>
<path fill="none" stroke="#000000" d="M272.2034,-364.3403C258.3698,-337.9803 244.4918,-311.5356 233.1958,-290.0108"/> <path fill="none" stroke="#000000" d="M167.4931,-389.6656C165.8292,-355.2775 164.0432,-318.3674 162.6731,-290.0512"/>
<polygon fill="none" stroke="#000000" points="269.1431,-366.041 276.8893,-373.2693 275.3415,-362.7881 269.1431,-366.041"/> <polygon fill="none" stroke="#000000" points="164.0025,-389.9456 167.9818,-399.7648 170.9943,-389.6073 164.0025,-389.9456"/>
</g> </g>
<!-- A9&#45;&gt;A8 --> <!-- A8&#45;&gt;A8 -->
<g id="edge8" class="edge"> <g id="edge15" class="edge">
<title>A9&#45;&gt;A8</title> <title>A8&#45;&gt;A8</title>
<path fill="none" stroke="#000000" d="M368.3237,-353.9299C374.1595,-331.1516 379.8848,-308.8044 384.6662,-290.1415"/> <path fill="none" stroke="#000000" d="M514.5164,-272.6238C525.1874,-267.6708 532.348,-257.4629 532.348,-242 532.348,-231.1277 528.8079,-222.8533 522.9966,-217.1769"/>
<polygon fill="none" stroke="#000000" points="364.9098,-353.1532 365.8184,-363.709 371.6908,-354.8905 364.9098,-353.1532"/> <polygon fill="#000000" stroke="#000000" points="514.5164,-211.3762 525.3108,-213.3079 518.6433,-214.1991 522.7702,-217.0221 522.7702,-217.0221 522.7702,-217.0221 518.6433,-214.1991 520.2296,-220.7363 514.5164,-211.3762 514.5164,-211.3762"/>
<text text-anchor="middle" x="534.2494" y="-211.6335" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">0..1</text>
<text text-anchor="middle" x="526.5555" y="-253.6532" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">has</text>
</g> </g>
<!-- A10&#45;&gt;A11 --> <!-- A12 -->
<g id="edge9" class="edge"> <g id="node13" class="node">
<title>A10&#45;&gt;A11</title> <title>A12</title>
<path fill="none" stroke="#000000" d="M93.7037,-160.4648C99.1515,-146.8826 104.7134,-133.016 109.8967,-120.0931"/> <polygon fill="none" stroke="#000000" points="460.348,-88 460.348,-120 582.348,-120 582.348,-88 460.348,-88"/>
<polygon fill="none" stroke="#000000" points="90.4307,-159.2232 89.9564,-169.8074 96.9276,-161.8291 90.4307,-159.2232"/> <text text-anchor="start" x="497.7325" y="-101" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">InverterG3</text>
<polygon fill="none" stroke="#000000" points="460.348,-56 460.348,-88 582.348,-88 582.348,-56 460.348,-56"/>
<text text-anchor="start" x="490.7835" y="-69" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">__ha_restarts</text>
<polygon fill="none" stroke="#000000" points="460.348,0 460.348,-56 582.348,-56 582.348,0 460.348,0"/>
<text text-anchor="start" x="469.9515" y="-37" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">async_create_remote()</text>
<text text-anchor="start" x="506.3505" y="-13" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">close()</text>
</g> </g>
<!-- A10&#45;&gt;A12 --> <!-- A8&#45;&gt;A12 -->
<g id="edge10" class="edge"> <g id="edge14" class="edge">
<title>A10&#45;&gt;A12</title> <title>A8&#45;&gt;A12</title>
<path fill="none" stroke="#000000" d="M122.8753,-170.8927C123.2497,-170.5927 123.6246,-170.2951 124,-170 149.1284,-150.2443 220.9786,-114.1777 273.8825,-88.7388"/> <path fill="none" stroke="#000000" d="M465.2524,-184.5048C474.4734,-164.0387 484.8784,-140.9447 494.2007,-120.2539"/>
<polygon fill="none" stroke="#000000" points="120.4501,-168.3606 115.1024,-177.5068 124.9865,-173.6918 120.4501,-168.3606"/> <polygon fill="none" stroke="#000000" points="462.024,-183.1501 461.1072,-193.7052 468.4062,-186.0256 462.024,-183.1501"/>
</g>
<!-- A9&#45;&gt;A9 -->
<g id="edge17" class="edge">
<title>A9&#45;&gt;A9</title>
<path fill="none" stroke="#000000" d="M238.6951,-272.2739C249.2923,-267.1987 256.348,-257.1074 256.348,-242 256.348,-231.3776 252.8598,-223.2351 247.1049,-217.5725"/>
<polygon fill="#000000" stroke="#000000" points="238.6951,-211.7261 249.4746,-213.7393 242.8005,-214.5802 246.9059,-217.4342 246.9059,-217.4342 246.9059,-217.4342 242.8005,-214.5802 244.3373,-221.1291 238.6951,-211.7261 238.6951,-211.7261"/>
<text text-anchor="middle" x="258.4028" y="-212.1325" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">0..1</text>
<text text-anchor="middle" x="250.5654" y="-253.1774" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">has</text>
</g> </g>
<!-- A13 --> <!-- A13 -->
<g id="node14" class="node"> <g id="node14" class="node">
<title>A13</title> <title>A13</title>
<polygon fill="none" stroke="#000000" points="350,-1164 350,-1196 453,-1196 453,-1164 350,-1164"/> <polygon fill="none" stroke="#000000" points="251.348,-88 251.348,-120 373.348,-120 373.348,-88 251.348,-88"/>
<text text-anchor="start" x="390.662" y="-1177" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">Infos</text> <text text-anchor="start" x="285.398" y="-101" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">InverterG3P</text>
<polygon fill="none" stroke="#000000" points="350,-1108 350,-1164 453,-1164 453,-1108 350,-1108"/> <polygon fill="none" stroke="#000000" points="251.348,-56 251.348,-88 373.348,-88 373.348,-56 251.348,-56"/>
<text text-anchor="start" x="393.4415" y="-1145" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">stat</text> <text text-anchor="start" x="281.7835" y="-69" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">__ha_restarts</text>
<text text-anchor="start" x="368.986" y="-1133" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">new_stat_data</text> <polygon fill="none" stroke="#000000" points="251.348,0 251.348,-56 373.348,-56 373.348,0 251.348,0"/>
<text text-anchor="start" x="382.6035" y="-1121" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">info_dev</text> <text text-anchor="start" x="260.9515" y="-37" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">async_create_remote()</text>
<polygon fill="none" stroke="#000000" points="350,-968 350,-1108 453,-1108 453,-968 350,-968"/> <text text-anchor="start" x="297.3505" y="-13" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">close()</text>
<text text-anchor="start" x="377.3355" y="-1089" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">static_init()</text> </g>
<text text-anchor="start" x="375.3845" y="-1077" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">dev_value()</text> <!-- A9&#45;&gt;A13 -->
<text text-anchor="start" x="372.3305" y="-1065" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">inc_counter()</text> <g id="edge16" class="edge">
<text text-anchor="start" x="370.6605" y="-1053" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">dec_counter()</text> <title>A9&#45;&gt;A13</title>
<text text-anchor="start" x="368.71" y="-1041" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">ha_proxy_conf</text> <path fill="none" stroke="#000000" d="M207.2144,-185.8836C224.5887,-165.0802 244.3566,-141.4107 262.0261,-120.2539"/>
<text text-anchor="start" x="383.713" y="-1029" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">ha_conf</text> <polygon fill="none" stroke="#000000" points="204.406,-183.7863 200.6821,-193.7052 209.7787,-188.2734 204.406,-183.7863"/>
<text text-anchor="start" x="377.8745" y="-1017" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">update_db</text> </g>
<text text-anchor="start" x="362.037" y="-1005" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">set_db_def_value</text> <!-- A10 -->
<text text-anchor="start" x="371.4855" y="-993" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">get_db_value</text> <g id="node11" class="node">
<text text-anchor="start" x="359.8225" y="-981" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">ignore_this_device</text> <title>A10</title>
<polygon fill="none" stroke="#000000" points="236.348,-578 236.348,-610 352.348,-610 352.348,-578 236.348,-578"/>
<text text-anchor="start" x="264.622" y="-591" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">AsyncStream</text>
<polygon fill="none" stroke="#000000" points="236.348,-498 236.348,-578 352.348,-578 352.348,-498 236.348,-498"/>
<text text-anchor="start" x="279.901" y="-559" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">reader</text>
<text text-anchor="start" x="282.131" y="-547" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">writer</text>
<text text-anchor="start" x="284.345" y="-535" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">addr</text>
<text text-anchor="start" x="279.901" y="-523" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">r_addr</text>
<text text-anchor="start" x="280.456" y="-511" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">l_addr</text>
<polygon fill="none" stroke="#000000" points="236.348,-370 236.348,-498 352.348,-498 352.348,-370 236.348,-370"/>
<text text-anchor="start" x="246.0055" y="-479" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;server_loop()</text>
<text text-anchor="start" x="248.226" y="-467" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;client_loop()</text>
<text text-anchor="start" x="266.002" y="-455" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;loop</text>
<text text-anchor="start" x="282.13" y="-443" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">disc()</text>
<text text-anchor="start" x="279.3505" y="-431" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">close()</text>
<text text-anchor="start" x="259.6185" y="-407" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">__async_read()</text>
<text text-anchor="start" x="264.628" y="-395" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">async_write()</text>
<text text-anchor="start" x="252.955" y="-383" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">__async_forward()</text>
</g>
<!-- A10&#45;&gt;A8 -->
<g id="edge9" class="edge">
<title>A10&#45;&gt;A8</title>
<path fill="none" stroke="#000000" d="M357.4808,-370.672C358.7731,-368.4252 360.063,-366.1993 361.348,-364 375.806,-339.2552 392.855,-312.3558 407.3203,-290.1276"/>
<polygon fill="none" stroke="#000000" points="354.4004,-369.0085 352.4898,-379.4297 360.4821,-372.4746 354.4004,-369.0085"/>
</g>
<!-- A10&#45;&gt;A9 -->
<g id="edge10" class="edge">
<title>A10&#45;&gt;A9</title>
<path fill="none" stroke="#000000" d="M231.527,-371.7451C230.1228,-369.1386 228.7284,-366.5542 227.348,-364 214.1359,-339.5527 199.2736,-312.4504 186.9099,-290.012"/>
<polygon fill="none" stroke="#000000" points="228.5137,-373.5316 236.3333,-380.6803 234.6785,-370.2155 228.5137,-373.5316"/>
</g>
<!-- A11&#45;&gt;A12 -->
<g id="edge11" class="edge">
<title>A11&#45;&gt;A12</title>
<path fill="none" stroke="#000000" d="M567.1644,-160.4648C560.9703,-146.8826 554.6465,-133.016 548.7531,-120.0931"/>
<polygon fill="none" stroke="#000000" points="564.0911,-162.1611 571.425,-169.8074 570.4601,-159.2566 564.0911,-162.1611"/>
</g>
<!-- A11&#45;&gt;A13 -->
<g id="edge12" class="edge">
<title>A11&#45;&gt;A13</title>
<path fill="none" stroke="#000000" d="M542.4867,-170.8745C542.1078,-170.5805 541.7282,-170.2889 541.348,-170 513.3438,-148.7162 431.3406,-111.2534 373.497,-86.0342"/>
<polygon fill="none" stroke="#000000" points="540.4079,-173.6974 550.3407,-177.3838 544.8747,-168.3078 540.4079,-173.6974"/>
</g> </g>
<!-- A14 --> <!-- A14 -->
<g id="node15" class="node"> <g id="node15" class="node">
<title>A14</title> <title>A14</title>
<polygon fill="none" stroke="#000000" points="319,-802 319,-834 386,-834 386,-802 319,-802"/> <polygon fill="none" stroke="#000000" points="133.348,-1176 133.348,-1208 236.348,-1208 236.348,-1176 133.348,-1176"/>
<text text-anchor="start" x="334.993" y="-815" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">InfosG3</text> <text text-anchor="start" x="174.01" y="-1189" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">Infos</text>
<polygon fill="none" stroke="#000000" points="319,-782 319,-802 386,-802 386,-782 319,-782"/> <polygon fill="none" stroke="#000000" points="133.348,-1120 133.348,-1176 236.348,-1176 236.348,-1120 133.348,-1120"/>
<polygon fill="none" stroke="#000000" points="319,-738 319,-782 386,-782 386,-738 319,-738"/> <text text-anchor="start" x="176.7895" y="-1157" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">stat</text>
<text text-anchor="start" x="328.884" y="-763" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">ha_confs()</text> <text text-anchor="start" x="152.334" y="-1145" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">new_stat_data</text>
<text text-anchor="start" x="336.668" y="-751" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">parse()</text> <text text-anchor="start" x="165.9515" y="-1133" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">info_dev</text>
</g> <polygon fill="none" stroke="#000000" points="133.348,-980 133.348,-1120 236.348,-1120 236.348,-980 133.348,-980"/>
<!-- A13&#45;&gt;A14 --> <text text-anchor="start" x="160.6835" y="-1101" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">static_init()</text>
<g id="edge16" class="edge"> <text text-anchor="start" x="158.7325" y="-1089" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">dev_value()</text>
<title>A13&#45;&gt;A14</title> <text text-anchor="start" x="155.6785" y="-1077" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">inc_counter()</text>
<path fill="none" stroke="#000000" d="M380.4486,-957.853C373.2314,-914.2551 365.5447,-867.821 359.9831,-834.2247"/> <text text-anchor="start" x="154.0085" y="-1065" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">dec_counter()</text>
<polygon fill="none" stroke="#000000" points="377.0391,-958.688 382.1254,-967.9821 383.9452,-957.5447 377.0391,-958.688"/> <text text-anchor="start" x="152.058" y="-1053" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">ha_proxy_conf</text>
<text text-anchor="start" x="167.061" y="-1041" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">ha_conf</text>
<text text-anchor="start" x="161.2225" y="-1029" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">update_db</text>
<text text-anchor="start" x="145.385" y="-1017" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">set_db_def_value</text>
<text text-anchor="start" x="154.8335" y="-1005" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">get_db_value</text>
<text text-anchor="start" x="143.1705" y="-993" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">ignore_this_device</text>
</g> </g>
<!-- A15 --> <!-- A15 -->
<g id="node16" class="node"> <g id="node16" class="node">
<title>A15</title> <title>A15</title>
<polygon fill="none" stroke="#000000" points="417,-802 417,-834 484,-834 484,-802 417,-802"/> <polygon fill="none" stroke="#000000" points="386.348,-814 386.348,-846 453.348,-846 453.348,-814 386.348,-814"/>
<text text-anchor="start" x="429.6585" y="-815" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">InfosG3P</text> <text text-anchor="start" x="402.341" y="-827" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">InfosG3</text>
<polygon fill="none" stroke="#000000" points="417,-782 417,-802 484,-802 484,-782 417,-782"/> <polygon fill="none" stroke="#000000" points="386.348,-794 386.348,-814 453.348,-814 453.348,-794 386.348,-794"/>
<polygon fill="none" stroke="#000000" points="417,-738 417,-782 484,-782 484,-738 417,-738"/> <polygon fill="none" stroke="#000000" points="386.348,-750 386.348,-794 453.348,-794 453.348,-750 386.348,-750"/>
<text text-anchor="start" x="426.884" y="-763" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">ha_confs()</text> <text text-anchor="start" x="396.232" y="-775" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">ha_confs()</text>
<text text-anchor="start" x="434.668" y="-751" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">parse()</text> <text text-anchor="start" x="404.016" y="-763" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">parse()</text>
</g> </g>
<!-- A13&#45;&gt;A15 --> <!-- A14&#45;&gt;A15 -->
<g id="edge17" class="edge"> <g id="edge18" class="edge">
<title>A13&#45;&gt;A15</title> <title>A14&#45;&gt;A15</title>
<path fill="none" stroke="#000000" d="M421.5514,-957.853C428.7686,-914.2551 436.4553,-867.821 442.0169,-834.2247"/> <path fill="none" stroke="#000000" d="M242.8857,-990.9876C246.5464,-987.0913 250.3682,-983.4032 254.348,-980 298.2601,-942.4501 334.8682,-972.1855 374.348,-930 395.7725,-907.1072 407.0366,-873.5975 412.9375,-846.0704"/>
<polygon fill="none" stroke="#000000" points="418.0548,-957.5447 419.8746,-967.9821 424.9609,-958.688 418.0548,-957.5447"/> <polygon fill="none" stroke="#000000" points="240.0515,-988.9088 236.0452,-998.717 245.2936,-993.548 240.0515,-988.9088"/>
</g> </g>
<!-- A14&#45;&gt;A5 --> <!-- A16 -->
<g id="node17" class="node">
<title>A16</title>
<polygon fill="none" stroke="#000000" points="142.348,-814 142.348,-846 209.348,-846 209.348,-814 142.348,-814"/>
<text text-anchor="start" x="155.0065" y="-827" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">InfosG3P</text>
<polygon fill="none" stroke="#000000" points="142.348,-794 142.348,-814 209.348,-814 209.348,-794 142.348,-794"/>
<polygon fill="none" stroke="#000000" points="142.348,-750 142.348,-794 209.348,-794 209.348,-750 142.348,-750"/>
<text text-anchor="start" x="152.232" y="-775" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">ha_confs()</text>
<text text-anchor="start" x="160.016" y="-763" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">parse()</text>
</g>
<!-- A14&#45;&gt;A16 -->
<g id="edge19" class="edge"> <g id="edge19" class="edge">
<title>A14&#45;&gt;A5</title> <title>A14&#45;&gt;A16</title>
<path fill="none" stroke="#000000" d="M328.0662,-737.8133C310.5801,-702.608 286.0413,-653.2031 263.2551,-607.3269"/> <path fill="none" stroke="#000000" d="M180.5733,-969.853C179.2476,-926.2551 177.8358,-879.821 176.8143,-846.2247"/>
<polygon fill="#000000" stroke="#000000" points="258.7238,-598.2039 267.2025,-605.1583 260.948,-602.682 263.1723,-607.1601 263.1723,-607.1601 263.1723,-607.1601 260.948,-602.682 259.142,-609.1619 258.7238,-598.2039 258.7238,-598.2039"/> <polygon fill="none" stroke="#000000" points="177.0788,-970.0931 180.8812,-979.9821 184.0756,-969.8803 177.0788,-970.0931"/>
</g> </g>
<!-- A15&#45;&gt;A6 --> <!-- A15&#45;&gt;A6 -->
<g id="edge18" class="edge"> <g id="edge21" class="edge">
<title>A15&#45;&gt;A6</title> <title>A15&#45;&gt;A6</title>
<path fill="none" stroke="#000000" d="M451.1169,-737.8133C452.1468,-693.3826 453.7008,-626.3353 454.9531,-572.3076"/> <path fill="none" stroke="#000000" d="M420.598,-749.875C421.4623,-716.5989 422.6586,-670.54 423.8044,-626.4296"/>
<polygon fill="#000000" stroke="#000000" points="455.1913,-562.0332 459.4583,-572.1349 455.0754,-567.0319 454.9595,-572.0306 454.9595,-572.0306 454.9595,-572.0306 455.0754,-567.0319 450.4607,-571.9262 455.1913,-562.0332 455.1913,-562.0332"/> <polygon fill="#000000" stroke="#000000" points="424.071,-616.1641 428.3097,-626.2776 423.9411,-621.1624 423.8113,-626.1607 423.8113,-626.1607 423.8113,-626.1607 423.9411,-621.1624 419.3128,-626.0438 424.071,-616.1641 424.071,-616.1641"/>
</g>
<!-- A16&#45;&gt;A7 -->
<g id="edge20" class="edge">
<title>A16&#45;&gt;A7</title>
<path fill="none" stroke="#000000" d="M174.8793,-749.875C174.4651,-707.3571 173.8477,-643.9701 173.3263,-590.4435"/>
<polygon fill="#000000" stroke="#000000" points="173.2268,-580.2253 177.8241,-590.181 173.2756,-585.2251 173.3243,-590.2249 173.3243,-590.2249 173.3243,-590.2249 173.2756,-585.2251 168.8245,-590.2687 173.2268,-580.2253 173.2268,-580.2253"/>
</g> </g>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

@@ -4,13 +4,15 @@
[note: You can stick notes on diagrams too!{bg:cornsilk}] [note: You can stick notes on diagrams too!{bg:cornsilk}]
[Singleton]^[Mqtt|<static>ha_restarts;<static>__client;<static>__cb_MqttIsUp|<async>publish();<async>close()] [Singleton]^[Mqtt|<static>ha_restarts;<static>__client;<static>__cb_MqttIsUp|<async>publish();<async>close()]
[Modbus||build_msg();recv_req();recv_resp();check_crc()]
[IterRegistry||__iter__]^[Message|server_side:bool;header_valid:bool;header_len:unsigned;data_len:unsigned;unique_id;node_id;sug_area;_recv_buffer:bytearray;_send_buffer:bytearray;_forward_buffer:bytearray;db:Infos;new_data:list|_read():void<abstract>;close():void;inc_counter():void;dec_counter():void] [IterRegistry||__iter__]^[Message|server_side:bool;header_valid:bool;header_len:unsigned;data_len:unsigned;unique_id;node_id;sug_area;_recv_buffer:bytearray;_send_buffer:bytearray;_forward_buffer:bytearray;db:Infos;new_data:list|_read():void<abstract>;close():void;inc_counter():void;dec_counter():void]
[Message]^[Talent|await_conn_resp_cnt;id_str;contact_name;contact_mail;switch|msg_contact_info();msg_ota_update();msg_get_time();msg_collector_data();msg_inverter_data();msg_unknown();;close()] [Message]^[Talent|await_conn_resp_cnt;id_str;contact_name;contact_mail;db:InfosG3;mb:Modbus;switch|msg_contact_info();msg_ota_update();msg_get_time();msg_collector_data();msg_inverter_data();msg_unknown();;close()]
[Message]^[SolarmanV5|control;serial;snr;switch|msg_unknown();;close()] [Message]^[SolarmanV5|control;serial;snr;db:InfosG3P;mb:Modbus;switch|msg_unknown();;close()]
[Talent]^[ConnectionG3|remoteStream:ConnectionG3|close()] [Talent]^[ConnectionG3|remoteStream:ConnectionG3|close()]
[Talent]has-1>[Modbus]
[SolarmanV5]^[ConnectionG3P|remoteStream:ConnectionG3P|close()] [SolarmanV5]^[ConnectionG3P|remoteStream:ConnectionG3P|close()]
[AsyncStream|reader;writer;addr;r_addr;l_addr|<async>server_loop();<async>client_loop();<async>loop;disc();close();;__async_read();__async_write();__async_forward()]^[ConnectionG3] [SolarmanV5]has-1>[Modbus]
[AsyncStream|reader;writer;addr;r_addr;l_addr|<async>server_loop();<async>client_loop();<async>loop;disc();close();;__async_read();async_write();__async_forward()]^[ConnectionG3]
[AsyncStream]^[ConnectionG3P] [AsyncStream]^[ConnectionG3P]
[Inverter|cls.db_stat;cls.entity_prfx;cls.discovery_prfx;cls.proxy_node_id;cls.proxy_unique_id;cls.mqtt:Mqtt|]^[InverterG3|__ha_restarts|async_create_remote();;close()] [Inverter|cls.db_stat;cls.entity_prfx;cls.discovery_prfx;cls.proxy_node_id;cls.proxy_unique_id;cls.mqtt:Mqtt|]^[InverterG3|__ha_restarts|async_create_remote();;close()]
[Inverter]^[InverterG3P|__ha_restarts|async_create_remote();;close()] [Inverter]^[InverterG3P|__ha_restarts|async_create_remote();;close()]

View File

@@ -61,7 +61,7 @@ class AsyncStream():
await self.__async_read() await self.__async_read()
if self.unique_id: if self.unique_id:
await self.__async_write() await self.async_write()
await self.__async_forward() await self.__async_forward()
await self.async_publ_mqtt() await self.async_publ_mqtt()
@@ -100,9 +100,9 @@ class AsyncStream():
else: else:
raise RuntimeError("Peer closed.") raise RuntimeError("Peer closed.")
async def __async_write(self) -> None: async def async_write(self, headline='Transmit to ') -> None:
if self._send_buffer: if self._send_buffer:
hex_dump_memory(logging.INFO, f'Transmit to {self.addr}:', hex_dump_memory(logging.INFO, f'{headline}{self.addr}:',
self._send_buffer, len(self._send_buffer)) self._send_buffer, len(self._send_buffer))
self.writer.write(self._send_buffer) self.writer.write(self._send_buffer)
await self.writer.drain() await self.writer.drain()
@@ -114,7 +114,7 @@ class AsyncStream():
await self.async_create_remote() await self.async_create_remote()
if self.remoteStream: if self.remoteStream:
if self.remoteStream._init_new_client_conn(): if self.remoteStream._init_new_client_conn():
await self.remoteStream.__async_write() await self.remoteStream.async_write()
if self.remoteStream: if self.remoteStream:
self.remoteStream._update_header(self._forward_buffer) self.remoteStream._update_header(self._forward_buffer)

View File

@@ -161,7 +161,7 @@ class InfosG3(Infos):
update = False update = False
name = str(f'info-id.0x{addr:x}') name = str(f'info-id.0x{addr:x}')
self.tracer.log(level, f'GEN3: {name} : {result}{unit}' if update:
f' update: {update}') self.tracer.log(level, f'GEN3: {name} : {result}{unit}')
i += 1 i += 1

View File

@@ -5,10 +5,12 @@ from datetime import datetime
if __name__ == "app.src.gen3.talent": if __name__ == "app.src.gen3.talent":
from app.src.messages import hex_dump_memory, Message from app.src.messages import hex_dump_memory, Message
from app.src.modbus import Modbus
from app.src.config import Config from app.src.config import Config
from app.src.gen3.infos_g3 import InfosG3 from app.src.gen3.infos_g3 import InfosG3
else: # pragma: no cover else: # pragma: no cover
from messages import hex_dump_memory, Message from messages import hex_dump_memory, Message
from modbus import Modbus
from config import Config from config import Config
from gen3.infos_g3 import InfosG3 from gen3.infos_g3 import InfosG3
@@ -41,13 +43,20 @@ class Talent(Message):
self.contact_name = b'' self.contact_name = b''
self.contact_mail = b'' self.contact_mail = b''
self.db = InfosG3() self.db = InfosG3()
self.mb = Modbus()
self.forward_modbus_resp = False
self.closed = False
self.switch = { self.switch = {
0x00: self.msg_contact_info, 0x00: self.msg_contact_info,
0x13: self.msg_ota_update, 0x13: self.msg_ota_update,
0x22: self.msg_get_time, 0x22: self.msg_get_time,
0x71: self.msg_collector_data, 0x71: self.msg_collector_data,
# 0x76:
0x77: self.msg_modbus,
# 0x78:
0x04: self.msg_inverter_data, 0x04: self.msg_inverter_data,
} }
self.modbus_elms = 0 # for unit tests
''' '''
Our puplic methods Our puplic methods
@@ -58,6 +67,7 @@ class Talent(Message):
# so we have to erase self.switch, otherwise this instance can't be # so we have to erase self.switch, otherwise this instance can't be
# deallocated by the garbage collector ==> we get a memory leak # deallocated by the garbage collector ==> we get a memory leak
self.switch.clear() self.switch.clear()
self.closed = True
def __set_serial_no(self, serial_no: str): def __set_serial_no(self, serial_no: str):
@@ -115,6 +125,19 @@ class Talent(Message):
f' Ctl: {int(self.ctrl):#02x} Msg: {fnc.__name__!r}') f' Ctl: {int(self.ctrl):#02x} Msg: {fnc.__name__!r}')
return return
async def send_modbus_cmd(self, func, addr, val) -> None:
self.forward_modbus_resp = False
self.__build_header(0x70, 0x77)
self._send_buffer += b'\x00\x01\xa3\x28' # fixme
modbus_msg = self.mb.build_msg(Modbus.INV_ADDR, func, addr, val)
self._send_buffer += struct.pack('!B', len(modbus_msg))
self._send_buffer += modbus_msg
self.__finish_send_msg()
try:
await self.async_write('Send Modbus Command:')
except Exception:
self._send_buffer = bytearray(0)
def _init_new_client_conn(self) -> bool: def _init_new_client_conn(self) -> bool:
contact_name = self.contact_name contact_name = self.contact_name
contact_mail = self.contact_mail contact_mail = self.contact_mail
@@ -190,11 +213,13 @@ class Talent(Message):
self.header_valid = True self.header_valid = True
return return
def __build_header(self, ctrl) -> None: def __build_header(self, ctrl, msg_id=None) -> None:
if not msg_id:
msg_id = self.msg_id
self.send_msg_ofs = len(self._send_buffer) self.send_msg_ofs = len(self._send_buffer)
self._send_buffer += struct.pack(f'!l{len(self.id_str)+1}pBB', self._send_buffer += struct.pack(f'!l{len(self.id_str)+1}pBB',
0, self.id_str, ctrl, self.msg_id) 0, self.id_str, ctrl, msg_id)
fnc = self.switch.get(self.msg_id, self.msg_unknown) fnc = self.switch.get(msg_id, self.msg_unknown)
logger.info(self.__flow_str(self.server_side, 'tx') + logger.info(self.__flow_str(self.server_side, 'tx') +
f' Ctl: {int(ctrl):#02x} Msg: {fnc.__name__!r}') f' Ctl: {int(ctrl):#02x} Msg: {fnc.__name__!r}')
@@ -348,6 +373,40 @@ class Talent(Message):
self.inc_counter('Unknown_Ctrl') self.inc_counter('Unknown_Ctrl')
self.forward(self._recv_buffer, self.header_len+self.data_len) self.forward(self._recv_buffer, self.header_len+self.data_len)
def parse_modbus_header(self):
msg_hdr_len = 5
result = struct.unpack_from('!lBB', self._recv_buffer,
self.header_len)
modbus_len = result[1]
# logger.debug(f'Ref: {result[0]}')
# logger.debug(f'Modbus MsgLen: {modbus_len} Func:{result[2]}')
return msg_hdr_len, modbus_len
def msg_modbus(self):
hdr_len, modbus_len = self.parse_modbus_header()
if self.ctrl.is_req():
self.forward_modbus_resp = True
self.inc_counter('Modbus_Command')
elif self.ctrl.is_ind():
# logger.debug(f'Modbus Ind MsgLen: {modbus_len}')
self.modbus_elms = 0
for key, update in self.mb.recv_resp(self.db, self._recv_buffer[
self.header_len + hdr_len:self.header_len+self.data_len],
self.node_id):
if update:
self.new_data[key] = True
self.modbus_elms += 1
if not self.forward_modbus_resp:
return
else:
logger.warning('Unknown Ctrl')
self.inc_counter('Unknown_Ctrl')
self.forward(self._recv_buffer, self.header_len+self.data_len)
def msg_unknown(self): def msg_unknown(self):
logger.warning(f"Unknow Msg: ID:{self.msg_id}") logger.warning(f"Unknow Msg: ID:{self.msg_id}")
self.inc_counter('Unknown_Msg') self.inc_counter('Unknown_Msg')

View File

@@ -19,7 +19,7 @@ class RegisterMap:
0x4102001a: {'reg': Register.HEARTBEAT_INTERVAL, 'fmt': '<B', 'ratio': 1}, # noqa: E501 0x4102001a: {'reg': Register.HEARTBEAT_INTERVAL, 'fmt': '<B', 'ratio': 1}, # noqa: E501
0x4102001c: {'reg': Register.SIGNAL_STRENGTH, 'fmt': '<B', 'ratio': 1}, # noqa: E501 0x4102001c: {'reg': Register.SIGNAL_STRENGTH, 'fmt': '<B', 'ratio': 1}, # noqa: E501
0x4102001e: {'reg': Register.CHIP_MODEL, 'fmt': '!40s'}, # noqa: E501 0x4102001e: {'reg': Register.CHIP_MODEL, 'fmt': '!40s'}, # noqa: E501
0x4102004c: {'reg': Register.IP_ADRESS, 'fmt': '!16s'}, # noqa: E501 0x4102004c: {'reg': Register.IP_ADDRESS, 'fmt': '!16s'}, # noqa: E501
0x41020064: {'reg': Register.COLLECTOR_FW_VERSION, 'fmt': '!40s'}, # noqa: E501 0x41020064: {'reg': Register.COLLECTOR_FW_VERSION, 'fmt': '!40s'}, # noqa: E501
0x4201001c: {'reg': Register.POWER_ON_TIME, 'fmt': '<H', 'ratio': 1}, # noqa: E501 0x4201001c: {'reg': Register.POWER_ON_TIME, 'fmt': '<H', 'ratio': 1}, # noqa: E501
@@ -122,5 +122,5 @@ class InfosG3P(Infos):
name = str(f'info-id.0x{addr:x}') name = str(f'info-id.0x{addr:x}')
update = False update = False
self.tracer.log(level, f'GEN3PLUS: {name} : {result}{unit}' if update:
f' update: {update}') self.tracer.log(level, f'GEN3PLUS: {name} : {result}{unit}')

View File

@@ -6,12 +6,14 @@ from datetime import datetime
if __name__ == "app.src.gen3plus.solarman_v5": if __name__ == "app.src.gen3plus.solarman_v5":
from app.src.messages import hex_dump_memory, Message from app.src.messages import hex_dump_memory, Message
from app.src.modbus import Modbus
from app.src.config import Config from app.src.config import Config
from app.src.gen3plus.infos_g3p import InfosG3P from app.src.gen3plus.infos_g3p import InfosG3P
from app.src.infos import Register from app.src.infos import Register
else: # pragma: no cover else: # pragma: no cover
from messages import hex_dump_memory, Message from messages import hex_dump_memory, Message
from config import Config from config import Config
from modbus import Modbus
from gen3plus.infos_g3p import InfosG3P from gen3plus.infos_g3p import InfosG3P
from infos import Register from infos import Register
# import traceback # import traceback
@@ -46,6 +48,8 @@ class Sequence():
class SolarmanV5(Message): class SolarmanV5(Message):
AT_CMD = 1
MB_RTU_CMD = 2
def __init__(self, server_side: bool): def __init__(self, server_side: bool):
super().__init__(server_side) super().__init__(server_side)
@@ -56,6 +60,9 @@ class SolarmanV5(Message):
self.snr = 0 self.snr = 0
self.db = InfosG3P() self.db = InfosG3P()
self.time_ofs = 0 self.time_ofs = 0
self.mb = Modbus()
self.forward_modbus_resp = False
self.closed = False
self.switch = { self.switch = {
0x4210: self.msg_data_ind, # real time data 0x4210: self.msg_data_ind, # real time data
@@ -84,7 +91,7 @@ class SolarmanV5(Message):
# #
# MODbus or AT cmd # MODbus or AT cmd
0x4510: self.msg_command_req, # from server 0x4510: self.msg_command_req, # from server
0x1510: self.msg_response, # from inverter 0x1510: self.msg_command_rsp, # from inverter
} }
''' '''
@@ -96,6 +103,7 @@ class SolarmanV5(Message):
# so we have to erase self.switch, otherwise this instance can't be # so we have to erase self.switch, otherwise this instance can't be
# deallocated by the garbage collector ==> we get a memory leak # deallocated by the garbage collector ==> we get a memory leak
self.switch.clear() self.switch.clear()
self.closed = True
def __set_serial_no(self, snr: int): def __set_serial_no(self, snr: int):
serial_no = str(snr) serial_no = str(snr)
@@ -293,16 +301,49 @@ class SolarmanV5(Message):
self._heartbeat()) self._heartbeat())
self.__finish_send_msg() self.__finish_send_msg()
def send_at_cmd(self, AT_cmd: str) -> None: async def send_modbus_cmd(self, func, addr, val) -> None:
self.forward_modbus_resp = False
self.__build_header(0x4510) self.__build_header(0x4510)
self._send_buffer += struct.pack(f'<BHLLL{len(AT_cmd)}sc', 1, 2, self._send_buffer += struct.pack('<BHLLL', self.MB_RTU_CMD,
0, 0, 0, AT_cmd.encode('utf-8'), 0x2b0, 0, 0, 0)
self._send_buffer += self.mb.build_msg(Modbus.INV_ADDR,
func, addr, val)
self.__finish_send_msg()
try:
await self.async_write('Send Modbus Command:')
except Exception:
self._send_buffer = bytearray(0)
async def send_at_cmd(self, AT_cmd: str) -> None:
self.__build_header(0x4510)
self._send_buffer += struct.pack(f'<BHLLL{len(AT_cmd)}sc', self.AT_CMD,
2, 0, 0, 0, AT_cmd.encode('utf-8'),
b'\r') b'\r')
self.__finish_send_msg() self.__finish_send_msg()
try:
await self.async_write('Send AT Command:')
except Exception:
self._send_buffer = bytearray(0)
def __forward_msg(self): def __forward_msg(self):
self.forward(self._recv_buffer, self.header_len+self.data_len+2) self.forward(self._recv_buffer, self.header_len+self.data_len+2)
def __build_model_name(self):
db = self.db
MaxPow = db.get_db_value(Register.MAX_DESIGNED_POWER, 0)
Rated = db.get_db_value(Register.RATED_POWER, 0)
Model = None
if MaxPow == 2000:
if Rated == 800 or Rated == 600:
Model = f'TSOL-MS{MaxPow}({Rated})'
else:
Model = f'TSOL-MS{MaxPow}'
elif MaxPow == 1800 or MaxPow == 1600:
Model = f'TSOL-MS{MaxPow}'
if Model:
logger.info(f'Model: {Model}')
self.db.set_db_def_value(Register.EQUIPMENT_MODEL, Model)
def __process_data(self, ftype): def __process_data(self, ftype):
inv_update = False inv_update = False
msg_type = self.control >> 8 msg_type = self.control >> 8
@@ -313,21 +354,7 @@ class SolarmanV5(Message):
self.new_data[key] = True self.new_data[key] = True
if inv_update: if inv_update:
db = self.db self.__build_model_name()
MaxPow = db.get_db_value(Register.MAX_DESIGNED_POWER, 0)
Rated = db.get_db_value(Register.RATED_POWER, 0)
Model = None
if MaxPow == 2000:
if Rated == 800 or Rated == 600:
Model = f'TSOL-MS{MaxPow}({Rated})'
else:
Model = f'TSOL-MS{MaxPow}'
elif MaxPow == 1800 or MaxPow == 1600:
Model = f'TSOL-MS{MaxPow}'
if Model:
logger.info(f'Model: {Model}')
self.db.set_db_def_value(Register.EQUIPMENT_MODEL, Model)
''' '''
Message handler methods Message handler methods
''' '''
@@ -390,11 +417,43 @@ class SolarmanV5(Message):
data = self._recv_buffer[self.header_len:] data = self._recv_buffer[self.header_len:]
result = struct.unpack_from('<B', data, 0) result = struct.unpack_from('<B', data, 0)
ftype = result[0] ftype = result[0]
if ftype == self.AT_CMD:
self.inc_counter('AT_Command')
elif ftype == self.MB_RTU_CMD:
if not self.mb.recv_req(data[15:-2]):
return
self.forward_modbus_resp = True
self.inc_counter('Modbus_Command')
self.inc_counter('AT_Command')
self.__forward_msg() self.__forward_msg()
self.__send_ack_rsp(0x1510, ftype) self.__send_ack_rsp(0x1510, ftype)
def msg_command_rsp(self):
data = self._recv_buffer[self.header_len:]
ftype = data[0]
if ftype == self.AT_CMD:
pass
elif ftype == self.MB_RTU_CMD:
valid = data[1]
modbus_msg_len = self.data_len - 14
# logger.debug(f'modbus_len:{modbus_msg_len} accepted:{valid}')
if valid == 1 and modbus_msg_len > 4:
# logger.info(f'first byte modbus:{data[14]}')
inv_update = False
for key, update in self.mb.recv_resp(self.db, data[14:-2],
self.node_id):
if update:
if key == 'inverter':
inv_update = True
self.new_data[key] = True
if inv_update:
self.__build_model_name()
if not self.forward_modbus_resp:
return
self.__forward_msg()
def msg_hbeat_ind(self): def msg_hbeat_ind(self):
data = self._recv_buffer[self.header_len:] data = self._recv_buffer[self.header_len:]
result = struct.unpack_from('<B', data, 0) result = struct.unpack_from('<B', data, 0)
@@ -423,8 +482,9 @@ class SolarmanV5(Message):
valid = result[1] == 1 # status valid = result[1] == 1 # status
ts = result[2] ts = result[2]
set_hb = result[3] # always 60 or 120 set_hb = result[3] # always 60 or 120
logger.info(f'ftype:{ftype} accepted:{valid}' logger.debug(f'ftype:{ftype} accepted:{valid}'
f' ts:{ts:08x} nextHeartbeat: {set_hb}s') f' ts:{ts:08x} nextHeartbeat: {set_hb}s')
dt = datetime.fromtimestamp(ts) dt = datetime.fromtimestamp(ts)
logger.info(f'ts: {dt.strftime("%Y-%m-%d %H:%M:%S")}') logger.debug(f'ts: {dt.strftime("%Y-%m-%d %H:%M:%S")}')
self.__forward_msg()

View File

@@ -28,6 +28,7 @@ class Register(Enum):
SW_EXCEPTION = 57 SW_EXCEPTION = 57
INVALID_MSG_FMT = 58 INVALID_MSG_FMT = 58
AT_COMMAND = 59 AT_COMMAND = 59
MODBUS_COMMAND = 60
OUTPUT_POWER = 83 OUTPUT_POWER = 83
RATED_POWER = 84 RATED_POWER = 84
INVERTER_TEMP = 85 INVERTER_TEMP = 85
@@ -86,7 +87,7 @@ class Register(Enum):
DATA_UP_INTERVAL = 404 DATA_UP_INTERVAL = 404
CONNECT_COUNT = 405 CONNECT_COUNT = 405
HEARTBEAT_INTERVAL = 406 HEARTBEAT_INTERVAL = 406
IP_ADRESS = 407 IP_ADDRESS = 407
EVENT_401 = 500 EVENT_401 = 500
EVENT_402 = 501 EVENT_402 = 501
EVENT_403 = 502 EVENT_403 = 502
@@ -192,7 +193,7 @@ class Infos:
Register.SERIAL_NUMBER: {'name': ['inverter', 'Serial_Number'], 'level': logging.DEBUG, 'unit': ''}, # noqa: E501 Register.SERIAL_NUMBER: {'name': ['inverter', 'Serial_Number'], 'level': logging.DEBUG, 'unit': ''}, # noqa: E501
Register.EQUIPMENT_MODEL: {'name': ['inverter', 'Equipment_Model'], 'level': logging.DEBUG, 'unit': ''}, # noqa: E501 Register.EQUIPMENT_MODEL: {'name': ['inverter', 'Equipment_Model'], 'level': logging.DEBUG, 'unit': ''}, # noqa: E501
Register.NO_INPUTS: {'name': ['inverter', 'No_Inputs'], 'level': logging.DEBUG, 'unit': ''}, # noqa: E501 Register.NO_INPUTS: {'name': ['inverter', 'No_Inputs'], 'level': logging.DEBUG, 'unit': ''}, # noqa: E501
Register.MAX_DESIGNED_POWER: {'name': ['inverter', 'Max_Designed_Power'], 'level': logging.DEBUG, 'unit': 'W', 'ha': {'dev': 'inverter', 'dev_cla': None, 'stat_cla': None, 'id': 'designed_power_', 'fmt': '| string + " W"', 'name': 'Max Designed Power', 'icon': 'mdi:lightning-bolt', 'ent_cat': 'diagnostic'}}, # noqa: E501 Register.MAX_DESIGNED_POWER: {'name': ['inverter', 'Max_Designed_Power'], 'level': logging.INFO, 'unit': 'W', 'ha': {'dev': 'inverter', 'dev_cla': None, 'stat_cla': None, 'id': 'designed_power_', 'fmt': '| string + " W"', 'name': 'Max Designed Power', 'icon': 'mdi:lightning-bolt', 'ent_cat': 'diagnostic'}}, # noqa: E501
Register.RATED_POWER: {'name': ['inverter', 'Rated_Power'], 'level': logging.DEBUG, 'unit': 'W', 'ha': {'dev': 'inverter', 'dev_cla': None, 'stat_cla': None, 'id': 'rated_power_', 'fmt': '| string + " W"', 'name': 'Rated Power', 'icon': 'mdi:lightning-bolt', 'ent_cat': 'diagnostic'}}, # noqa: E501 Register.RATED_POWER: {'name': ['inverter', 'Rated_Power'], 'level': logging.DEBUG, 'unit': 'W', 'ha': {'dev': 'inverter', 'dev_cla': None, 'stat_cla': None, 'id': 'rated_power_', 'fmt': '| string + " W"', 'name': 'Rated Power', 'icon': 'mdi:lightning-bolt', 'ent_cat': 'diagnostic'}}, # noqa: E501
Register.PV1_MANUFACTURER: {'name': ['inverter', 'PV1_Manufacturer'], 'level': logging.DEBUG, 'unit': ''}, # noqa: E501 Register.PV1_MANUFACTURER: {'name': ['inverter', 'PV1_Manufacturer'], 'level': logging.DEBUG, 'unit': ''}, # noqa: E501
@@ -219,6 +220,7 @@ class Infos:
Register.SW_EXCEPTION: {'name': ['proxy', 'SW_Exception'], 'singleton': True, 'ha': {'dev': 'proxy', 'comp': 'sensor', 'dev_cla': None, 'stat_cla': None, 'id': 'sw_exception_', 'fmt': '| int', 'name': 'Internal SW Exception', 'icon': 'mdi:counter', 'ent_cat': 'diagnostic'}}, # noqa: E501 Register.SW_EXCEPTION: {'name': ['proxy', 'SW_Exception'], 'singleton': True, 'ha': {'dev': 'proxy', 'comp': 'sensor', 'dev_cla': None, 'stat_cla': None, 'id': 'sw_exception_', 'fmt': '| int', 'name': 'Internal SW Exception', 'icon': 'mdi:counter', 'ent_cat': 'diagnostic'}}, # noqa: E501
Register.INVALID_MSG_FMT: {'name': ['proxy', 'Invalid_Msg_Format'], 'singleton': True, 'ha': {'dev': 'proxy', 'comp': 'sensor', 'dev_cla': None, 'stat_cla': None, 'id': 'inv_msg_fmt_', 'fmt': '| int', 'name': 'Invalid Message Format', 'icon': 'mdi:counter', 'ent_cat': 'diagnostic'}}, # noqa: E501 Register.INVALID_MSG_FMT: {'name': ['proxy', 'Invalid_Msg_Format'], 'singleton': True, 'ha': {'dev': 'proxy', 'comp': 'sensor', 'dev_cla': None, 'stat_cla': None, 'id': 'inv_msg_fmt_', 'fmt': '| int', 'name': 'Invalid Message Format', 'icon': 'mdi:counter', 'ent_cat': 'diagnostic'}}, # noqa: E501
Register.AT_COMMAND: {'name': ['proxy', 'AT_Command'], 'singleton': True, 'ha': {'dev': 'proxy', 'comp': 'sensor', 'dev_cla': None, 'stat_cla': None, 'id': 'at_cmd_', 'fmt': '| int', 'name': 'AT Command', 'icon': 'mdi:counter', 'ent_cat': 'diagnostic'}}, # noqa: E501 Register.AT_COMMAND: {'name': ['proxy', 'AT_Command'], 'singleton': True, 'ha': {'dev': 'proxy', 'comp': 'sensor', 'dev_cla': None, 'stat_cla': None, 'id': 'at_cmd_', 'fmt': '| int', 'name': 'AT Command', 'icon': 'mdi:counter', 'ent_cat': 'diagnostic'}}, # noqa: E501
Register.MODBUS_COMMAND: {'name': ['proxy', 'Modbus_Command'], 'singleton': True, 'ha': {'dev': 'proxy', 'comp': 'sensor', 'dev_cla': None, 'stat_cla': None, 'id': 'modbus_cmd_', 'fmt': '| int', 'name': 'Modbus Command', 'icon': 'mdi:counter', 'ent_cat': 'diagnostic'}}, # noqa: E501
# 0xffffff03: {'name':['proxy', 'Voltage'], 'level': logging.DEBUG, 'unit': 'V', 'ha':{'dev':'proxy', 'dev_cla': 'voltage', 'stat_cla': 'measurement', 'id':'proxy_volt_', 'fmt':'| float','name': 'Grid Voltage'}}, # noqa: E501 # 0xffffff03: {'name':['proxy', 'Voltage'], 'level': logging.DEBUG, 'unit': 'V', 'ha':{'dev':'proxy', 'dev_cla': 'voltage', 'stat_cla': 'measurement', 'id':'proxy_volt_', 'fmt':'| float','name': 'Grid Voltage'}}, # noqa: E501
# events # events
@@ -290,7 +292,7 @@ class Infos:
Register.COMMUNICATION_TYPE: {'name': ['controller', 'Communication_Type'], 'level': logging.DEBUG, 'unit': '', 'ha': {'dev': 'controller', 'dev_cla': None, 'stat_cla': None, 'id': 'comm_type_', 'name': 'Communication Type', 'val_tpl': __comm_type_val_tpl, 'comp': 'sensor', 'icon': 'mdi:wifi'}}, # noqa: E501 Register.COMMUNICATION_TYPE: {'name': ['controller', 'Communication_Type'], 'level': logging.DEBUG, 'unit': '', 'ha': {'dev': 'controller', 'dev_cla': None, 'stat_cla': None, 'id': 'comm_type_', 'name': 'Communication Type', 'val_tpl': __comm_type_val_tpl, 'comp': 'sensor', 'icon': 'mdi:wifi'}}, # noqa: E501
Register.DATA_UP_INTERVAL: {'name': ['controller', 'Data_Up_Interval'], 'level': logging.DEBUG, 'unit': 's', 'ha': {'dev': 'controller', 'dev_cla': None, 'stat_cla': None, 'id': 'data_up_intval_', 'fmt': '| string + " s"', 'name': 'Data Up Interval', 'icon': 'mdi:update', 'ent_cat': 'diagnostic'}}, # noqa: E501 Register.DATA_UP_INTERVAL: {'name': ['controller', 'Data_Up_Interval'], 'level': logging.DEBUG, 'unit': 's', 'ha': {'dev': 'controller', 'dev_cla': None, 'stat_cla': None, 'id': 'data_up_intval_', 'fmt': '| string + " s"', 'name': 'Data Up Interval', 'icon': 'mdi:update', 'ent_cat': 'diagnostic'}}, # noqa: E501
Register.HEARTBEAT_INTERVAL: {'name': ['controller', 'Heartbeat_Interval'], 'level': logging.DEBUG, 'unit': 's', 'ha': {'dev': 'controller', 'dev_cla': None, 'stat_cla': None, 'id': 'heartbeat_intval_', 'fmt': '| string + " s"', 'name': 'Heartbeat Interval', 'icon': 'mdi:update', 'ent_cat': 'diagnostic'}}, # noqa: E501 Register.HEARTBEAT_INTERVAL: {'name': ['controller', 'Heartbeat_Interval'], 'level': logging.DEBUG, 'unit': 's', 'ha': {'dev': 'controller', 'dev_cla': None, 'stat_cla': None, 'id': 'heartbeat_intval_', 'fmt': '| string + " s"', 'name': 'Heartbeat Interval', 'icon': 'mdi:update', 'ent_cat': 'diagnostic'}}, # noqa: E501
Register.IP_ADRESS: {'name': ['controller', 'IP_Adress'], 'level': logging.DEBUG, 'unit': '', 'ha': {'dev': 'controller', 'dev_cla': None, 'stat_cla': None, 'id': 'ip_adress_', 'fmt': '| string', 'name': 'IP Adress', 'icon': 'mdi:wifi', 'ent_cat': 'diagnostic'}}, # noqa: E501 Register.IP_ADDRESS: {'name': ['controller', 'IP_Address'], 'level': logging.DEBUG, 'unit': '', 'ha': {'dev': 'controller', 'dev_cla': None, 'stat_cla': None, 'id': 'ip_address_', 'fmt': '| string', 'name': 'IP Address', 'icon': 'mdi:wifi', 'ent_cat': 'diagnostic'}}, # noqa: E501
} }
@property @property

174
app/src/modbus.py Normal file
View File

@@ -0,0 +1,174 @@
import struct
import logging
from typing import Generator
if __name__ == "app.src.modbus":
from app.src.infos import Register
else: # pragma: no cover
from infos import Register
#######
# TSUN uses the Modbus in the RTU transmission mode.
# see: https://modbus.org/docs/Modbus_over_serial_line_V1_02.pdf
#
# A Modbus PDU consists of: 'Function-Code' + 'Data'
# A Modbus RTU message consists of: 'Addr' + 'Modbus-PDU' + 'CRC-16'
#
# The 16-bit CRC is known as CRC-16-ANSI(reverse)
# see: https://en.wikipedia.org/wiki/Computation_of_cyclic_redundancy_checks
#######
CRC_POLY = 0xA001 # (LSBF/reverse)
CRC_INIT = 0xFFFF
class Modbus():
INV_ADDR = 1
READ_REGS = 3
READ_INPUTS = 4
WRITE_SINGLE_REG = 6
'''Modbus function codes'''
__crc_tab = []
map = {
0x2007: {'reg': Register.MAX_DESIGNED_POWER, 'fmt': '!H', 'ratio': 1}, # noqa: E501
# 0x????: {'reg': Register.INVERTER_STATUS, 'fmt': '!H'}, # noqa: E501
0x3008: {'reg': Register.VERSION, 'fmt': '!H', 'eval': "f'v{(result>>12)}.{(result>>8)&0xf}.{(result>>4)&0xf}{result&0xf}'"}, # noqa: E501
0x3009: {'reg': Register.GRID_VOLTAGE, 'fmt': '!H', 'ratio': 0.1}, # noqa: E501
0x300a: {'reg': Register.GRID_CURRENT, 'fmt': '!H', 'ratio': 0.01}, # noqa: E501
0x300b: {'reg': Register.GRID_FREQUENCY, 'fmt': '!H', 'ratio': 0.01}, # noqa: E501
0x300c: {'reg': Register.INVERTER_TEMP, 'fmt': '!H', 'eval': 'result-40'}, # noqa: E501
# 0x300d
0x300e: {'reg': Register.RATED_POWER, 'fmt': '!H', 'ratio': 1}, # noqa: E501
0x300f: {'reg': Register.OUTPUT_POWER, 'fmt': '!H', 'ratio': 0.1}, # noqa: E501
0x3010: {'reg': Register.PV1_VOLTAGE, 'fmt': '!H', 'ratio': 0.1}, # noqa: E501
0x3011: {'reg': Register.PV1_CURRENT, 'fmt': '!H', 'ratio': 0.01}, # noqa: E501
0x3012: {'reg': Register.PV1_POWER, 'fmt': '!H', 'ratio': 0.1}, # noqa: E501
0x3013: {'reg': Register.PV2_VOLTAGE, 'fmt': '!H', 'ratio': 0.1}, # noqa: E501
0x3014: {'reg': Register.PV2_CURRENT, 'fmt': '!H', 'ratio': 0.01}, # noqa: E501
0x3015: {'reg': Register.PV2_POWER, 'fmt': '!H', 'ratio': 0.1}, # noqa: E501
0x3016: {'reg': Register.PV3_VOLTAGE, 'fmt': '!H', 'ratio': 0.1}, # noqa: E501
0x3017: {'reg': Register.PV3_CURRENT, 'fmt': '!H', 'ratio': 0.01}, # noqa: E501
0x3018: {'reg': Register.PV3_POWER, 'fmt': '!H', 'ratio': 0.1}, # noqa: E501
0x3019: {'reg': Register.PV4_VOLTAGE, 'fmt': '!H', 'ratio': 0.1}, # noqa: E501
0x301a: {'reg': Register.PV4_CURRENT, 'fmt': '!H', 'ratio': 0.01}, # noqa: E501
0x301b: {'reg': Register.PV4_POWER, 'fmt': '!H', 'ratio': 0.1}, # noqa: E501
0x301c: {'reg': Register.DAILY_GENERATION, 'fmt': '!H', 'ratio': 0.01}, # noqa: E501
# 0x301d: {'reg': Register.TOTAL_GENERATION, 'fmt': '!L', 'ratio': 0.01}, # noqa: E501
0x301f: {'reg': Register.PV1_DAILY_GENERATION, 'fmt': '!H', 'ratio': 0.01}, # noqa: E501
# 0x3020: {'reg': Register.PV1_TOTAL_GENERATION, 'fmt': '!L', 'ratio': 0.01}, # noqa: E501
0x3022: {'reg': Register.PV2_DAILY_GENERATION, 'fmt': '!H', 'ratio': 0.01}, # noqa: E501
# 0x3023: {'reg': Register.PV2_TOTAL_GENERATION, 'fmt': '!L', 'ratio': 0.01}, # noqa: E501
0x3025: {'reg': Register.PV3_DAILY_GENERATION, 'fmt': '!H', 'ratio': 0.01}, # noqa: E501
# 0x3026: {'reg': Register.PV3_TOTAL_GENERATION, 'fmt': '!L', 'ratio': 0.01}, # noqa: E501
0x3028: {'reg': Register.PV4_DAILY_GENERATION, 'fmt': '!H', 'ratio': 0.01}, # noqa: E501
# 0x3029: {'reg': Register.PV4_TOTAL_GENERATION, 'fmt': '!L', 'ratio': 0.01}, # noqa: E501
}
def __init__(self):
if not len(self.__crc_tab):
self.__build_crc_tab(CRC_POLY)
self.last_fcode = 0
self.last_len = 0
self.last_reg = 0
self.err = 0
def build_msg(self, addr, func, reg, val):
msg = struct.pack('>BBHH', addr, func, reg, val)
msg += struct.pack('<H', self.__calc_crc(msg))
self.last_fcode = func
self.last_reg = reg
self.last_len = val
self.err = 0
return msg
def recv_req(self, buf: bytearray) -> bool:
# logging.info(f'recv_req: first byte modbus:{buf[0]} len:{len(buf)}')
if not self.check_crc(buf):
self.err = 1
logging.error('Modbus: CRC error')
return False
if buf[0] != self.INV_ADDR:
self.err = 2
logging.info(f'Modbus: Wrong addr{buf[0]}')
return False
res = struct.unpack_from('>BHH', buf, 1)
self.last_fcode = res[0]
self.last_reg = res[1]
self.last_len = res[2]
self.err = 0
return True
def recv_resp(self, info_db, buf: bytearray, node_id: str) -> \
Generator[tuple[str, bool], None, None]:
# logging.info(f'recv_resp: first byte modbus:{buf[0]} len:{len(buf)}')
if not self.check_crc(buf):
logging.error('Modbus: CRC error')
self.err = 1
return
if buf[0] != self.INV_ADDR:
logging.info(f'Modbus: Wrong addr {buf[0]}')
self.err = 2
return
if buf[1] != self.last_fcode:
logging.info(f'Modbus: Wrong fcode {buf[1]} != {self.last_fcode}')
self.err = 3
return
elmlen = buf[2] >> 1
if elmlen != self.last_len:
logging.info(f'Modbus: len error {elmlen} != {self.last_len}')
self.err = 4
return
self.err = 0
for i in range(0, elmlen):
val = struct.unpack_from('>H', buf, 3+2*i)
addr = self.last_reg+i
# logging.info(f'Modbus: 0x{addr:04x}: {val[0]}')
if addr in self.map:
row = self.map[addr]
info_id = row['reg']
result = val[0]
# fmt = row['fmt']
# res = struct.unpack_from(fmt, buf, addr)
# result = res[0]
if 'eval' in row:
result = eval(row['eval'])
if 'ratio' in row:
result = round(result * row['ratio'], 2)
keys, level, unit, must_incr = info_db._key_obj(info_id)
if keys:
name, update = info_db.update_db(keys, must_incr, result)
yield keys[0], update
else:
name = str(f'info-id.0x{addr:x}')
update = False
if update:
info_db.tracer.log(level,
f'MODBUS[{node_id}]: {name} : {result}'
f'{unit}')
def check_crc(self, msg) -> bool:
return 0 == self.__calc_crc(msg)
def __calc_crc(self, buffer: bytes) -> int:
crc = CRC_INIT
for cur in buffer:
crc = (crc >> 8) ^ self.__crc_tab[(crc ^ cur) & 0xFF]
return crc
def __build_crc_tab(self, poly) -> None:
for index in range(256):
data = index << 1
crc = 0
for _ in range(8, 0, -1):
data >>= 1
if (data ^ crc) & 1:
crc = (crc >> 1) ^ poly
else:
crc >>= 1
self.__crc_tab.append(crc)

View File

@@ -1,22 +1,15 @@
import asyncio import asyncio
import logging import logging
import aiomqtt import aiomqtt
import traceback
from modbus import Modbus
from messages import Message
from config import Config from config import Config
from singleton import Singleton
logger_mqtt = logging.getLogger('mqtt') logger_mqtt = logging.getLogger('mqtt')
class Singleton(type):
_instances = {}
def __call__(cls, *args, **kwargs):
logger_mqtt.debug('singleton: __call__')
if cls not in cls._instances:
cls._instances[cls] = super(Singleton,
cls).__call__(*args, **kwargs)
return cls._instances[cls]
class Mqtt(metaclass=Singleton): class Mqtt(metaclass=Singleton):
__client = None __client = None
__cb_MqttIsUp = None __cb_MqttIsUp = None
@@ -65,6 +58,12 @@ class Mqtt(metaclass=Singleton):
password=mqtt['passwd']) password=mqtt['passwd'])
interval = 5 # Seconds interval = 5 # Seconds
ha_status_topic = f"{ha['auto_conf_prefix']}/status"
mb_rated_topic = "tsun/+/rated_load" # fixme
mb_reads_topic = "tsun/+/modbus_read_regs" # fixme
mb_inputs_topic = "tsun/+/modbus_read_inputs" # fixme
mb_at_cmd_topic = "tsun/+/at_cmd" # fixme
while True: while True:
try: try:
async with self.__client: async with self.__client:
@@ -74,16 +73,36 @@ class Mqtt(metaclass=Singleton):
await self.__cb_MqttIsUp() await self.__cb_MqttIsUp()
# async with self.__client.messages() as messages: # async with self.__client.messages() as messages:
await self.__client.subscribe( await self.__client.subscribe(ha_status_topic)
f"{ha['auto_conf_prefix']}" await self.__client.subscribe(mb_rated_topic)
"/status") await self.__client.subscribe(mb_reads_topic)
await self.__client.subscribe(mb_inputs_topic)
await self.__client.subscribe(mb_at_cmd_topic)
async for message in self.__client.messages: async for message in self.__client.messages:
status = message.payload.decode("UTF-8") if message.topic.matches(ha_status_topic):
logger_mqtt.info('Home-Assistant Status:' status = message.payload.decode("UTF-8")
f' {status}') logger_mqtt.info('Home-Assistant Status:'
if status == 'online': f' {status}')
self.ha_restarts += 1 if status == 'online':
await self.__cb_MqttIsUp() self.ha_restarts += 1
await self.__cb_MqttIsUp()
if message.topic.matches(mb_rated_topic):
await self.modbus_cmd(message,
Modbus.WRITE_SINGLE_REG,
1, 0x2008)
if message.topic.matches(mb_reads_topic):
await self.modbus_cmd(message,
Modbus.READ_REGS, 2)
if message.topic.matches(mb_inputs_topic):
await self.modbus_cmd(message,
Modbus.READ_INPUTS, 2)
if message.topic.matches(mb_at_cmd_topic):
await self.at_cmd(message)
except aiomqtt.MqttError: except aiomqtt.MqttError:
if Config.is_default('mqtt'): if Config.is_default('mqtt'):
@@ -101,3 +120,52 @@ class Mqtt(metaclass=Singleton):
logger_mqtt.debug("MQTT task cancelled") logger_mqtt.debug("MQTT task cancelled")
self.__client = None self.__client = None
return return
except Exception:
# self.inc_counter('SW_Exception') # fixme
logger_mqtt.error(
f"Exception:\n"
f"{traceback.format_exc()}")
def each_inverter(self, message, func_name: str):
topic = str(message.topic)
node_id = topic.split('/')[1] + '/'
for m in Message:
if m.server_side and not m.closed and (m.node_id == node_id):
logger_mqtt.debug(f'Found: {node_id}')
fnc = getattr(m, func_name, None)
if callable(fnc):
yield fnc
else:
logger_mqtt.warning(f'Cmd not supported by: {node_id}')
else:
logger_mqtt.warning(f'Node_id: {node_id} not found')
async def modbus_cmd(self, message, func, params=0, addr=0, val=0):
topic = str(message.topic)
node_id = topic.split('/')[1] + '/'
# refactor into a loop over a table
payload = message.payload.decode("UTF-8")
logger_mqtt.info(f'InvCnf: {node_id}:{payload}')
for m in Message:
if m.server_side and not m.closed and (m.node_id == node_id):
logger_mqtt.info(f'Found: {node_id}')
fnc = getattr(m, "send_modbus_cmd", None)
res = payload.split(',')
if params != len(res):
logger_mqtt.error(f'Parameter expected: {params}, '
f'got: {len(res)}')
return
if callable(fnc):
if params == 1:
val = int(payload)
elif params == 2:
addr = int(res[0], base=16)
val = int(res[1]) # lenght
await fnc(func, addr, val)
async def at_cmd(self, message):
payload = message.payload.decode("UTF-8")
for fnc in self.each_inverter(message, "send_at_cmd"):
await fnc(payload)

View File

@@ -3,6 +3,8 @@ import json
from mqtt import Mqtt from mqtt import Mqtt
from aiocron import crontab from aiocron import crontab
from infos import ClrAtMidnight from infos import ClrAtMidnight
from modbus import Modbus
from messages import Message
logger_mqtt = logging.getLogger('mqtt') logger_mqtt = logging.getLogger('mqtt')
@@ -17,7 +19,9 @@ class Schedule:
cls.mqtt = Mqtt(None) cls.mqtt = Mqtt(None)
crontab('0 0 * * *', func=cls.atmidnight, start=True) crontab('0 0 * * *', func=cls.atmidnight, start=True)
# crontab('*/5 * * * *', func=cls.atmidnight, start=True)
# every minute
crontab('* * * * *', func=cls.regular_modbus_cmds, start=True)
@classmethod @classmethod
async def atmidnight(cls) -> None: async def atmidnight(cls) -> None:
@@ -28,3 +32,12 @@ class Schedule:
logger_mqtt.debug(f'{key}: {data}') logger_mqtt.debug(f'{key}: {data}')
data_json = json.dumps(data) data_json = json.dumps(data)
await cls.mqtt.publish(f"{key}", data_json) await cls.mqtt.publish(f"{key}", data_json)
@classmethod
async def regular_modbus_cmds(cls):
# logging.info("Regular Modbus requests")
for m in Message:
if m.server_side:
fnc = getattr(m, "send_modbus_cmd", None)
if callable(fnc):
await fnc(Modbus.READ_REGS, 0x3008, 20)

9
app/src/singleton.py Normal file
View File

@@ -0,0 +1,9 @@
class Singleton(type):
_instances = {}
def __call__(cls, *args, **kwargs):
# logger_mqtt.debug('singleton: __call__')
if cls not in cls._instances:
cls._instances[cls] = super(Singleton,
cls).__call__(*args, **kwargs)
return cls._instances[cls]

View File

@@ -17,13 +17,13 @@ def test_statistic_counter():
assert val == None or val == 0 assert val == None or val == 0
i.static_init() # initialize counter i.static_init() # initialize counter
assert json.dumps(i.stat) == json.dumps({"proxy": {"Inverter_Cnt": 0, "Unknown_SNR": 0, "Unknown_Msg": 0, "Invalid_Data_Type": 0, "Internal_Error": 0,"Unknown_Ctrl": 0, "OTA_Start_Msg": 0, "SW_Exception": 0, "Invalid_Msg_Format": 0, "AT_Command": 0}}) assert json.dumps(i.stat) == json.dumps({"proxy": {"Inverter_Cnt": 0, "Unknown_SNR": 0, "Unknown_Msg": 0, "Invalid_Data_Type": 0, "Internal_Error": 0,"Unknown_Ctrl": 0, "OTA_Start_Msg": 0, "SW_Exception": 0, "Invalid_Msg_Format": 0, "AT_Command": 0, "Modbus_Command": 0}})
val = i.dev_value(Register.INVERTER_CNT) # valid and initiliazed addr val = i.dev_value(Register.INVERTER_CNT) # valid and initiliazed addr
assert val == 0 assert val == 0
i.inc_counter('Inverter_Cnt') i.inc_counter('Inverter_Cnt')
assert json.dumps(i.stat) == json.dumps({"proxy": {"Inverter_Cnt": 1, "Unknown_SNR": 0, "Unknown_Msg": 0, "Invalid_Data_Type": 0, "Internal_Error": 0,"Unknown_Ctrl": 0, "OTA_Start_Msg": 0, "SW_Exception": 0, "Invalid_Msg_Format": 0, "AT_Command": 0}}) assert json.dumps(i.stat) == json.dumps({"proxy": {"Inverter_Cnt": 1, "Unknown_SNR": 0, "Unknown_Msg": 0, "Invalid_Data_Type": 0, "Internal_Error": 0,"Unknown_Ctrl": 0, "OTA_Start_Msg": 0, "SW_Exception": 0, "Invalid_Msg_Format": 0, "AT_Command": 0, "Modbus_Command": 0}})
val = i.dev_value(Register.INVERTER_CNT) val = i.dev_value(Register.INVERTER_CNT)
assert val == 1 assert val == 1

View File

@@ -70,7 +70,7 @@ def test_parse_4110(DeviceData: bytes):
pass pass
assert json.dumps(i.db) == json.dumps({ assert json.dumps(i.db) == json.dumps({
'controller': {"Data_Up_Interval": 300, "Collect_Interval": 1, "Heartbeat_Interval": 120, "Signal_Strength": 100, "IP_Adress": "192.168.80.49"}, 'controller': {"Data_Up_Interval": 300, "Collect_Interval": 1, "Heartbeat_Interval": 120, "Signal_Strength": 100, "IP_Address": "192.168.80.49"},
'collector': {"Chip_Model": "LSW5BLE_17_02B0_1.05", "Collector_Fw_Version": "V1.1.00.0B"}, 'collector': {"Chip_Model": "LSW5BLE_17_02B0_1.05", "Collector_Fw_Version": "V1.1.00.0B"},
}) })

41
app/tests/test_modbus.py Normal file
View File

@@ -0,0 +1,41 @@
# test_with_pytest.py
# import pytest, logging
from app.src.modbus import Modbus
from app.src.infos import Infos
class TestHelper(Modbus):
def __init__(self):
super().__init__()
self.db = Infos()
def test_modbus_crc():
mb = Modbus()
assert 0x0b02 == mb._Modbus__calc_crc(b'\x01\x06\x20\x08\x00\x04')
assert 0 == mb._Modbus__calc_crc(b'\x01\x06\x20\x08\x00\x04\x02\x0b')
assert mb.check_crc(b'\x01\x06\x20\x08\x00\x04\x02\x0b')
assert 0xc803 == mb._Modbus__calc_crc(b'\x01\x06\x20\x08\x00\x00')
assert 0 == mb._Modbus__calc_crc(b'\x01\x06\x20\x08\x00\x00\x03\xc8')
assert mb.check_crc(b'\x01\x06\x20\x08\x00\x00\x03\xc8')
def test_build_modbus_pdu():
mb = Modbus()
pdu = mb.build_msg(1,6,0x2000,0x12)
assert pdu == b'\x01\x06\x20\x00\x00\x12\x02\x07'
assert mb.check_crc(pdu)
def test_build_recv():
mb = TestHelper()
pdu = mb.build_msg(1,3,0x300e,0x2)
assert pdu == b'\x01\x03\x30\x0e\x00\x02\xaa\xc8'
assert mb.check_crc(pdu)
call = 0
for key, update in mb.recv_resp(mb.db, b'\x01\x03\x04\x01\x2c\x00\x46\xbb\xf4', 'test'):
if key == 'grid':
assert update == True
elif key == 'inverter':
assert update == True
else:
assert False
call += 1
assert 2 == call

View File

@@ -6,6 +6,9 @@ from app.src.gen3plus.solarman_v5 import SolarmanV5
from app.src.config import Config from app.src.config import Config
from app.src.infos import Infos, Register from app.src.infos import Infos, Register
pytest_plugins = ('pytest_asyncio',)
# initialize the proxy statistics # initialize the proxy statistics
Infos.static_init() Infos.static_init()
@@ -54,6 +57,9 @@ class MemoryStream(SolarmanV5):
pass pass
return copied_bytes return copied_bytes
async def async_write(self, headline=''):
pass
def _SolarmanV5__flush_recv_msg(self) -> None: def _SolarmanV5__flush_recv_msg(self) -> None:
super()._SolarmanV5__flush_recv_msg() super()._SolarmanV5__flush_recv_msg()
self.msg_count += 1 self.msg_count += 1
@@ -725,7 +731,7 @@ def test_device_rsp(ConfigTsunInv1, DeviceRspMsg):
assert m.data_len == 0x0a assert m.data_len == 0x0a
assert m._recv_buffer==b'' assert m._recv_buffer==b''
assert m._send_buffer==b'' assert m._send_buffer==b''
assert m._forward_buffer==b'' # DeviceRspMsg assert m._forward_buffer==DeviceRspMsg
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0 assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0
m.close() m.close()
@@ -743,7 +749,7 @@ def test_inverter_rsp(ConfigTsunInv1, InverterRspMsg):
assert m.data_len == 0x0a assert m.data_len == 0x0a
assert m._recv_buffer==b'' assert m._recv_buffer==b''
assert m._send_buffer==b'' assert m._send_buffer==b''
assert m._forward_buffer==b'' # InverterRspMsg assert m._forward_buffer==InverterRspMsg
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0 assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0
m.close() m.close()
@@ -779,7 +785,7 @@ def test_heartbeat_rsp(ConfigTsunInv1, HeartbeatRspMsg):
assert m.data_len == 0x0a assert m.data_len == 0x0a
assert m._recv_buffer==b'' assert m._recv_buffer==b''
assert m._send_buffer==b'' assert m._send_buffer==b''
assert m._forward_buffer==b'' # HeartbeatRspMsg assert m._forward_buffer==HeartbeatRspMsg
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0 assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0
m.close() m.close()
@@ -820,7 +826,7 @@ def test_sync_start_rsp(ConfigTsunInv1, SyncStartRspMsg):
assert m.data_len == 0x0a assert m.data_len == 0x0a
assert m._recv_buffer==b'' assert m._recv_buffer==b''
assert m._send_buffer==b'' assert m._send_buffer==b''
assert m._forward_buffer==b'' # HeartbeatRspMsg assert m._forward_buffer==SyncStartRspMsg
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0 assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0
m.close() m.close()
@@ -856,7 +862,7 @@ def test_sync_end_rsp(ConfigTsunInv1, SyncEndRspMsg):
assert m.data_len == 0x0a assert m.data_len == 0x0a
assert m._recv_buffer==b'' assert m._recv_buffer==b''
assert m._send_buffer==b'' assert m._send_buffer==b''
assert m._forward_buffer==b'' # HeartbeatRspMsg assert m._forward_buffer==SyncEndRspMsg
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0 assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0
m.close() m.close()
@@ -942,7 +948,8 @@ def test_build_logger_modell(ConfigTsunAllowAll, DeviceIndMsg):
assert 'V1.1.00.0B' == m.db.get_db_value(Register.COLLECTOR_FW_VERSION, 0).rstrip('\00') assert 'V1.1.00.0B' == m.db.get_db_value(Register.COLLECTOR_FW_VERSION, 0).rstrip('\00')
m.close() m.close()
def test_AT_cmd(ConfigTsunAllowAll, DeviceIndMsg, DeviceRspMsg, AtCommandIndMsg): @pytest.mark.asyncio
async def test_AT_cmd(ConfigTsunAllowAll, DeviceIndMsg, DeviceRspMsg, AtCommandIndMsg):
ConfigTsunAllowAll ConfigTsunAllowAll
m = MemoryStream(DeviceIndMsg, (0,), True) m = MemoryStream(DeviceIndMsg, (0,), True)
m.read() m.read()
@@ -954,7 +961,7 @@ def test_AT_cmd(ConfigTsunAllowAll, DeviceIndMsg, DeviceRspMsg, AtCommandIndMsg)
m._send_buffer = bytearray(0) # clear send buffer for next test m._send_buffer = bytearray(0) # clear send buffer for next test
m._forward_buffer = bytearray(0) # clear send buffer for next test m._forward_buffer = bytearray(0) # clear send buffer for next test
m.send_at_cmd('AT+TIME=214028,1,60,120') await m.send_at_cmd('AT+TIME=214028,1,60,120')
assert m._recv_buffer==b'' assert m._recv_buffer==b''
assert m._send_buffer==AtCommandIndMsg assert m._send_buffer==AtCommandIndMsg
assert m._forward_buffer==b'' assert m._forward_buffer==b''

View File

@@ -3,6 +3,10 @@ import pytest, logging
from app.src.gen3.talent import Talent, Control from app.src.gen3.talent import Talent, Control
from app.src.config import Config from app.src.config import Config
from app.src.infos import Infos from app.src.infos import Infos
from app.src.modbus import Modbus
pytest_plugins = ('pytest_asyncio',)
# initialize the proxy statistics # initialize the proxy statistics
Infos.static_init() Infos.static_init()
@@ -19,6 +23,7 @@ class MemoryStream(Talent):
self.__chunk_idx = 0 self.__chunk_idx = 0
self.msg_count = 0 self.msg_count = 0
self.addr = 'Test: SrvSide' self.addr = 'Test: SrvSide'
self.send_msg_ofs = 0
def append_msg(self, msg): def append_msg(self, msg):
self.__msg += msg self.__msg += msg
@@ -50,6 +55,10 @@ class MemoryStream(Talent):
self.msg_count += 1 self.msg_count += 1
return return
async def async_write(self, headline=''):
pass
@pytest.fixture @pytest.fixture
def MsgContactInfo(): # Contact Info message def MsgContactInfo(): # Contact Info message
@@ -170,6 +179,35 @@ def MsgOtaAck(): # Over the air update rewuest from tsun cloud
def MsgOtaInvalid(): # Get Time Request message def MsgOtaInvalid(): # Get Time Request message
return b'\x00\x00\x00\x14\x10R170000000000001\x99\x13\x01' return b'\x00\x00\x00\x14\x10R170000000000001\x99\x13\x01'
@pytest.fixture
def MsgModbusCmd():
msg = b'\x00\x00\x00\x20\x10R170000000000001'
msg += b'\x70\x77\x00\x01\xa3\x28\x08\x01\x06\x20\x08'
msg += b'\x00\x00\x03\xc8'
return msg
@pytest.fixture
def MsgModbusRsp():
msg = b'\x00\x00\x00\x20\x10R170000000000001'
msg += b'\x91\x77\x17\x18\x19\x1a\x08\x01\x06\x20\x08'
msg += b'\x00\x00\x03\xc8'
return msg
@pytest.fixture
def MsgModbusInv():
msg = b'\x00\x00\x00\x20\x10R170000000000001'
msg += b'\x99\x77\x17\x18\x19\x1a\x08\x01\x06\x20\x08'
msg += b'\x00\x00\x03\xc8'
return msg
@pytest.fixture
def MsgModbusResp20():
msg = b'\x00\x00\x00\x45\x10R170000000000001'
msg += b'\x91\x77\x17\x18\x19\x1a\x2d\x01\x03\x28\x51'
msg += b'\x09\x08\xd3\x00\x29\x13\x87\x00\x3e\x00\x00\x01\x2c\x03\xb4\x00'
msg += b'\x08\x00\x00\x00\x00\x01\x59\x01\x21\x03\xe6\x00\x00\x00\x00\x00'
msg += b'\x00\x00\x00\x00\x00\x00\x00\xdb\x6b'
return msg
def test_read_message(MsgContactInfo): def test_read_message(MsgContactInfo):
m = MemoryStream(MsgContactInfo, (0,)) m = MemoryStream(MsgContactInfo, (0,))
@@ -740,3 +778,123 @@ def test_proxy_counter():
assert Infos.new_stat_data == {'proxy': True} assert Infos.new_stat_data == {'proxy': True}
assert 0 == m.db.stat['proxy']['Unknown_Msg'] assert 0 == m.db.stat['proxy']['Unknown_Msg']
m.close() m.close()
def test_msg_modbus_req(ConfigTsunInv1, MsgModbusCmd):
ConfigTsunInv1
m = MemoryStream(MsgModbusCmd, (0,), False)
m.db.stat['proxy']['Unknown_Ctrl'] = 0
m.db.stat['proxy']['Modbus_Command'] = 0
m.read() # read complete msg, and dispatch msg
assert not m.header_valid # must be invalid, since msg was handled and buffer flushed
assert m.msg_count == 1
assert m.id_str == b"R170000000000001"
assert m.unique_id == 'R170000000000001'
assert int(m.ctrl)==112
assert m.msg_id==119
assert m.header_len==23
assert m.data_len==13
assert m._forward_buffer==MsgModbusCmd
assert m._send_buffer==b''
assert m.db.stat['proxy']['Unknown_Ctrl'] == 0
assert m.db.stat['proxy']['Modbus_Command'] == 1
m.close()
def test_msg_modbus_rsp1(ConfigTsunInv1, MsgModbusRsp):
ConfigTsunInv1
m = MemoryStream(MsgModbusRsp, (0,), False)
m.db.stat['proxy']['Unknown_Ctrl'] = 0
m.db.stat['proxy']['Modbus_Command'] = 0
m.forward_modbus_resp = False
m.read() # read complete msg, and dispatch msg
assert not m.header_valid # must be invalid, since msg was handled and buffer flushed
assert m.msg_count == 1
assert m.id_str == b"R170000000000001"
assert m.unique_id == 'R170000000000001'
assert int(m.ctrl)==145
assert m.msg_id==119
assert m.header_len==23
assert m.data_len==13
assert m._forward_buffer==b''
assert m._send_buffer==b''
assert m.db.stat['proxy']['Unknown_Ctrl'] == 0
assert m.db.stat['proxy']['Modbus_Command'] == 0
m.close()
def test_msg_modbus_rsp2(ConfigTsunInv1, MsgModbusRsp):
ConfigTsunInv1
m = MemoryStream(MsgModbusRsp, (0,), False)
m.db.stat['proxy']['Unknown_Ctrl'] = 0
m.db.stat['proxy']['Modbus_Command'] = 0
m.forward_modbus_resp = True
m.read() # read complete msg, and dispatch msg
assert not m.header_valid # must be invalid, since msg was handled and buffer flushed
assert m.msg_count == 1
assert m.id_str == b"R170000000000001"
assert m.unique_id == 'R170000000000001'
assert int(m.ctrl)==145
assert m.msg_id==119
assert m.header_len==23
assert m.data_len==13
assert m._forward_buffer==MsgModbusRsp
assert m._send_buffer==b''
assert m.db.stat['proxy']['Unknown_Ctrl'] == 0
assert m.db.stat['proxy']['Modbus_Command'] == 0
m.close()
def test_msg_modbus_invalid(ConfigTsunInv1, MsgModbusInv):
ConfigTsunInv1
m = MemoryStream(MsgModbusInv, (0,), False)
m.db.stat['proxy']['Unknown_Ctrl'] = 0
m.db.stat['proxy']['Modbus_Command'] = 0
m.read() # read complete msg, and dispatch msg
assert not m.header_valid # must be invalid, since msg was handled and buffer flushed
assert m.msg_count == 1
assert m.id_str == b"R170000000000001"
assert m.unique_id == 'R170000000000001'
assert int(m.ctrl)==153
assert m.msg_id==119
assert m.header_len==23
assert m.data_len==13
assert m._forward_buffer==MsgModbusInv
assert m._send_buffer==b''
assert m.db.stat['proxy']['Unknown_Ctrl'] == 1
assert m.db.stat['proxy']['Modbus_Command'] == 0
m.close()
def test_msg_modbus_fragment(ConfigTsunInv1, MsgModbusResp20):
ConfigTsunInv1
# receive more bytes than expected (7 bytes from the next msg)
m = MemoryStream(MsgModbusResp20+b'\x00\x00\x00\x45\x10\x52\x31', (0,))
m.db.stat['proxy']['Unknown_Ctrl'] = 0
m.db.stat['proxy']['Modbus_Command'] = 0
m.forward_modbus_resp = True
m.mb.last_fcode = 3
m.mb.last_len = 20
m.mb.last_reg = 0x3008
m.read() # read complete msg, and dispatch msg
assert not m.header_valid # must be invalid, since msg was handled and buffer flushed
assert m.msg_count == 1
assert m.id_str == b"R170000000000001"
assert m.unique_id == 'R170000000000001'
assert int(m.ctrl)==0x91
assert m.msg_id==119
assert m.header_len==23
assert m.data_len==50
assert m._forward_buffer==MsgModbusResp20
assert m._send_buffer==b''
assert m.mb.err == 0
assert m.modbus_elms == 20-1 # register 0x300d is unknown, so one value can't be mapped
assert m.db.stat['proxy']['Unknown_Ctrl'] == 0
assert m.db.stat['proxy']['Modbus_Command'] == 0
m.close()
@pytest.mark.asyncio
async def test_msg_build_modbus_req(ConfigTsunInv1, MsgModbusCmd):
ConfigTsunInv1
m = MemoryStream(b'', (0,), False)
m.id_str = b"R170000000000001"
await m.send_modbus_cmd(Modbus.WRITE_SINGLE_REG, 0x2008, 0)
assert 0==m.send_msg_ofs
assert m._forward_buffer==b''
assert m._send_buffer==MsgModbusCmd
m.close()

View File

@@ -224,7 +224,7 @@ def test_send_inv_data(ClientConnection, MsgTimeStampReq, MsgTimeStampResp, MsgI
data = s.recv(1024) data = s.recv(1024)
except TimeoutError: except TimeoutError:
pass pass
# time.sleep(32.5) time.sleep(32.5)
# assert data == MsgTimeStampResp # assert data == MsgTimeStampResp
try: try:
s.sendall(MsgInvData) s.sendall(MsgInvData)