Open andreondra opened 2 years ago
Hi @andreondra,
Don't know if will be relevant for this, but mocking the server could be a hard part... I'm working on a proxy for the Sermatec inverter, I could code some way to ask the proxy to answer defined response on requests ...
Your component => Proxy (several sockets opened, in memory data mutualisation) => Sermatec inverter or nothing (mock mode)
But yes, unit test will be a nice add to this critical part ^_^
Hello,
the proxy would be very helpful! The inverter's built-in server is really dumb and can't reliably handle more than 1 client. And as you said, it could be used for mocking the API for testing purposes - which would solve this issue.
The proxy in the mock mode would also allow to develop the Home Assistant integration when the inverter is unavailable for testing (e.g. on the go).
So if you need any help, let me know!
hi @andreondra,
Just tested your new version, seems working on my SMT-5K-TL-LV
:
/app # python3 -m sermatec_inverter 10.5.1.1 get batteryStatus
Connecting to Sermatec at 10.5.1.1:8899...OK
Getting data...
[1/3] Command 0x0a response data malformed.
{'battery_voltage': {'unit': 'V', 'value': 48.4}, 'battery_current': {'unit': 'A', 'value': 0.0}, 'battery_temperature': {'unit': 'C', 'value': 15.9}, 'battery_soc': {'value': 19}, 'battery_soh': {'value': 99}, 'charge_and_discharge_status': {'value': 'stand-by'}, 'battery_max_charging_current': {'unit': 'A', 'value': 130.0}, 'battery_max_discharging_current': {'unit': 'A', 'value': 130.0}, 'charge_cut_off_voltage': {'unit': 'V', 'value': 53.2}, 'discharge_cut_off_voltage': {'unit': 'V', 'value': 45.0}, 'charge_discharge_times': {'value': 0}, 'battery_pressure': {'value': 0}, 'battery_warning': {'value': 0}, 'battery_error': {'value': 0}, 'battery_communication_connection_status': {'value': 'OK'}}
Disconnecting...OK
/app # python3 -m sermatec_inverter 10.5.1.1 get batteryStatus --raw
usage: sermatec_inverter [-h] [--port PORT] [-v] [--protocolFilePath PROTOCOLFILEPATH] ip {get,set,customget} ...
sermatec_inverter: error: unrecognized arguments: --raw
/app # python3 -m sermatec_inverter 10.5.1.1 --port 8899 get batteryStatus
Connecting to Sermatec at 10.5.1.1:8899...OK
Getting data...
{'battery_voltage': {'unit': 'V', 'value': 48.4}, 'battery_current': {'unit': 'A', 'value': 0.0}, 'battery_temperature': {'unit': 'C', 'value': 15.9}, 'battery_soc': {'value': 19}, 'battery_soh': {'value': 99}, 'charge_and_discharge_status': {'value': 'stand-by'}, 'battery_max_charging_current': {'unit': 'A', 'value': 130.0}, 'battery_max_discharging_current': {'unit': 'A', 'value': 130.0}, 'charge_cut_off_voltage': {'unit': 'V', 'value': 53.2}, 'discharge_cut_off_voltage': {'unit': 'V', 'value': 45.0}, 'charge_discharge_times': {'value': 0}, 'battery_pressure': {'value': 0}, 'battery_warning': {'value': 0}, 'battery_error': {'value': 0}, 'battery_communication_connection_status': {'value': 'OK'}}
Disconnecting...OK
/app # python3 -m sermatec_inverter 10.5.1.1 get batteryStatus
Connecting to Sermatec at 10.5.1.1:8899...OK
Getting data...
{'battery_voltage': {'unit': 'V', 'value': 48.4}, 'battery_current': {'unit': 'A', 'value': 0.0}, 'battery_temperature': {'unit': 'C', 'value': 15.9}, 'battery_soc': {'value': 19}, 'battery_soh': {'value': 99}, 'charge_and_discharge_status': {'value': 'stand-by'}, 'battery_max_charging_current': {'unit': 'A', 'value': 130.0}, 'battery_max_discharging_current': {'unit': 'A', 'value': 130.0}, 'charge_cut_off_voltage': {'unit': 'V', 'value': 53.2}, 'discharge_cut_off_voltage': {'unit': 'V', 'value': 45.0}, 'charge_discharge_times': {'value': 0}, 'battery_pressure': {'value': 0}, 'battery_warning': {'value': 0}, 'battery_error': {'value': 0}, 'battery_communication_connection_status': {'value': 'OK'}}
Disconnecting...OK
There is an error that shown firstly, is there an auto-retry ?
Hello @mathieupotier,
thanks for testing 😀. Yes, I implemented some basic auto-retry. The message means that the first attempt failed, the second one turned up successful. Probably it isn't very clear from the message.
I'll do some more feature updates and hopefully integrate this new version to the home assistant integration.
Details: use
unittest
and maybetox
.