springfall2008 / batpred

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

Predbat does not call discharge_stop_service #926

Open jacekowski opened 2 months ago

jacekowski commented 2 months ago

I've been working on integrating predbat with my sunsynk inverter and i've found what i think might be a bug

In this line charge_stop_service is being called instead of discharge_stop_service, is this intentional for some reason (so charge_stop_service is supposed to stop both discharge and charge) or is it a typo? https://github.com/springfall2008/batpred/blob/3b5ffa6fa838cc95e47b360cfe01aad2a575a497/apps/predbat/predbat.py#L3759

springfall2008 commented 2 months ago

This is actually by design in that the stop is the same for charge or discharge, is it not in your case?

jacekowski commented 2 months ago

Not with my inverter. I'm got a sunsynk inverter, so i'm running some node red between it and predbat to make things actually happen (i've actually started with pv opt which led to some design choices, but i also need some other workarounds for inverter quirks).

Alternatively ability to call service with multiple entity id's would also work (with example below only first entity will be passed to actual service call):

  charge_stop_service:
      service: switch.turn_off
      entity_id:.
        - "switch.schedule_charge"
        - "switch.schedule_discharge"
springfall2008 commented 2 months ago

Not with my inverter. I'm got a sunsynk inverter, so i'm running some node red between it and predbat to make things actually happen (i've actually started with pv opt which led to some design choices, but i also need some other workarounds for inverter quirks).

Alternatively ability to call service with multiple entity id's would also work (with example below only first entity will be passed to actual service call):

  charge_stop_service:
      service: switch.turn_off
      entity_id:.
        - "switch.schedule_charge"
        - "switch.schedule_discharge"

This is certainly doable add I could add it.

That said, you can just make an automation in HA which does this and then have Predbat trigger the automation as the service.

It's also worth pointing out that Predbat can control the scheduled charge and discharge switch directly if you configure them in apps.yaml and enable it in the inverter configuration

springfall2008 commented 2 months ago

That said scheduled charge means to the time window configured, so you will need to make sure the time window is set from Predbat too.

jacekowski commented 2 months ago

I've realised that after spending some time diagnosing why things are not working as expected.

I have also disabled service api for now and things seem to work.

It would be nice if predbat could provide time and date (using time & date integration) instead of just time for charge/discharge window or instead of "schedule charge/discharge" have "charge/discharge now"

On my inverter (sunsynk) there is no way to schedule charge/discharge (it has scheduling, but it is limited to what can be done as setting needed to discharge/charge is a global setting not one that is changed with a schedule) so i have node-red adjusting settings as needed when needed.

bensebborn commented 2 months ago

I just use the charge/discharge now and don’t use windows. Works well on Sunsynk.