Skip to content

Automation examples

HAEdwin edited this page Jan 12, 2026 · 6 revisions

I collected some automations that might help you. The YAML scripts can be copied to the clipboard and simply pasted in the screen where you started a new automation (just press Ctrl+V there). Then you can use the UI of edit the YAML to adapt it to your own entities/devices.

Restart ECU-B or ECU-C

This automation was build for ECU-B and/or ECU-R (2160) owners who use a smart-plug to restart the ECU when it repeatedly refuses connections. When the cache-count is at a certain stage the smart-plug will turn the ECU off and on again after 15 seconds.

alias: Reboot ECU-B when needed
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.ecu_216300123456_using_cache_counter
    above: 2
conditions: []
actions:
  - action: switch.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: switch.smartplug_ecu
  - action: persistent_notification.create
    metadata: {}
    data:
      message: ECU-B is being restarted
  - delay:
      hours: 0
      minutes: 0
      seconds: 15
      milliseconds: 0
  - action: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: switch.smartplug_ecu
mode: single

Grid Zero Control

This automation was build for ECU-R-Pro (2162) owners who have a DSMR entity. It consists out of a custom made sensor and an automation but might need some customization to suit your needs because it was not tested yet. What it does:

  • Runs every 5 seconds

  • Keeps grid power between −50 W and +50 W

  • Adjusts inverter output in small steps

  • Both inverters always get the same power

  • Never exceeds 0–500 W

  • Automatically reduces output when exporting

This avoids oscillation and works well with real-world meter latency.

Custom sensor

- sensor:
    - name: "Power usage"
      unique_id: my_power_usage
      unit_of_measurement: "W"
      state: >
        {{ states('sensor.electricity_meter_power_consumption')|int(0)
           - states('sensor.electricity_meter_power_production')|int(0) }}

Automation

alias: Grid Zero Control
mode: single
trigger:
  - platform: time_pattern
    seconds: "/5"

variables:
  power: "{{ states('sensor.power_usage') | int(0) }}"
  deadband: 50
  step: 20
  current: "{{ states('input_number.inverter_target_power') | int(0) }}"

action:
  - choose:
      # Importing from grid → increase inverter output
      - conditions:
          - condition: template
            value_template: "{{ power > deadband }}"
        sequence:
          - service: input_number.set_value
            data:
              entity_id: input_number.inverter_target_power
              value: "{{ [current + step, 500] | min }}"

      # Exporting to grid → reduce inverter output
      - conditions:
          - condition: template
            value_template: "{{ power < -deadband }}"
        sequence:
          - service: input_number.set_value
            data:
              entity_id: input_number.inverter_target_power
              value: "{{ [current - step, 0] | max }}"

  # Apply target power equally to both inverters
  - service: number.set_value
    data:
      entity_id:
        - number.inverter_{inverter-ID}_maxpwr
        - number.inverter_{inverter-ID}_maxpwr
      value: "{{ states('input_number.inverter_target_power') | int(0) }}"

Clone this wiki locally