Automating Inverter Operation - TonyM1958/HA-FoxESS-Modbus GitHub Wiki

Set Work Mode

If you are using this Home Assistant integration, you can automate changing the work mode using the example yaml code below.

If you are using a different integration, the setup will be different - always check for information specific to your integration.

  • Go to Settings, Automations and click on CREATE AUTOMATION and select 'Create new automation'
  • Click the 3 dots in the top right hand corner and select 'Edit in YAML'
  • Delete the default YAML code and then copy and paste the following code. This changes Self Use to Feed In First, triggered at 11am:
alias: Set Feed In First at 11am
description: Change inverter work mode to Feed In First
trigger:
  - platform: time
    at: "11:00:00"
action:
  - service: modbus.write_register
    data:
      hub: FoxESSInverterModbus
      address: 41000
      slave: 247
      value: 1
mode: single
  • Click Save

  • Click RENAME to set the name of the automation

  • Click the arrow at the top left hand corner to return to Automations

  • Repeat this process, using the following code to create an automation that changes Feed In First to Self Use, triggered at 7pm:

alias: Set Self Use at 7pm
description: Change inverter work mode to Self Use at 7pm
trigger:
  - platform: time
    at: "19:00:00"
action:
  - service: modbus.write_register
    data:
      hub: FoxESSInverterModbus
      address: 41000
      slave: 247
      value: 0
mode: single

Click on an automation to change the time or add further conditions etc.

If you want to manually change work mode outside the set times, just go to Settings, Automations and click on the 3 dots and select Run.

Trigger Force Charge or Force Discharge

The integration includes a facility to manually trigger Force Charge or Force Discharge for a period of time (without setting a schedule or a charge time), like this:

image

You set the Time and Power values and simply flip the Remote Enable to ON to start or OFF to stop the command. This section describes how to set this up.

This uses the inverter remote control Modbus registers:

  • 44000: Remote Control Enable - this is set to 1 to enable remote control and 0 to disable remote control
  • 44001: Remote Control Time - this is the time period in seconds that the command will run for
  • 44002: Remote Control Power - this is the power (in Watts) that the inverter will output (when +ve) or input (when -ve). The output power will come from solar or the battery and the input power will be used to charge the battery. Setting this value starts the time period.

This automation starts a remote control command:

alias: Remote Control Start
description: Start remote control charge / discharge
triggers:
- trigger: state
  entity_id:
  - input_boolean.remote_enable
  from: 'off'
  to: 'on'
conditions: []
actions:
- data:
    hub: FoxESSInverterModbus
    address: 44000
    slave: 247
    value: 1
  action: modbus.write_register
- data:
    hub: FoxESSInverterModbus
    address: 44001
    slave: 247
    value: '{% set seconds = (states(''input_number.remote_time'') | int(default=1))
      * 60 %} {{ seconds }}'
  action: modbus.write_register
- data:
    hub: FoxESSInverterModbus
    address: 44002
    slave: 247
    value: '{% set power = (states(''input_number.remote_power'') | float(default=0)
      * 1000) | int %} {{ (65536 + power) if power < 0 else power }}'
  action: modbus.write_register
mode: single

This automation stops a remote control command:

alias: Remote Control Stop
description: Stop remote control command
triggers:
- trigger: state
  entity_id:
  - input_boolean.remote_enable
  from: 'on'
  to: 'off'
conditions: []
actions:
- data:
    hub: FoxESSInverterModbus
    address: 44000
    slave: 247
    value: 0
  action: modbus.write_register
mode: single

The 'Remote Time' and 'Remote Power' values are set using Input Numbers:

remote_time:
  # remote control time setting in minutes
  name: Remote Time
  mode: box
  max: 300
  min: 1
  step: 1
remote_power:
  # remote control power setting in kW
  name: Remote Power
  mode: box
  max: 6.0
  min: -6.0
  step: 0.1

'Remote Enable' is a button to turn remote control ON and OFF and is an Input Boolean:

remote_enable:
  name: Remote Enable

'Remote Setting' is a template that reads the input numbers and formats them for display.