Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add support for Huawei inverters. #684

Open
JohanAlvedal opened this issue Feb 1, 2024 · 81 comments
Open

Please add support for Huawei inverters. #684

JohanAlvedal opened this issue Feb 1, 2024 · 81 comments
Assignees
Labels
enhancement New feature or request

Comments

@JohanAlvedal
Copy link

JohanAlvedal commented Feb 1, 2024

Please add support for Huawei inverters.

I use https://github.com/wlcrs/huawei_solar.
This integration exposes the information and functions made available by Huawei Solar inverters directly via one of its Modbus interfaces in Home Assistant.

And not to forget Nordpool
https://github.com/custom-components/nordpool/

example of sensors in HA

PV power W = sensor.inverter_input_power
Battery SOC = sensor.battery_state_of_capacity
Battery charge/discharge in W = sensor.battery_charge_discharge_power
Export sensor KWh = sensor.power_meter_exported (total)
Import (Grid) kWh = sensor.power_meter_consumption (total)

number.battery_maximum_charging_power
number.battery_maximum_discharging_power
select.battery_working_mode
number.battery_end_of_discharge_soc
number.battery_end_of_charge_soc

@springfall2008
Copy link
Owner

Can you attempt to take a sample configuration from 'templates' and try it with your sensors? I suspect you will need my help to control charging and discharging, its not obvious to me how these are triggered

@JohanAlvedal
Copy link
Author

Taken from the github link above:
The integration offers multiple services that you can call to dynamically change the behavior of the battery:

forcible_charge: Forcible Charge
forcible_charge_soc: Forcible Charge to a SoC level
forcible_discharge: Forcible Discharge
forcible_discharge_soc: Forcible Discharge to a SoC level
stop_forcible_charge: Stop the forcible charge or discharge
Forcible Charge

This allows you to forcibly charge your battery for a given duration or to a given SoC level of your battery. While a forcible charge is active, it will direct all power received from the solar panels to your battery instead of covering your home electricity usage.

If the "Charge from grid" toggle is set, it will also draw power from the grid until the given charge power level is reached.

Forcible Discharge

This allows you to forcibly discharge your battery for a given duration or to a given SoC level of your battery. This forces the inverter to inject more power to the AC-side than your home electricity usage, which will consequently be pushed onto the grid.

Stop Forcible charge or discharge

Calling this service will cancel any running forcible charge of forcible discharge command.

I have a reasonably functioning config. there will be no direct errors in the log as far as I can see. then of course it could be the wrong sensors I have, etc.

https://pastebin.pl/view/a70a067e

@springfall2008
Copy link
Owner

I've made some changes on a branch:

  1. Updated template - https://github.com/springfall2008/batpred/blob/huawei/templates/huawei.yaml

This has a new inverter type select HU and the services for charge/discharge defined

  1. Update predbat.py - https://github.com/springfall2008/batpred/blob/huawei/apps/predbat/predbat.py

Added code for the new inverter type and using the services.

Please give this a try, however for it to work you need to fix your load sensor otherwise its not going to do anything useful

@JohanAlvedal
Copy link
Author

Thank you very much, I will double check and get back to you.

@JohanAlvedal
Copy link
Author

`2024-02-05 21:50:03.612180 INFO pred_bat: Inverter 0 Stop charge via Service
2024-02-05 21:50:03.616484 INFO pred_bat: Inverter 0 Stop discharge via Service
2024-02-05 21:50:03.627270 WARNING HASS: Error calling Home Assistant service default/huawei_solar/stop_forcible_charge
2024-02-05 21:50:03.627592 WARNING HASS: Code: 500, error: 500 Internal Server Error

Server got itself in trouble
2024-02-05 21:50:03.637760 WARNING HASS: Error calling Home Assistant service default/huawei_solar/stop_forcible_charge
2024-02-05 21:50:03.638070 WARNING HASS: Code: 500, error: 500 Internal Server Error

Server got itself in trouble
2024-02-05 21:50:03.647732 INFO pred_bat: Will not recompute the plan, it is 5.0 minutes old and max age is 10 minutes
2024-02-05 21:50:03.648596 INFO pred_bat: IBoost model today updated to 0.364
2024-02-05 21:50:03.649539 INFO pred_bat: Completed run status Idle`

@springfall2008
Copy link
Owner

