britkat1980 / giv_tcp

TCP connection (from inverter) and MQTT implementation
71 stars 32 forks source link

Crash using setDischargeSlot1 #167

Open springfall2008 opened 5 months ago

springfall2008 commented 5 months ago

I'm seeing a dump when using setDIschargeSlot1 when I include the 'dischargeToPercent' setting:

2024-01-27 12:34:48,061 - Inv1 - app - [ERROR ] - Exception on /setDischargeSlot1 [POST] Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 2529, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1825, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib/python3.10/site-packages/flask_cors/extension.py", line 176, in wrapped_function return cors_after_request(app.make_response(f(*args, kwargs))) File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1823, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1799, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(view_args) File "/app/GivTCP_1/REST.py", line 120, in setDischrgSlot1 return wr.setDischargeSlot(payload) File "/app/GivTCP_1/write.py", line 678, in setDischargeSlot result=setBatteryReserve(payload) File "/app/GivTCP_1/write.py", line 508, in setBatteryReserve target=int(payload['reservePercent']) KeyError: 'reservePercent'

springfall2008 commented 5 months ago

What I actually want to do is change Discharge Target SOC 1 which is one of the new registers, but doing this in a way that still doesn't break older systems.

See: https://github.com/springfall2008/batpred/issues/644