Savings Session Automation - nathanmarlor/foxess_modbus GitHub Wiki

This is a fairly basic automation that operates on a "set and forget" basis. Hopefully this will help you guys out there who - like me - sometimes forget to turn off the force discharge cycle the next day!

How does it work?

Savings Session Card

  1. Enable the automation (if not on already - you can keep it on permanently if you want - my OCD leads me to turn it off...)
  2. Turn on the main On/Off toggle
  3. If required, turn on the pre-charge toggle
  4. Set the pre-charge start time - this bit is fairly common sense - if you want to pre-charge for 30 mins, set it to 30 mins before the start of the savings session and if you don't want a pre-charge, simply set it for a few mins before the savings session start time
  5. Set the savings session start and end time.
  6. and relax... the automation will trigger at the pre-charge start time and turn itself off at the savings session end time.

Savings Session Automation


Step 1

To begin, you need the Foxess Modbus integration and have at least version v1.10.1 installed.

This version includes the new Force Charge and Force Discharge work modes that I will be using with this automation.


Step 2

Next, you'll need 5 basic helpers to support the automation.

  1. Main on/off toggle - toggle helper named "Savings Session On/Off"
  2. Pre-charge on/off toggle - toggle helper named "Savings Session Pre-charge On/Off"
  3. Pre-charge start time - datetime helper (set to time) named "Savings Session Pre-Charge Start"
  4. Session start time - datetime helper (set to time) named "Savings Session Start"
  5. Session end time - datetime helper (set to time) named "Savings Session End"

Savings Session Helpers


Step 3

Next, you'll need to create a new automation.

Open a new blank automation, switch to YAML view and then copy and paste the code in the link below into the automation.

After you've copied the code - switch back to visual editor mode - then make sure work mode steps are pointing at your own Foxeess Modbus integration.

alias: Savings Session Automation
description: ""
trigger:
  - platform: time
    at: input_datetime.savings_session_pre_charge_start
condition:
  - condition: state
    entity_id: input_boolean.savings_session_on_off
    state: "on"
action:
  - if:
      - condition: state
        entity_id: input_boolean.savings_session_pre_charge_on_off
        state: "on"
    then:
      - device_id: 6be5bb4feedac189c5bf85cac8ea83f0
        domain: select
        entity_id: 42f2d324789f519b902c3aa15cbb5e32
        type: select_option
        option: Force Charge
      - service: input_boolean.turn_off
        data: {}
        target:
          entity_id: input_boolean.savings_session_pre_charge_on_off
  - wait_for_trigger:
      - platform: time
        at: input_datetime.savings_session_start
  - device_id: 6be5bb4feedac189c5bf85cac8ea83f0
    domain: select
    entity_id: 42f2d324789f519b902c3aa15cbb5e32
    type: select_option
    option: Force Discharge
  - wait_for_trigger:
      - platform: time
        at: input_datetime.savings_session_end
  - device_id: 6be5bb4feedac189c5bf85cac8ea83f0
    domain: select
    entity_id: 42f2d324789f519b902c3aa15cbb5e32
    type: select_option
    option: Self Use
  - service: input_boolean.turn_off
    target:
      entity_id:
        - input_boolean.savings_session_on_off
    data: {}
mode: single

Savings Session Automation 2


Step 4

Once you've created and saved the automation - you can now create the card for your dashboard using the yaml code below.

type: entities
entities:
  - entity: automation.savings_session_automation
  - entity: input_boolean.savings_session_on_off
  - entity: input_boolean.savings_session_pre_charge_on_off
  - entity: input_datetime.savings_session_pre_charge_start
  - entity: input_datetime.savings_session_start
  - entity: input_datetime.savings_session_end
title: Savings Sessions Settings
show_header_toggle: false
state_color: true

Savings Session Card


As mentioned, this automation is fairly basic but very easy to customise to your taste. It switches back to Self Use at the end but you could easily edit the automation to have it switch to any other modes which suits you, for example. There may be cleverer ways to automate this process - I am experimenting with the Octopus integration to try and use the information there to further automate the process - but for most, this automation will strike a reasonable balance between automation and control.

Any feedback, errors, questions - please feel free to contact me on Facebook DM or here.