olivergregorius / sun2000_modbus

Library for reading Huawei Sun2000 inverter metrics via Modbus TCP
MIT License
23 stars 9 forks source link

standardize registers on W for all that dont have kW in their name, add disconnect method #19

Closed daniel309 closed 1 year ago

daniel309 commented 1 year ago

Few minor changes

Test are clean:

python3 -m unittest discover -v
test_decode_bitfield16 (test_sun2000_modbus.TestDataTypes) ... ok
test_decode_bitfield32 (test_sun2000_modbus.TestDataTypes) ... ok
test_decode_int16_be (test_sun2000_modbus.TestDataTypes) ... ok
test_decode_int32_be (test_sun2000_modbus.TestDataTypes) ... ok
test_decode_invalid (test_sun2000_modbus.TestDataTypes) ... ok
test_decode_multidata (test_sun2000_modbus.TestDataTypes) ... ok
test_decode_string (test_sun2000_modbus.TestDataTypes) ... ok
test_decode_uint16_be (test_sun2000_modbus.TestDataTypes) ... ok
test_decode_uint32_be (test_sun2000_modbus.TestDataTypes) ... ok
test_connect_fail (test_sun2000_modbus.TestSun2000) ... ERROR:root:Connection to inverter failed
ok
test_connect_success (test_sun2000_modbus.TestSun2000) ... INFO:root:Successfully connected to inverter
ok
test_init (test_sun2000_modbus.TestSun2000) ... ok
test_read_bitfield16 (test_sun2000_modbus.TestSun2000) ... INFO:root:Successfully connected to inverter
ok
test_read_formatted_bitfield16 (test_sun2000_modbus.TestSun2000) ... INFO:root:Successfully connected to inverter
ok
test_read_formatted_uint32be (test_sun2000_modbus.TestSun2000) ... INFO:root:Successfully connected to inverter
ok
test_read_formatted_with_mapping (test_sun2000_modbus.TestSun2000) ... INFO:root:Successfully connected to inverter
ok
test_read_range_from_disconnected_unit (test_sun2000_modbus.TestSun2000) ... ERROR:root:Connection to inverter failed
ok
test_read_range_from_unavailable_unit (test_sun2000_modbus.TestSun2000) ... INFO:root:Successfully connected to inverter
ERROR:root:A connection error occurred
ok
test_read_range_returns_range_of_register_values (test_sun2000_modbus.TestSun2000) ... INFO:root:Successfully connected to inverter
ok
test_read_range_with_both_quantity_and_end_address_defined (test_sun2000_modbus.TestSun2000) ... INFO:root:Successfully connected to inverter
ok
test_read_range_with_end_address_not_being_greater_than_start_address (test_sun2000_modbus.TestSun2000) ... INFO:root:Successfully connected to inverter
ok
test_read_range_with_no_right_border (test_sun2000_modbus.TestSun2000) ... INFO:root:Successfully connected to inverter
ok
test_read_range_with_quantity_set_to_0 (test_sun2000_modbus.TestSun2000) ... INFO:root:Successfully connected to inverter
ok
test_read_raw_value_bitfield16 (test_sun2000_modbus.TestSun2000) ... INFO:root:Successfully connected to inverter
ok
test_read_raw_value_string (test_sun2000_modbus.TestSun2000) ... INFO:root:Successfully connected to inverter
ok
test_read_raw_value_string_connection_unexpectedly_closed (test_sun2000_modbus.TestSun2000) ... INFO:root:Successfully connected to inverter
ERROR:root:A connection error occurred
ok
test_read_raw_value_string_from_disconnected_unit (test_sun2000_modbus.TestSun2000) ... ERROR:root:Connection to inverter failed
ok
test_read_raw_value_string_from_unavailable_unit (test_sun2000_modbus.TestSun2000) ... INFO:root:Successfully connected to inverter
ERROR:root:Inverter unit did not respond
ok
test_read_raw_value_uint16be (test_sun2000_modbus.TestSun2000) ... INFO:root:Successfully connected to inverter
ok
test_read_raw_value_uint32be (test_sun2000_modbus.TestSun2000) ... INFO:root:Successfully connected to inverter
ok
test_read_raw_value_with_mapping (test_sun2000_modbus.TestSun2000) ... INFO:root:Successfully connected to inverter
ok
test_read_returns_float (test_sun2000_modbus.TestSun2000) ... INFO:root:Successfully connected to inverter
ok
test_read_uint32be (test_sun2000_modbus.TestSun2000) ... INFO:root:Successfully connected to inverter
ok

----------------------------------------------------------------------
Ran 33 tests in 0.002s

OK
olivergregorius commented 1 year ago

I'm currently on sickness-leave, will need a few days to come up with this review.

daniel309 commented 1 year ago

totally overlooked unit test fixes. done now:

python3 -m unittest discover tests
.........ERROR:root:Connection to inverter failed
.......ERROR:root:Connection to inverter failed
.ERROR:root:A connection error occurred
..ERROR:root:Connection to inverter failed
.ERROR:root:Connection to inverter failed
.ERROR:root:Connection to inverter failed
.ERROR:root:Connection to inverter failed
...ERROR:root:A connection error occurred
.ERROR:root:Connection to inverter failed
.ERROR:root:Inverter unit did not respond
......
----------------------------------------------------------------------
Ran 33 tests in 0.002s

OK
daniel309 commented 1 year ago

@olivergregorius can you please re-start workflow? tests should be all clean now

olivergregorius commented 1 year ago

Sry for the delay, approved and merged.