batpred icon indicating copy to clipboard operation
batpred copied to clipboard

Add an override control to have specific SoC by specific time

Open stevedundee2 opened this issue 3 months ago • 7 comments

Is your feature request related to a problem? Please describe. Under Predbat control, my house battery often starts the day with a very low SoC. This is fine but sometimes (e.g. when I have visitors staying over who will use a lot of hot water in the morning) I know that I need a full battery first thing.

Describe the solution you'd like A clear and concise description of what you want to happen. ** Controls that let me specify a charge level (probably 100%) by a particular time (in my case 5.30 when peak rates start).

Describe alternatives you've considered I am trying setting "select.predbat_manual_charge" tonight, telling predbat to force charging from 2.30 to 5.30. The resulting plan suggests this will do the trick but I'll need to set it again each day before visitors stay over.

I've looked at creating a help toggle and automation to set "select.predbat_manual_charge" but I can't see how to multi select the entity.

But this control is not ideal anyway because I could be in charge mode too early etc.

Additional context

stevedundee2 avatar Oct 29 '25 12:10 stevedundee2

Here's the bit of automation code to manually set a charge for a number of blocks of time:

alias: Force overnight charge
description: Using predbat_manual_api
triggers:
 - trigger: time
    at:
      - "23:00:00"
conditions: []
actions:
  - alias: Charge batteries from 4am to 6am
   action: select.select_option
    target:
      entity_id:
       - select.predbat_manual_charge
    data:
      option: >-
         04:00:00,04:30:00,05:00:00,05:30:00
mode: single

Alternatively you could use select.predbat_manual_load_adjust to tell predbat that you want to adjust the load for specific time periods so it will automatically charge the battery in anticipation of that load

gcoan avatar Oct 29 '25 14:10 gcoan

Thanks for the (quickly provided) suggestions!

I'll try an automation that couples a time trigger like yours with a helper toggle being "on" to set up the manual charge daily. And another to clear the field when the toggle goes "off".

Adjusting the load would be more precise but I think too hard to use accurately so may as well just go with manual charging.

A target SoC at time would be the ideal because the charging could potentially be done for less time but I suppose over the year the requirement doesn't come up often and the saving would be small.

Steve

stevedundee2 avatar Oct 29 '25 15:10 stevedundee2

Hi Steve

I think it's still worth leaving this as a feature request, it could definitely be useful.

How easy it is to deliver this into the predbat "engine", I don't know !

But a charging automation is simple to implement for now

gcoan avatar Oct 29 '25 21:10 gcoan

Interestingly, when I set the manual charge for the slots starting between 02.30:00 and 05.00:00, predbat adds a charge for an hour at midnight so that my session is mostly predicted to be holding the charge at 100%. It's reversible: if I clear the manual charge then this extra charge disappears too, and comes back when I set the manual charge again. Just a curiosity, not a problem to me.

stevedundee2 avatar Oct 29 '25 23:10 stevedundee2

This is actually supported underneath for the bad weather alerts so could be added.

springfall2008 avatar Nov 02 '25 18:11 springfall2008

This is actually supported underneath for the bad weather alerts so could be added.

Whilst you are looking at the meteo alarm code Trefor, could you look at https://github.com/springfall2008/batpred/issues/2062 I have left the weather alarm config commented out because I couldn't risk Predbat crashing in the event of an internet failure when trying to access meteoalarm

gcoan avatar Nov 02 '25 19:11 gcoan

That's good news, Trefor. Thanks.

For anyone wanting to do this meantime, I used the following automations successfully over the long weekend.

The main automation aims to ensure a full battery (the triggers mean it sets up when the helper input_boolean.sk_ensure_full_battery_in_the_morning is toggled on or at 10pm if that helper is currently on).

description: ""
triggers:
  - trigger: time
    at: "22:00:00"
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
  - trigger: state
    entity_id:
      - input_boolean.sk_ensure_full_battery_in_the_morning
    from: "off"
    to: "on"
conditions:
  - condition: state
    entity_id: input_boolean.sk_ensure_full_battery_in_the_morning
    state: "on"
actions:
  - action: select.select_option
    metadata: {}
    data:
      option: 02:30:00,03:00:00,03:30:00,04:00:00,04:30:00,05:00:00
    target:
      entity_id: select.predbat_manual_charge
mode: single

And when no longer needed:

description: ""
triggers:
  - trigger: state
    entity_id:
      - input_boolean.sk_ensure_full_battery_in_the_morning
    to: "off"
conditions: []
actions:
  - action: select.select_option
    metadata: {}
    data:
      option: "off"
    target:
      entity_id: select.predbat_manual_charge
mode: single

stevedundee2 avatar Nov 03 '25 12:11 stevedundee2

The days selection for these example automations has changed. The time component now has a three character day and the seconds have been removed. So the format has to be (eg Fri 23:00). On the basis that the day changes, I updated one of the automations as such:

alias: Force overnight charge
description: Using predbat_manual_api
triggers:
  - trigger: time
    at: "23:15:00"
actions:
  - alias: Charge batteries from 23:30 to 05:30
    action: select.select_option
    target:
      entity_id:
        - select.predbat_manual_charge
    data:
      option: >-
        {{ now().strftime("%A")[:3] }} 23:30,{{
        (now()+timedelta(days=1)).strftime("%A")[:3] }} 00:00,{{
        (now()+timedelta(days=1)).strftime("%A")[:3] }} 00:30,{{
        (now()+timedelta(days=1)).strftime("%A")[:3] }} 01:00,{{
        (now()+timedelta(days=1)).strftime("%A")[:3] }} 01:30,{{
        (now()+timedelta(days=1)).strftime("%A")[:3] }} 02:00,{{
        (now()+timedelta(days=1)).strftime("%A")[:3] }} 02:30,{{
        (now()+timedelta(days=1)).strftime("%A")[:3] }} 03:00,{{
        (now()+timedelta(days=1)).strftime("%A")[:3] }} 03:30,{{
        (now()+timedelta(days=1)).strftime("%A")[:3] }} 04:00,{{
        (now()+timedelta(days=1)).strftime("%A")[:3] }} 04:30,{{
        (now()+timedelta(days=1)).strftime("%A")[:3] }} 05:00
mode: single

DrJohnM61 avatar Nov 29 '25 09:11 DrJohnM61

The days selection for these example automations has changed. The time component now has a three character day and the seconds have been removed. So the format has to be (eg Fri 23:00).

Yes and no

The override selection was changed to include the day, but following feedback from lots of people whose automations that set certain activities every day broke, Trefor changed it so you can still use the time only via the API. I think the seconds have gone though.

I've not upgraded to that version yet, and the documentation lags, but it should not require day to be added

gcoan avatar Nov 29 '25 10:11 gcoan

I'd missed the last few comments. As you say the seconds have gone (my automation failed silently to set the field), and you do not need to set the day, though it appears in the field, which is fine as it will get cleared off overnight and need resetting anyway.

stevedundee2 avatar Dec 06 '25 13:12 stevedundee2