springfall2008 / batpred

Home battery prediction and charging automation for Home Assistant, supporting many inverter types
https://springfall2008.github.io/batpred/
123 stars 43 forks source link

Solax (SX4) inverter config.py appears to be incorrect for service call method #1478

Open jefft4 opened 3 weeks ago

jefft4 commented 3 weeks ago

Describe the bug I configured my SX4 inverter to use the service calls, as direct modbus control from predbat wasn't working. The service calls are also not working - no actions from predbat in the HA history at all.

This seems to be because config.py for the SX4 type says 'has_service_api' is false. If I read the code correctly, that means that these service calls will never be used, it'll be trying to use charge_control_immediate, which calls enable_charge_discharge_with_time_current and tries to set time periods.

Expected behavior Looks like two variants of the SX4 might be needed, unless predbat can handle having two ways to control the inverter and selecting whichever is defined - (1) has_service_api = true and (2) has_service_api = false.

Predbat version 8.4.8

Environment details SolaX X1 Hybrid G4 with battery Home Assistant container on Ubuntu 22.04 Predbat in docker

springfall2008 commented 3 weeks ago

Please try 'main' which will now call the service if its configured in apps.yaml, I removed has_service_api from apps.yaml totally.

jefft4 commented 2 weeks ago

I'm getting this in the log - "Warn: Inverter 0 unable to find service template for charge_start_service" - only for charge_start_service, not the others - but it does appear to have started charging. Definitions (lifted from the UI):

charge_start_service
service : input_select.select_option
entity_id   : input_select.solar_control_mode
option  : Charge

charge_stop_service
service : input_select.select_option
entity_id   : input_select.solar_control_mode
option  : Stop Charge

discharge_start_service
service : input_select.select_option
entity_id   : input_select.solar_control_mode
option  : Self-use

(Can't get at apps.yaml directly at the moment because of a Windows problem crashing all my SSH clients!)

jefft4 commented 2 weeks ago

The log in full:

0413    2024-09-30 15:05:03.385730: Warn: Inverter 0 unable to find service template for charge_start_service
10412   2024-09-30 15:05:03.382258: Inverter 0 Call service input_select/select_option with data {'entity_id': 'input_select.solar_control_mode', 'option': 'Charge'}
10411   2024-09-30 15:05:03.382236: Inverter 0 Call service template charge_start_service = {'service': 'input_select.select_option', 'entity_id': 'input_select.solar_control_mode', 'option': 'Charge'}

I may have spoken too soon about control working, too - the plan shows hold charge from 15:00 and we're still in charge mode as of 15:11. Failed to switch out of charge at 16:00 too, when the plan says discharge.

Also have this in the log just now:


12941   2024-09-30 16:00:15.416094: Error: strptime() argument 1 must be str, not dict
12940   2024-09-30 16:00:15.416030: Info: record_status Error: Exception raised strptime() argument 1 must be str, not dict
12938   TypeError: strptime() argum ent 1 must be str, not dict
12937   ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12936   time_pressed = datetime .strptime(self.base.get_state_wrapper(entity_id, refresh=True), TIME_FORMAT_SECONDS)
12935   File "/config/inverter.py ", line 2039, in press_and_poll_button
12934   self.press_and_poll_but ton(entity_id)
12933   File "/config/inverter.py ", line 2005, in adjust_charge_window
12932   inverter.adjust_charge_ window(charge_start_time, charge_end_time, self.minutes_now)
12931   File "/config/predbat.py" , line 8579, in execute_plan
12930   ^^^^^^^^^^^^^^^^^^^
12929   status, status_extra = self.execute_plan()
12928   File "/config/predbat.py" , line 10009, in update_pred
12927   self.update_pred(schedu led=True)
12926   File "/config/predbat.py" , line 11238, in run_time_loop
12925   2024-09-30 16:00:15.409055: Error: Traceback (most recent call last):
12924   2024-09-30 16:00:15.405948: Error: Exception raised strptime() argument 1 must be str, not dict
``` ... still trying to press the 'send' button even though it's using service calls, perhaps?