Skip to content

Solax Automations

Logic

We have a strategy selector updating our helper entity. These automations are realizing the strategy towards the solax. Remember the Self Use Mode that we are using as setup in the components? That will be our No action strategy. There are however few cases there we want to hande the invertor with remote control. If you want to truly understand, please read docs.

Handled situations:

  • Charging
  • Discharge
  • Sell to grid
  • No action
  • Automatic control disabled

The charge, discharge, sell to grid and no action automations act only while binary_sensor.emhass_publish_stale is off, which means the EMHASS data is current, see the publish watchdog on the Pyscripts page. With stale data, or after a restart before the first ok publish, they send nothing even with the control enabled. The inverter keeps the last command until its autorepeat duration ends, then returns to its normal mode, the Self Use Mode. When the publish is ok again they run right away. Turning the control off still works at any time.

Configuration.yaml

Uncomment this section.

automation: !include_dir_list automations
script: !include scripts.yaml
scene: !include scenes.yaml

Automations

Create a folder with the automations is /config/automations

alias: Charge the batter either from the grid or pv - 10m
description: "Charge"
triggers:
  - trigger: time_pattern
    minutes: "/10"
  - trigger: state
    entity_id: input_boolean.automatic_invertor_control_enabled
  - trigger: state
    entity_id: input_select.invertor_strategy
  # Run right away when the EMHASS publish is ok again
  - trigger: state
    entity_id: binary_sensor.emhass_publish_stale
    to: "off"

condition:
  - condition: state
    entity_id: input_boolean.automatic_invertor_control_enabled
    state: "on"
  - condition: state
    entity_id: input_select.invertor_strategy
    state: "Charge"
  # Only with current EMHASS data: off = publish ok, on = stale, missing after a restart
  # until the first check. Without a command the inverter returns to Self Use
  # when the autorepeat duration of the last command ends.
  - condition: state
    entity_id: binary_sensor.emhass_publish_stale
    state: "off"

# Charge from the grid, by enabling the battery to only import, this means that all will go from the grid
# not sure about some negative scenarios

action:
  - service: select.select_option
    data:
      option: Enabled Battery Control
    target:
      entity_id:
        - select.solax_remotecontrol_power_control
  - service: number.set_value
    data:
      value: "{{ (states('sensor.p_batt_forecast') | float / 100) | round(0) * 100 }}"
    target:
      entity_id: number.solax_remotecontrol_active_power
  - service: number.set_value
    data:
      value: "606"
    target:
      entity_id: number.solax_remotecontrol_autorepeat_duration
  - service: number.set_value
    data:
      value: 12000
    target:
      entity_id: number.solax_remotecontrol_import_limit
  - service: button.press
    data: {}
    target:
      entity_id: button.solax_remotecontrol_trigger
mode: single
alias: Discharge the battery to the grid or to the house load 
description: ""
triggers:
  - trigger: time_pattern
    minutes: "/10"
  - trigger: state
    entity_id: input_boolean.automatic_invertor_control_enabled
  - trigger: state
    entity_id: input_select.invertor_strategy
  # Run right away when the EMHASS publish is ok again
  - trigger: state
    entity_id: binary_sensor.emhass_publish_stale
    to: "off"
condition:
  - condition: state
    entity_id: input_boolean.automatic_invertor_control_enabled
    state: "on"
  - condition: state
    entity_id: input_select.invertor_strategy
    state: "Discharge"
  # Only with current EMHASS data: off = publish ok, on = stale, missing after a restart
  # until the first check. Without a command the inverter returns to Self Use
  # when the autorepeat duration of the last command ends.
  - condition: state
    entity_id: binary_sensor.emhass_publish_stale
    state: "off"

# Discharge the battery, this is reasonably 

action:
  - service: select.select_option
    data:
      option: Enabled Battery Control
    target:
      entity_id:
        - select.solax_remotecontrol_power_control
  - service: number.set_value
    data:
      value: "{{ - ((states('sensor.p_batt_forecast') | float / 100) | int) * 100 }}"
    target:
      entity_id: number.solax_remotecontrol_active_power
  - service: number.set_value
    data:
      value: "606"
    target:
      entity_id: number.solax_remotecontrol_autorepeat_duration
  - service: number.set_value
    data:
      value: 12000
    target:
      entity_id: number.solax_remotecontrol_import_limit
  - service: button.press
    data: {}
    target:
      entity_id: button.solax_remotecontrol_trigger
mode: single
alias: Sell no store - 10m
description: ""
triggers:
  - trigger: time_pattern
    minutes: "/10"
  - trigger: state
    entity_id: input_boolean.automatic_invertor_control_enabled
  - trigger: state
    entity_id: input_select.invertor_strategy
  # Run right away when the EMHASS publish is ok again
  - trigger: state
    entity_id: binary_sensor.emhass_publish_stale
    to: "off"

condition:
  - condition: state
    entity_id: input_boolean.automatic_invertor_control_enabled
    state: "on"
  - condition: state
    entity_id: input_select.invertor_strategy
    state: "Sell to grid"
  # Only with current EMHASS data: off = publish ok, on = stale, missing after a restart
  # until the first check. Without a command the inverter returns to Self Use
  # when the autorepeat duration of the last command ends.
  - condition: state
    entity_id: binary_sensor.emhass_publish_stale
    state: "off"
#
# this is the only way to force the safe selling, this forces the battery to not charge.
# but you can still push energy in and out (in case of some fuckup).
# low load cases
#
# with E_BATTERY_CONTROL
# positive -> charge
# negative -> discharge
# 0 no battery
#
action:
  - service: select.select_option
    data:
      option: Enabled Battery Control
    target:
      entity_id:
        - select.solax_remotecontrol_power_control
  - service: number.set_value
    data:
      value: "0"
    target:
      entity_id: number.solax_remotecontrol_active_power
  - service: number.set_value
    data:
      value: "606"
    target:
      entity_id: number.solax_remotecontrol_autorepeat_duration
  - service: number.set_value
    data:
      value: 12000
    target:
      entity_id: number.solax_remotecontrol_import_limit
  - service: button.press
    data: {}
    target:
      entity_id: button.solax_remotecontrol_trigger
mode: single
alias: No action - 10s
description: ""
triggers:
  - trigger: time_pattern
    minutes: "/10"
  - trigger: state
    entity_id: input_boolean.automatic_invertor_control_enabled
  - trigger: state
    entity_id: input_select.invertor_strategy
  # Run right away when the EMHASS publish is ok again
  - trigger: state
    entity_id: binary_sensor.emhass_publish_stale
    to: "off"

condition:
  - condition: state
    entity_id: input_boolean.automatic_invertor_control_enabled
    state: "on"
  - condition: state
    entity_id: input_select.invertor_strategy
    state: "No action"
  # Only with current EMHASS data: off = publish ok, on = stale, missing after a restart
  # until the first check. Without a command the inverter returns to Self Use
  # when the autorepeat duration of the last command ends.
  - condition: state
    entity_id: binary_sensor.emhass_publish_stale
    state: "off"
#
# this is the only way to force the safe selling, this forces the battery to not charge.
# but you can still push energy in and out (in case of some fuckup).
# low load cases
#
# with E_BATTERY_CONTROL
# positive -> charge
# negative -> discharge
# 0 no battery
#
action:
  - service: select.select_option
    data:
      option: Enabled Battery Control
    target:
      entity_id:
        - select.solax_remotecontrol_power_control
  - service: number.set_value
    data:
      value: "0"
    target:
      entity_id: number.solax_remotecontrol_active_power
  - service: number.set_value
    data:
      value: "10"
    target:
      entity_id: number.solax_remotecontrol_autorepeat_duration
  - service: number.set_value
    data:
      value: 12000
    target:
      entity_id: number.solax_remotecontrol_import_limit
  - service: button.press
    data: {}
    target:
      entity_id: button.solax_remotecontrol_trigger
mode: single
alias: No action - 10s
description: ""
triggers:
  - trigger: state
    entity_id: input_boolean.automatic_invertor_control_enabled
condition:
  - condition: state
    entity_id: input_boolean.automatic_invertor_control_enabled
    state: "off"

action:
  - service: select.select_option
    data:
      option: Enabled Battery Control
    target:
      entity_id:
        - select.solax_remotecontrol_power_control
  - service: number.set_value
    data:
      value: "0"
    target:
      entity_id: number.solax_remotecontrol_active_power
  - service: number.set_value
    data:
      value: "10"
    target:
      entity_id: number.solax_remotecontrol_autorepeat_duration
  - service: number.set_value
    data:
      value: 12000
    target:
      entity_id: number.solax_remotecontrol_import_limit
  - service: button.press
    data: {}
    target:
      entity_id: button.solax_remotecontrol_trigger
mode: single

Please setup these automations and you are quite good to go!!!

If you set up the publish.yaml automation and the publish_data shell command from an earlier version of this guide, delete both. em.py publishes the EMHASS data every 5 minutes and watches that it works, see the Pyscripts page. With both in place EMHASS gets two publishes at the same moment.