Solar forecast Battery state of charge - time of use - trigger issue

Hello ALL.

I have tried and tried and tried for weeks and weeks to no avail. So I am turning to the comminunity for help.

I have a Solar PV system with 10kw battery based in the UK where sunshine is intermittent.

I have an EV time of use Electricity plan which provides cheap energy between 12am - 5am dailiy.

I use Solar Assistant app on a Raspberry Pi 4 to monitor the inverter via MQQT and pass this data into HomeAssistant. HA can write changes back to the inverter via this method with no issue.

I am trying to get an automation to work with the follwoing logic:

  1. Trigger events at cheap energy window 12am-5am (*tw) for the duration of this window.

  2. Look at the Forcast.Solar - forcast PV energy for Tomorrow - If this is between X and Y KwH

IF(a) 1+2 above = TRUE

Then >


bSoC between X% and Y%

[check the Battery State of Charge I have a entity for this]


  1. change the state of two device entities on the inverter:

    q - Charge Source Priority - 3 options
    r - output source priority - 3 option

[r&q state triggers the battery to charge]

(s) loop round the section IF(b) every minute (t) within the (tw) time window unitl bSoC Test = FALSE


   q - Charge Source Priority - 3 options 
   r - output source priority - 3 option

[above will stop the mains AC charging]


A) I can get section 1) & 2) and 3) to change the two options q and r based on the first bSoC test. this okay.

I am having the issue with the loop at setion (s) to send the test back round again after 1min between the time window to check the bSoC.

I am having the issue getting the condition to loop back round and check the bSoc again later based on time (to save the resources on the infinite loop). to pole if the bSoC has risen between X or Y%.

B) is there a HAC integration that can resolve this for me without the condition code?

Any help will be grately appreciated.

you should post the code that you have so far.