I must have the service name wrong, you can change it in apps.yaml if you can figure out the correct name

@springfall2008
Copy link
Owner

Okay I think I might know the issue, the service needs a device_id to be set.

Can you:

  1. Update predbat.py from the latest on the branch (https://github.com/springfall2008/batpred/blob/main/apps/predbat/predbat.py)
  2. add 'device_id: xxxxx' to your apps.yaml where the xxxxx is the device_id that Home Assistant reports. The best way to find it is to go into developer tools, services and try to trigger the stop charge service, then once it works to go to YAML mode and copy the device_id from there. Also please snapshot what you see there in case my attempt still doesn't work.

@JohanAlvedal
Copy link
Author

JohanAlvedal commented Feb 6, 2024

Did you remove "HU" from the latest predbat.py ?

I added it and then the errors in the log disappeared, kinda.

2024-02-06 10:49:00.459610 WARNING pred_bat: pred_bat: Entity sensor.predbat_HU_scheduled_charge_enable not found in namespace default 2024-02-06 10:49:00.459997 INFO AppDaemon: pred_bat: Entity sensor.predbat_HU_scheduled_charge_enable created in namespace: default 2024-02-06 10:49:00.466792 WARNING pred_bat: pred_bat: Entity sensor.predbat_HU_scheduled_discharge_enable not found in namespace default 2024-02-06 10:49:00.467225 INFO AppDaemon: pred_bat: Entity sensor.predbat_HU_scheduled_discharge_enable created in namespace: default 2024-02-06 10:49:00.473172 WARNING pred_bat: pred_bat: Entity sensor.predbat_HU_reserve not found in namespace default 2024-02-06 10:49:00.473689 INFO AppDaemon: pred_bat: Entity sensor.predbat_HU_reserve created in namespace: default 2024-02-06 10:49:00.479548 WARNING pred_bat: pred_bat: Entity sensor.predbat_HU_charge_limit not found in namespace default 2024-02-06 10:49:00.480066 INFO AppDaemon: pred_bat: Entity sensor.predbat_HU_charge_limit created in namespace: default 2024-02-06 10:49:00.485759 WARNING pred_bat: pred_bat: Entity sensor.predbat_HU_charge_rate not found in namespace default 2024-02-06 10:49:00.486206 INFO AppDaemon: pred_bat: Entity sensor.predbat_HU_charge_rate created in namespace: default 2024-02-06 10:49:00.491926 WARNING pred_bat: pred_bat: Entity sensor.predbat_HU_discharge_rate not found in namespace default 2024-02-06 10:49:00.492366 INFO AppDaemon: pred_bat: Entity sensor.predbat_HU_discharge_rate created in namespace: default 2024-02-06 10:49:00.498661 WARNING pred_bat: pred_bat: Entity sensor.predbat_HU_inverter_mode not found in namespace default 2024-02-06 10:49:00.499134 INFO AppDaemon: pred_bat: Entity sensor.predbat_HU_inverter_mode created in namespace: default 2024-02-06 10:49:00.504829 WARNING pred_bat: pred_bat: Entity sensor.predbat_HU_charge_start_time not found in namespace default 2024-02-06 10:49:00.505279 INFO AppDaemon: pred_bat: Entity sensor.predbat_HU_charge_start_time created in namespace: default 2024-02-06 10:49:00.511097 WARNING pred_bat: pred_bat: Entity sensor.predbat_HU_charge_end_time not found in namespace default 2024-02-06 10:49:00.511613 INFO AppDaemon: pred_bat: Entity sensor.predbat_HU_charge_end_time created in namespace: default 2024-02-06 10:49:00.517356 WARNING pred_bat: pred_bat: Entity sensor.predbat_HU_discharge_start_time not found in namespace default 2024-02-06 10:49:00.517861 INFO AppDaemon: pred_bat: Entity sensor.predbat_HU_discharge_start_time created in namespace: default 2024-02-06 10:49:00.523877 WARNING pred_bat: pred_bat: Entity sensor.predbat_HU_discharge_end_time not found in namespace default 2024-02-06 10:49:00.524444 INFO AppDaemon: pred_bat: Entity sensor.predbat_HU_discharge_end_time created in namespace: default

@springfall2008
Copy link
Owner

Sorry I gave you the wrong link you need to take predbat from the Huawei branch and not
From main

@gcoan
Copy link
Collaborator

gcoan commented Feb 6, 2024

however for it to work you need to fix your load sensor otherwise its not going to do anything useful

@JohanAlvedal if you don't have a native 'home load' sensor easily available in HA, there's the code for custom template to calculate home load from import, export, solar and battery data in the HA docs you could utilise
https://springfall2008.github.io/batpred/apps-yaml#data-from-givtcp

@JohanAlvedal
Copy link
Author

however for it to work you need to fix your load sensor otherwise its not going to do anything useful

@JohanAlvedal if you don't have a native 'home load' sensor easily available in HA, there's the code for custom template to calculate home load from import, export, solar and battery data in the HA docs you could utilise https://springfall2008.github.io/batpred/apps-yaml#data-from-givtcp

Made one now so I have to wait for some history.

@springfall2008
Copy link
Owner

@JohanAlvedal did you try the correct code here? with device_id set https://github.com/springfall2008/batpred/blob/huawei/apps/predbat/predbat.py

@JohanAlvedal
Copy link
Author

@JohanAlvedal did you try the correct code here? with device_id set https://github.com/springfall2008/batpred/blob/huawei/apps/predbat/predbat.py

Result of newest prebat.py

https://pastebin.pl/view/9a7685c4

@springfall2008
Copy link
Owner

You would need to move away from monitor mode and into control charge to see if it does anything

@JohanAlvedal
Copy link
Author

You would need to move away from monitor mode and into control charge to see if it does anything

https://pastebin.pl/view/025b0676

@springfall2008
Copy link
Owner

Hmm, odd error - can you go to 'settings, system, logfiles' and select appdeamon (or adddeamon-predbat) and then check for the full error at the end of this log and paste it here please?

@JohanAlvedal
Copy link
Author

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/lib/python3.11/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/lib/python3.11/site-packages/appdaemon/adapi.py", line 1752, in call_service
self._check_service(service)
File "/usr/lib/python3.11/site-packages/appdaemon/adapi.py", line 1579, in _check_service
if service.find("/") == -1:
^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'find'

2024-02-06 21:35:03.822087 WARNING pred_bat: ------------------------------------------------------------
2024-02-06 21:40:03.724586 WARNING pred_bat: ------------------------------------------------------------
2024-02-06 21:40:03.724732 WARNING pred_bat: Unexpected error in worker for App pred_bat:
2024-02-06 21:40:03.724837 WARNING pred_bat: Worker Ags: {'id': '2f9cb91f26b34c9f8125f68e37b1abdf', 'name': 'pred_bat', 'objectid': '52bbd711c5934b25b04ddaff81ad2496', 'type': 'scheduler', 'function': <bound method PredBat.run_time_loop of <predbat.PredBat object at 0x7f3af340f910>>, 'pin_app': True, 'pin_thread': 0, 'kwargs': {'interval': 300, 'random_start': 0, 'random_end': 0, '__thread_id': 'thread-0'}}
2024-02-06 21:40:03.724926 WARNING pred_bat: ------------------------------------------------------------
2024-02-06 21:40:03.726075 WARNING pred_bat: Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/appdaemon/threading.py", line 1022, in worker
funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"]))
File "/usr/lib/python3.11/site-packages/appdaemon/adbase.py", line 35, in f_app_lock
return f(*args, **kw)
^^^^^^^^^^^^^^
File "/config/apps/predbat.py", line 12003, in run_time_loop
raise e
File "/config/apps/predbat.py", line 11999, in run_time_loop
self.update_pred(scheduled=True)
File "/usr/lib/python3.11/site-packages/appdaemon/adbase.py", line 35, in f_app_lock
return f(*args, **kw)
^^^^^^^^^^^^^^
File "/config/apps/predbat.py", line 11037, in update_pred
status, status_extra = self.execute_plan()
^^^^^^^^^^^^^^^^^^^
File "/config/apps/predbat.py", line 9841, in execute_plan
inverter.adjust_charge_immediate(self.charge_limit_percent_best[0])
File "/config/apps/predbat.py", line 2452, in adjust_charge_immediate
self.base.call_service(self.base.get_arg("charge_start_service"), device_id=self.base.get_arg("device_id", index=self.id), target_soc=target_soc)
File "/usr/lib/python3.11/site-packages/appdaemon/utils.py", line 231, in inner_sync_wrapper
f = run_coroutine_threadsafe(self, coro(self, *args, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/appdaemon/utils.py", line 313, in run_coroutine_threadsafe
result = future.result(self.AD.internal_function_timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/lib/python3.11/site-packages/appdaemon/adapi.py", line 1752, in call_service
self._check_service(service)
File "/usr/lib/python3.11/site-packages/appdaemon/adapi.py", line 1579, in _check_service
if service.find("/") == -1:
^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'find'

2024-02-06 21:40:03.726209 WARNING pred_bat: ------------------------------------------------------------
2024-02-06 21:45:03.762781 WARNING pred_bat: ------------------------------------------------------------
2024-02-06 21:45:03.763146 WARNING pred_bat: Unexpected error in worker for App pred_bat:
2024-02-06 21:45:03.763319 WARNING pred_bat: Worker Ags: {'id': '2f9cb91f26b34c9f8125f68e37b1abdf', 'name': 'pred_bat', 'objectid': '52bbd711c5934b25b04ddaff81ad2496', 'type': 'scheduler', 'function': <bound method PredBat.run_time_loop of <predbat.PredBat object at 0x7f3af340f910>>, 'pin_app': True, 'pin_thread': 0, 'kwargs': {'interval': 300, 'random_start': 0, 'random_end': 0, '__thread_id': 'thread-0'}}
2024-02-06 21:45:03.763519 WARNING pred_bat: ------------------------------------------------------------
2024-02-06 21:45:03.764956 WARNING pred_bat: Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/appdaemon/threading.py", line 1022, in worker
funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"]))
File "/usr/lib/python3.11/site-packages/appdaemon/adbase.py", line 35, in f_app_lock
return f(*args, **kw)
^^^^^^^^^^^^^^
File "/config/apps/predbat.py", line 12003, in run_time_loop
raise e
File "/config/apps/predbat.py", line 11999, in run_time_loop
self.update_pred(scheduled=True)
File "/usr/lib/python3.11/site-packages/appdaemon/adbase.py", line 35, in f_app_lock
return f(*args, **kw)
^^^^^^^^^^^^^^
File "/config/apps/predbat.py", line 11037, in update_pred
status, status_extra = self.execute_plan()
^^^^^^^^^^^^^^^^^^^
File "/config/apps/predbat.py", line 9841, in execute_plan
inverter.adjust_charge_immediate(self.charge_limit_percent_best[0])
File "/config/apps/predbat.py", line 2452, in adjust_charge_immediate
self.base.call_service(self.base.get_arg("charge_start_service"), device_id=self.base.get_arg("device_id", index=self.id), target_soc=target_soc)
File "/usr/lib/python3.11/site-packages/appdaemon/utils.py", line 231, in inner_sync_wrapper
f = run_coroutine_threadsafe(self, coro(self, *args, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/appdaemon/utils.py", line 313, in run_coroutine_threadsafe
result = future.result(self.AD.internal_function_timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/lib/python3.11/site-packages/appdaemon/adapi.py", line 1752, in call_service
self._check_service(service)
File "/usr/lib/python3.11/site-packages/appdaemon/adapi.py", line 1579, in _check_service
if service.find("/") == -1:
^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'find'

2024-02-06 21:45:03.765711 WARNING pred_bat: ------------------------------------------------------------

@springfall2008
Copy link
Owner

What do you have in apps.yaml for 'charge_start_service' ?

@JohanAlvedal
Copy link
Author

charge_start_service:
service: huawei_solar/forcible_charge_soc
data:
target_soc: 100
power: "3000"

@JohanAlvedal
Copy link
Author

IMG_0322

@springfall2008
Copy link
Owner

No sorry in apps.yaml it should say:

charge_start_service: service: huawei_solar/forcible_charge_soc
device_id: XXXX

And you need to replace the XXXX with your device ID as per the above template

@JohanAlvedal
Copy link
Author

https://pastebin.pl/view/9172ef45

apps.yaml code

#Services to charge/discharge
charge_start_service:
service: huawei_solar/forcible_charge_soc
device_id: 6893ee838a0972bd3e50d9e0faa0ba5a

charge_stop_service:
service: huawei_solar/stop_forcible_charge
device_id: 6893ee838a0972bd3e50d9e0faa0ba5a

discharge_start_service:
service: huawei_solar/forcible_discharge_soc
device_id: 6893ee838a0972bd3e50d9e0faa0ba5a

discharge_stop_service:
service: huawei_solar/stop_forcible_charge
device_id: 6893ee838a0972bd3e50d9e0faa0ba5a

#Predbat, HA log

` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/lib/python3.11/site-packages/appdaemon/adapi.py", line 1752, in call_service
self._check_service(service)
File "/usr/lib/python3.11/site-packages/appdaemon/adapi.py", line 1579, in _check_service
if service.find("/") == -1:
^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'find'

2024-02-06 22:12:55.709484 WARNING pred_bat: ------------------------------------------------------------
2024-02-06 22:13:30.822254 WARNING pred_bat: ------------------------------------------------------------
2024-02-06 22:13:30.822428 WARNING pred_bat: Unexpected error in worker for App pred_bat:
2024-02-06 22:13:30.822533 WARNING pred_bat: Worker Ags: {'id': 'ac684c787a14409cafd0896086e6776f', 'name': 'pred_bat', 'objectid': 'e1f704e86c354964a1212ad9e1b4e6b9', 'type': 'scheduler', 'function': <bound method PredBat.update_time_loop of <predbat.PredBat object at 0x7f23ac9af690>>, 'pin_app': True, 'pin_thread': 0, 'kwargs': {'interval': 15, 'random_start': 0, 'random_end': 0, '__thread_id': 'thread-0'}}
2024-02-06 22:13:30.822620 WARNING pred_bat: ------------------------------------------------------------
2024-02-06 22:13:30.823769 WARNING pred_bat: Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/appdaemon/threading.py", line 1022, in worker
funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"]))
File "/usr/lib/python3.11/site-packages/appdaemon/adbase.py", line 35, in f_app_lock
return f(*args, **kw)
^^^^^^^^^^^^^^
File "/config/apps/predbat.py", line 11981, in update_time_loop
raise e
File "/config/apps/predbat.py", line 11976, in update_time_loop
self.update_pred(scheduled=False)
File "/usr/lib/python3.11/site-packages/appdaemon/adbase.py", line 35, in f_app_lock
return f(*args, **kw)
^^^^^^^^^^^^^^
File "/config/apps/predbat.py", line 11037, in update_pred
status, status_extra = self.execute_plan()
^^^^^^^^^^^^^^^^^^^
File "/config/apps/predbat.py", line 9841, in execute_plan
inverter.adjust_charge_immediate(self.charge_limit_percent_best[0])
File "/config/apps/predbat.py", line 2452, in adjust_charge_immediate
self.base.call_service(self.base.get_arg("charge_start_service"), device_id=self.base.get_arg("device_id", index=self.id), target_soc=target_soc)
File "/usr/lib/python3.11/site-packages/appdaemon/utils.py", line 231, in inner_sync_wrapper
f = run_coroutine_threadsafe(self, coro(self, *args, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/appdaemon/utils.py", line 313, in run_coroutine_threadsafe
result = future.result(self.AD.internal_function_timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/lib/python3.11/site-packages/appdaemon/adapi.py", line 1752, in call_service
self._check_service(service)
File "/usr/lib/python3.11/site-packages/appdaemon/adapi.py", line 1579, in _check_service
if service.find("/") == -1:
^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'find'

2024-02-06 22:13:30.823890 WARNING pred_bat: ------------------------------------------------------------
2024-02-06 22:15:03.818652 WARNING pred_bat: ------------------------------------------------------------
2024-02-06 22:15:03.818856 WARNING pred_bat: Unexpected error in worker for App pred_bat:
2024-02-06 22:15:03.819021 WARNING pred_bat: Worker Ags: {'id': 'a325f77312ec4a40a42917bbda943697', 'name': 'pred_bat', 'objectid': 'e1f704e86c354964a1212ad9e1b4e6b9', 'type': 'scheduler', 'function': <bound method PredBat.run_time_loop of <predbat.PredBat object at 0x7f23ac9af690>>, 'pin_app': True, 'pin_thread': 0, 'kwargs': {'interval': 300, 'random_start': 0, 'random_end': 0, '__thread_id': 'thread-0'}}
2024-02-06 22:15:03.819152 WARNING pred_bat: ------------------------------------------------------------
2024-02-06 22:15:03.820364 WARNING pred_bat: Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/appdaemon/threading.py", line 1022, in worker
funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"]))
File "/usr/lib/python3.11/site-packages/appdaemon/adbase.py", line 35, in f_app_lock
return f(*args, **kw)
^^^^^^^^^^^^^^
File "/config/apps/predbat.py", line 12003, in run_time_loop
raise e
File "/config/apps/predbat.py", line 11999, in run_time_loop
self.update_pred(scheduled=True)
File "/usr/lib/python3.11/site-packages/appdaemon/adbase.py", line 35, in f_app_lock
return f(*args, **kw)
^^^^^^^^^^^^^^
File "/config/apps/predbat.py", line 11037, in update_pred
status, status_extra = self.execute_plan()
^^^^^^^^^^^^^^^^^^^
File "/config/apps/predbat.py", line 9841, in execute_plan
inverter.adjust_charge_immediate(self.charge_limit_percent_best[0])
File "/config/apps/predbat.py", line 2452, in adjust_charge_immediate
self.base.call_service(self.base.get_arg("charge_start_service"), device_id=self.base.get_arg("device_id", index=self.id), target_soc=target_soc)
File "/usr/lib/python3.11/site-packages/appdaemon/utils.py", line 231, in inner_sync_wrapper
f = run_coroutine_threadsafe(self, coro(self, *args, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/appdaemon/utils.py", line 313, in run_coroutine_threadsafe
result = future.result(self.AD.internal_function_timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/lib/python3.11/site-packages/appdaemon/adapi.py", line 1752, in call_service
self._check_service(service)
File "/usr/lib/python3.11/site-packages/appdaemon/adapi.py", line 1579, in _check_service
if service.find("/") == -1:
^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'find'

2024-02-06 22:15:03.820551 WARNING pred_bat: ------------------------------------------------------------`

@springfall2008
Copy link
Owner

Sorry I'm maybe not being specific, the apps.yaml should say:

#Services to charge/discharge
device_id: 6893ee838a0972bd3e50d9e0faa0ba5a

charge_start_service: huawei_solar/forcible_charge_soc
charge_stop_service: huawei_solar/stop_forcible_charge
discharge_start_service: huawei_solar/forcible_discharge_soc
discharge_stop_service: huawei_solar/stop_forcible_charge

@JohanAlvedal
Copy link
Author

predbat.log
https://pastebin.pl/view/06a3d469

Addon log.
s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service base-addon-banner: starting


Add-on: appdaemon-predbat
Predbat pre-install in AppDaemon

Add-on version: 1.0.6
You are running the latest version of this add-on.
System: Home Assistant OS 11.5 (amd64 / generic-x86-64)
Home Assistant Core: 2024.1.6
Home Assistant Supervisor: 2024.01.1

Please, share the above information when looking for help
or support in, e.g., GitHub, forums or the Discord chat.

s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service init-appdaemon: starting
s6-rc: info: service init-appdaemon successfully started
s6-rc: info: service appdaemon: starting
s6-rc: info: service appdaemon successfully started
s6-rc: info: service legacy-services: starting
[00:49:32] INFO: Starting AppDaemon...
s6-rc: info: service legacy-services successfully started

HA core log
Logger: homeassistant.helpers.service
Source: helpers/service.py:246
First occurred: 01:17:09 (8 occurrences)
Last logged: 06:00:41

Referenced entities switch.predbat_load_filter_modal are missing or not currently available
Referenced entities switch.predbat_set_status_notify are missing or not currently available
Referenced entities switch.predbat_set_inverter_notify are missing or not currently available
Referenced entities switch.predbat_set_reserve_enable are missing or not currently available

@springfall2008
Copy link
Owner

Can you actually try trigger a force charge and a force discharge to a target SOC in Developer Tools/Services and then send me the YAML for both of them (if they actually work)?

@springfall2008
Copy link
Owner

I think I might have to add 'power', if so what value?

@JohanAlvedal
Copy link
Author

I think I might have to add 'power', if so what value?

Charge night time 4500w
Charge day 2500w
Discharge 1500-2000w

@JohanAlvedal
Copy link
Author

IMG_0327
IMG_0326
IMG_0325
IMG_0324
IMG_0323

@springfall2008
Copy link
Owner

Do the above all work okay when you hit 'call service'?

It seems that we need to add power, what's the maximum power?

@springfall2008
Copy link
Owner

@JohanAlvedal
Copy link
Author

Did you try changing your reserve min to 12% as above and re-test? = yes, I run now and have to wait for the result. but have been away for a couple of days when I ran a different flow then.

No, you didn't miss anything. What is expected to happen when it goes to idle? Should it continue to drain the battery? Because then my question is if there is any difference between discharege and idle?

I am a little unsure if my inverter's Maximize self consumption mode is the same as what you call eco mode. It discharges all the time as long as there is some % in the battery,

@springfall2008
Copy link
Owner

Ah okay there is a terminology difference here, so 'idle' in Predbat means ECO Mode in GE inverter which is when the battery covers the house load. This is different from what it calls Discharge which is when you export to the grid at maximum rate.

@JohanAlvedal
Copy link
Author

the problem right now is that if it should charge to 33% as an example. Then it charges to 33%, stops charging, then automatically starts discharging for a while and then charges to 33% again, etc., etc. the only way to make the battery stop discharging is to set number.battery_maximum_discharging_power to 0.
Unfortunately, huawei_solar.stop_forcible_charge in combination with work mode Maximize self consumption does not help

@springfall2008
Copy link
Owner

the problem right now is that if it should charge to 33% as an example. Then it charges to 33%, stops charging, then automatically starts discharging for a while and then charges to 33% again, etc., etc. the only way to make the battery stop discharging is to set number.battery_maximum_discharging_power to 0. Unfortunately, huawei_solar.stop_forcible_charge in combination with work mode Maximize self consumption does not help

That's progress, if its working then as the next step I can add this to the code :)

Did you have to change the apps.yaml any further?

@JohanAlvedal
Copy link
Author

Same thing with hold charge, there are two options as far as I can see. Either set (number.battery_maximum_discharging_power) to 0w or change workmode to (select.battery_working_mode) to time_of_use_luna2000 and then go to maximize_self_consumption to discharge the battery.

my apps.yaml

https://justpaste.it/7iexm

@JohanAlvedal
Copy link
Author

Same thing with hold charge, there are two options as far as I can see. Either set (number.battery_maximum_discharging_power) to 0w or change workmode to (select.battery_working_mode) to time_of_use_luna2000 and then go to maximize_self_consumption to discharge the battery.

my apps.yaml

https://justpaste.it/7iexm

Or wait it's wrong with hold mode if you set it to always load in TOU (time_of_use_luna2000) then it's best to stay in Work mode: maximize_self_consumption and set number.battery_maximum_discharging_power to 0 W Then it should stay there

@springfall2008
Copy link
Owner

I think your apps.yaml has an error, shouldn't charge/discharge rate be set as follows:

charge_rate:
- number.battery_maximum_charging_power
discharge_rate:
- number.battery_maximum_discharging_power

Have you tried turning off 'set_charge_freeze'? The reason it doesn't work is you have the reserve hard wired at 12 rather than set in a way that Predbat can change it. Normally in charge freeze the reserve is set to the current battery level to avoid the discharging, mosty as setting discharge power to 0 with GE inverters doesn't totally prevent discharge.

Can you try with set_charge_freeze off and also correct the above? Then please share a logfile?

@JohanAlvedal
Copy link
Author

JohanAlvedal commented Feb 18, 2024

I think your apps.yaml has an error, shouldn't charge/discharge rate be set as follows:

charge_rate: - number.battery_maximum_charging_power discharge_rate: - number.battery_maximum_discharging_power

Have you tried turning off 'set_charge_freeze'? The reason it doesn't work is you have the reserve hard wired at 12 rather than set in a way that Predbat can change it. Normally in charge freeze the reserve is set to the current battery level to avoid the discharging, mosty as setting discharge power to 0 with GE inverters doesn't totally prevent discharge.

Can you try with set_charge_freeze off and also correct the above? Then please share a logfile?

Aha let me change and restart. set_charge_freeze was off, but Set Discharge Freeze Only is on

@JohanAlvedal
Copy link
Author

@springfall2008
Copy link
Owner

So far looks like, see how it goes...

@JohanAlvedal
Copy link
Author

Hello
Unfortunately, it is the same as before. After a charging session, it discharges a few percent, and then charges to the target of, for example, 100% over and over again.
Charging the battery seems to work fine but if it should be hold or when it gets up to its target that it should "stay" as long as the % is not expected to drop or discharge.
So to make this work, number.battery_maximum_discharging_power must be set to 0 on hold charge or when the charge % target has been reached.
Now predbat insists on changing number.battery_maximum_discharging_power to 3500 all the time so I have to manually change predbat to monitor mode and then to number.battery_maximum_discharging_power 0

pred1
99
100

@springfall2008
Copy link
Owner

Okay thanks for testing, I'll make a change to use discharging power as a next step.

@springfall2008
Copy link
Owner

Can you try this version which should disable the discharge during charge periods? https://github.com/springfall2008/batpred/blob/huawei/apps/predbat/predbat.py

@JohanAlvedal
Copy link
Author

Can you try this version which should disable the discharge during charge periods? https://github.com/springfall2008/batpred/blob/huawei/apps/predbat/predbat.py

Good, I'll try and get back to you tomorrow

@JohanAlvedal
Copy link
Author

Unfortunately, it was the same as before. It insists on setting number.battery_maximum_discharging_power to 3500W.
You can see how it has behaved since 05:00 this morning in the attached image and log file. In the end I set it to 0 and put predbat in monitor mode

Skärmavbild 2024-02-20 kl  06 31 28

https://justpaste.it/fv4fb

@springfall2008 springfall2008 self-assigned this Feb 20, 2024
springfall2008 added a commit that referenced this issue Feb 20, 2024
@springfall2008
Copy link
Owner

So I thin what's happening is your inverter turns off charging once the target is reached rather than holding it there.

I've tried to make another update to the same file to turn off discharging while the charge happens and not just when it finishes:

https://github.com/springfall2008/batpred/blob/huawei/apps/predbat/predbat.py

Can you please try this one?

@springfall2008 springfall2008 added the enhancement New feature or request label Feb 20, 2024
@JohanAlvedal
Copy link
Author

So I thin what's happening is your inverter turns off charging once the target is reached rather than holding it there.

I've tried to make another update to the same file to turn off discharging while the charge happens and not just when it finishes:

https://github.com/springfall2008/batpred/blob/huawei/apps/predbat/predbat.py

Can you please try this one?

Exactly like that but with the result that it immediately discharges.

Ok I'll try again with the new one

@JohanAlvedal
Copy link
Author

Now it looks like it's working, I'll leave it for a few days and get back to you.

One thing that I react to is all the notifications, I have inverter notify on and had over 50 notifications since I went to bed last night.

@springfall2008
Copy link
Owner

That's good news. I'd certainly turn off inverter notification once it's working

@JohanAlvedal
Copy link
Author

Just saw this, though it seems to work.

https://justpaste.it/9lhwr

springfall2008 added a commit that referenced this issue Feb 25, 2024
* Disable discharge during charge if inverter doesn't have a reserve hold method

* Stop discharge during charge

#684

* [pre-commit.ci lite] apply automatic fixes

---------

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
@springfall2008
Copy link
Owner

I think I see the issue it tried to discharge to 4% but your min reserve is 14%, maybe a bug?

@springfall2008
Copy link
Owner

I think you need to set 'battery_min_soc' to 14 in your apps.yaml

@JohanAlvedal
Copy link
Author

The sensor that controls the end of discharge is number.battery_end_of_discharge_soc
A bit unsure of what happened but last night it didn't charge the battery as planned but maybe that changed last night?

https://justpaste.it/cwo6n

@springfall2008
Copy link
Owner

I think you need to set 'battery_min_soc' to 14 in your apps.yaml

Did you make this change?

@JohanAlvedal
Copy link
Author

I had already entered it.

  charge_rate:
    - number.battery_maximum_charging_power
  discharge_rate:
    - number.battery_maximum_discharging_power
  battery_power:
    - sensor.battery_charge_discharge_power
  pv_power:
    - sensor.inverter_input_power
  load_power:
    - sensor.power_meter_active_power
  soc_percent:
    - sensor.battery_state_of_capacity
  soc_max:
   - 10
  charge_limit:
   - number.battery_end_of_charge_soc
  reserve:
   - 12
  battery_min_soc:
   - 14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants