E3DC in Energy Dashboard

oh my god, I didn’t follow the “think before you post” order. Sorry for the now self-explanatory stupid question. :pensive:

But can someone still explain to me why I can’t select the solar power?

Hi, everyone,

I was able to solve my problems. After the system got a bit confused during my exercises, I set it up again with the following configuration and it works. Important, patience: the values are only displayed after approx. 2 hours. And also important: the configuration of the energy dashboard has moved from settings to settings → dashboard.

configuration.yaml

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

  # Name of the location where Home Assistant is running
  name: Home
  # Location required to calculate the time the sun rises and sets
  latitude: 48.306766
  longitude: 11.200741
  # Impacts weather/sunrise data (altitude above sea level in meters)
  elevation: 510
  # metric for Metric, imperial for Imperial
  unit_system: metric
  # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  time_zone: Europe/Berlin

# Text to speech
tts:
  - platform: google_translate

homeassistant:
  packages: !include_dir_named packages/

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
homematic: !include services/homematic.yaml

# Auslagern der Sensordaten in ein Datenbank auf einem NAS (MariaDB)
recorder:
  db_url: mysql://hassio:[email protected]:3307/Homeassistant?charset=utf8mb4

/config/packages/binary_sensor.yaml

binary_sensor:
  - platform: template
    sensors:
      e3dc_emergency_power_possible:
        friendly_name: "E3DC Emergency Power possible"
        value_template: "{{ states('sensor.e3dc_ems_state')|int|bitwise_and(4) > 0 }}"
      e3dc_battery_loading_blocked:
        friendly_name: "E3DC Battery loading blocked"
        value_template: "{{ states('sensor.e3dc_ems_state')|int|bitwise_and(1) > 0 }}"
      e3dc_battery_unloading_blocked:
        friendly_name: "E3DC Battery unloading blocked"
        value_template: "{{ states('sensor.e3dc_ems_state')|int|bitwise_and(2) > 0 }}"
      e3dc_weather_based_loading:
        friendly_name: "E3DC weather based loading limiter"
        value_template: "{{ states('sensor.e3dc_ems_state')|int|bitwise_and(8) > 0 }}"
      e3dc_power_limiter:
        friendly_name: "E3DC power limiter"
        value_template: "{{ states('sensor.e3dc_ems_state')|int|bitwise_and(16) > 0 }}"
      e3dc_smartcharge_loading_blocked:
        friendly_name: "E3DC SmartCharge loading blocked"
        value_template: "{{ states('sensor.e3dc_ems_state')|int|bitwise_and(32) > 0 }}"
      e3dc_smartcharge_unloading_blocked:
        friendly_name: "E3DC SmartCharge unloading blocked"
        value_template: "{{ states('sensor.e3dc_ems_state')|int|bitwise_and(64) > 0 }}"
      e3dc_emergency_power_active:
        friendly_name: "E3DC Emergency Power Mode Active"
        value_template: "{{ is_state('sensor.e3dc_emergency_power_state', '1') }}"
      e3dc_emergency_power_available:
        friendly_name: "E3DC Emergency Power Available"
        value_template: "{{ is_state('sensor.e3dc_emergency_power_state', '1') or is_state('sensor.e3dc_emergency_power_state', '2') }}"
        device_class: "power"

/config/packages/e3dc.yaml

modbus:
- name: e3dc
  type: tcp
  host: 192.168.2.39
  port: 502
  sensors:
    - name: E3DC solar power
      data_type: int16
      unit_of_measurement: W
      address: 40067
      device_class: power
      state_class: measurement
    - name: E3DC battery power
      data_type: int16
      unit_of_measurement: W
      address: 40069
      device_class: power
      state_class: measurement
    - name: E3DC battery soc
      unit_of_measurement: '%'
      address: 40082
      data_type: uint16
      device_class: battery
    - name: E3DC power consumption
      data_type: int16
      unit_of_measurement: W
      address: 40071
      device_class: power
      state_class: measurement
    - name: E3DC grid power
      data_type: int16
      unit_of_measurement: W
      address: 40073
      device_class: power
      state_class: measurement
    - name: E3DC emergency power state
      address: 40083
      data_type: uint16
    - name: E3DC EMS state
      address: 40084
      data_type: uint16
    - name: E3DC autarky and consumption
      data_type: uint16
      address: 40081
    - name: E3DC string 1 power
      data_type: uint16
      address: 40101
      device_class: power
      unit_of_measurement: W
      state_class: measurement
    - name: E3DC string 2 power
      data_type: uint16
      address: 40102
      device_class: power
      unit_of_measurement: W
      state_class: measurement
    - name: E3DC powermeter 1 L1
      data_type: int16
      address: 40105
      device_class: power
      unit_of_measurement: W
    - name: E3DC powermeter 1 L2
      data_type: int16
      address: 40106
      device_class: power
      unit_of_measurement: W
    - name: E3DC powermeter 1 L3
      data_type: int16
      address: 40107
      device_class: power
      unit_of_measurement: W

/config/packages/sensor.yaml

sensor:
    - platform: template
      sensors:
        e3dc_autarky:
          friendly_name: 'E3DC Autarky'
          unit_of_measurement: '%'
          value_template: "{{ (states('sensor.e3dc_autarky_and_consumption')|int / 256)|round(0,'floor') }}"
        e3dc_own_consumption:
          friendly_name: 'E3DC Own Consumption ratio'
          unit_of_measurement: '%'
          value_template: "{{ ((states('sensor.e3dc_autarky_and_consumption')|int / 256 - states('sensor.e3dc_autarky')|int) * 256)|round(0,'floor') }}"
        # Grid out
        e3dc_grid_power_out:
          unit_of_measurement: 'W'
          device_class: power
          value_template: >
            {% if states('sensor.e3dc_grid_power') | int > 0 %}
              0
            {% else -%}
              {{ (states('sensor.e3dc_grid_power') | int) | abs }} 
            {% endif %}      
        # Grid in
        e3dc_grid_power_in:
          unit_of_measurement: 'W'
          device_class: power
          value_template: >
            {% if states('sensor.e3dc_grid_power') | int > 0 %}
              {{ states('sensor.e3dc_grid_power') | int }}
            {% else -%}
              0
            {% endif %}
        # Battery out
        e3dc_battery_power_out:
          unit_of_measurement: 'W'
          device_class: power
          value_template: >
            {% if states('sensor.e3dc_battery_power') | int > 0 %}
              0
            {% else -%}
              {{ (states('sensor.e3dc_battery_power') | int) | abs }} 
            {% endif %}
        # Battery in
        e3dc_battery_power_in:
          unit_of_measurement: 'W'
          device_class: power
          value_template: >
            {% if states('sensor.e3dc_battery_power') | int > 0 %}
              {{ states('sensor.e3dc_battery_power') | int }}
            {% else -%}
              0
            {% endif %}
    
    - platform: integration
      source: sensor.e3dc_battery_power_out
      name: energy_battery_discharge
      unit_prefix: k
      round: 2
    - platform: integration
      source: sensor.e3dc_battery_power_in
      name: energy_battery_charge
      unit_prefix: k
      round: 2
    - platform: integration
      source: sensor.e3dc_solar_power
      name: energy_solar_production
      unit_prefix: k
      round: 2
    - platform: integration
      source: sensor.e3dc_string_1_power
      name: energy_solar_production1
      unit_prefix: k
      round: 2
    - platform: integration
      source: sensor.e3dc_string_2_power
      name: energy_solar_production2
      unit_prefix: k
      round: 2
    - platform: integration
      source: sensor.e3dc_powermeter_1_L1
      name: energy_solar_powermeter1
      unit_prefix: k
      round: 2
    - platform: integration
      source: sensor.e3dc_powermeter_1_L2
      name: energy_solar_powermeter2
      unit_prefix: k
      round: 2
    - platform: integration
      source: sensor.e3dc_power_consumption
      name: energy_consumption
      unit_prefix: k
      round: 2
    - platform: integration
      source: sensor.e3dc_grid_power_in
      name: energy_grid_usage
      unit_prefix: k
      round: 2
    - platform: integration
      source: sensor.e3dc_grid_power_out
      name: energy_grid_feed_in
      unit_prefix: k
      round: 2

This is how it currently works for me. I would like to thank all the “supporters”, especially da-anda, without whom I would never have been able to do this.

Best regards
Volker

2 Likes

Hi
Really great work! Very much appreciated. I got this running for me as well.
But I´m curious if this setup also incl the power consumption of the E3DC system itself.
Any idea?
Thanks a lot!
Cheers Christoph

Hi, I have an e3dc s10 Power Plant and I read it ba openhab3 - but now I am installing Home Assistant and am interested in this theme - how did you integrated e3dc? do I have to install modbus first?

Welcome to HA! :slight_smile:
All you need is in this topic, just read it.

Hello!
…and Thanks a lot Volker for shareing your code!

It safed me a lot of time, since many of the adresses are not correct in the E3DC ModBus documentation file.
Unfortunatelly I was not able to get your code running as splited files.
So a merged all files into one and it worked like a charme.
I also added a wallbox.

I hope it is ok to share my attempt here, maybe someone else can benefit.

++ needs to be added configuration.yaml:

homeassistant:
  packages: !include_dir_named packages/

++ file location:
config\packages\e3dc_modebus.yaml

++ file content:

#### get data over ModBus
modbus:
  - name: e3dc
    type: tcp
    host: 10.1.1.71
    port: 502
    sensors:
      - name: power_solar
        address: 40067
        state_class: measurement
        unit_of_measurement: "W"
        device_class: power
        scan_interval: 2

      - name: power_battery
        address: 40069
        state_class: measurement
        scan_interval: 2

      - name: soc_battery
        address: 40082
        state_class: measurement
        unit_of_measurement: "%"
        scan_interval: 30

      - name: power_consumption
        address: 40071
        state_class: measurement
        unit_of_measurement: "W"
        device_class: power
        scan_interval: 2

      - name: power_grid
        address: 40073
        state_class: measurement
        scan_interval: 2

      - name: power_wallbox
        address: 40077
        state_class: measurement
        unit_of_measurement: "W"
        device_class: power
        scan_interval: 2

      - name: power_solar_used_by_wallbox
        address: 40079
        state_class: measurement
        unit_of_measurement: "W"
        device_class: power
        scan_interval: 2

      - name: power_external_source
        address: 40076
        state_class: measurement
        unit_of_measurement: "W"
        device_class: power
        scan_interval: 30

      - name: state_emergency_power
        address: 40083
        state_class: measurement
        scan_interval: 30

      - name: state_ems
        address: 40084
        state_class: measurement
        scan_interval: 30

      - name: state_wb0
        address: 40087
        state_class: measurement
        scan_interval: 5

      - name: autarky_and_consumption
        address: 40081
        state_class: measurement
        scan_interval: 30

      - name: power_string_1
        address: 40101
        state_class: measurement
        unit_of_measurement: "W"
        device_class: power
        scan_interval: 5

      - name: power_string_2
        address: 40102
        state_class: measurement
        unit_of_measurement: "W"
        device_class: power
        scan_interval: 5

      - name: power_meter1_p1
        address: 40105
        state_class: measurement
        unit_of_measurement: "W"
        device_class: power
        scan_interval: 5

      - name: power_meter1_p2
        address: 40106
        state_class: measurement
        unit_of_measurement: "W"
        device_class: power
        scan_interval: 5

      - name: power_meter1_p3
        address: 40107
        state_class: measurement
        unit_of_measurement: "W"
        device_class: power
        scan_interval: 5

#### power meters
sensor:
  - platform: template
    sensors:
      power_battery_in:
        #unique_id: "power_battery_in"
        friendly_name: "Leistung Batterie Laden"
        unit_of_measurement: "W"
        device_class: power
        value_template: >
          {% if states('sensor.power_battery') | int > 0 %}
            {{ states('sensor.power_battery') | int }}
          {% else -%}
            0
          {% endif %}
      power_battery_out:
        #unique_id: "power_battery_out"
        friendly_name: "Leistung Batterie Entaden"
        unit_of_measurement: "W"
        device_class: power
        value_template: >
          {% if states('sensor.power_battery') | int > 0 %}
            0
          {% else -%}
            {{ (states('sensor.power_battery') | int) | abs }} 
          {% endif %}
      power_grid_in:
        #unique_id: "power_grid_in"
        friendly_name: "Leistung Netz Beziehen"
        unit_of_measurement: "W"
        device_class: power
        value_template: >
          {% if states('sensor.power_grid') | int > 0 %}
            {{ states('sensor.power_grid') | int }}
          {% else -%}
            0
          {% endif %}
      power_grid_out:
        #unique_id: "power_grid_in"
        friendly_name: "Leistung Netz Einspeisen"
        unit_of_measurement: "W"
        device_class: power
        value_template: >
          {% if states('sensor.power_grid') | int > 0 %}
            0
          {% else -%}
            {{ (states('sensor.power_grid') | int) | abs }}
          {% endif %}
      power_autarky:
        #unique_id: ""
        friendly_name: "Autarkie"
        unit_of_measurement: "%"
        value_template: "{{ (states('sensor.autarky_and_consumption')|int / 256)|round(0,'floor') }}"
      power_consumption_percent:
        #unique_id: ""
        friendly_name: "Eigenverbrauch"
        unit_of_measurement: "%"
        value_template: "{{ ((states('sensor.autarky_and_consumption')|int / 256 - states('sensor.power_autarky')|int) * 256)|round(0,'floor') }}"

  #### energy meters
  - platform: integration
    source: sensor.power_solar
    name: energy_solar
    unit_prefix: k
    unit_time: h
    round: 1
  - platform: integration
    source: sensor.power_battery_out
    name: energy_battery_out
    unit_prefix: k
    unit_time: h
    round: 1
  - platform: integration
    source: sensor.power_battery_in
    name: energy_battery_in
    unit_prefix: k
    unit_time: h
    round: 1
  - platform: integration
    source: sensor.power_grid_out
    name: energy_grid_out
    unit_prefix: k
    unit_time: h
    round: 1
  - platform: integration
    source: sensor.power_grid_in
    name: energy_grid_in
    unit_prefix: k
    unit_time: h
    round: 1
  - platform: integration
    source: sensor.power_consumption
    name: energy_consumption
    unit_prefix: k
    unit_time: h
    round: 1
  - platform: integration
    source: sensor.power_wallbox
    name: energy_wallbox
    unit_prefix: k
    unit_time: h
    round: 1
  - platform: integration
    source: sensor.power_solar_used_by_wallbox
    name: energy_solar_used_by_wallbox
    unit_prefix: k
    unit_time: h
    round: 1
  - platform: integration
    source: sensor.power_external_source
    name: energy_external_source
    unit_prefix: k
    unit_time: h
    round: 1

binary_sensor:
  - platform: template
    sensors:
      #### EMS
      battery_loading_blocked:
        friendly_name: "Laden der Batterien ist gesperrt"
        value_template: "{{ states('sensor.state_ems')|int|bitwise_and(1) > 0 }}"
      battery_unloading_blocked:
        friendly_name: "Entladen der Batterien ist gesperrt"
        value_template: "{{ states('sensor.state_ems')|int|bitwise_and(2) > 0 }}"
      emergency_power_possible:
        friendly_name: "Notstrommodus ist möglich"
        value_template: "{{ states('sensor.state_ems')|int|bitwise_and(4) > 0 }}"
      weather_based_loading:
        friendly_name: "Wetterbasiertes Laden"
        value_template: "{{ states('sensor.state_ems')|int|bitwise_and(8) > 0 }}"
      power_limiter:
        friendly_name: "Abregelungs-Status"
        value_template: "{{ states('sensor.state_ems')|int|bitwise_and(16) > 0 }}"
      smartcharge_loading_blocked:
        friendly_name: "Ladesperrzeit aktiv"
        value_template: "{{ states('sensor.state_ems')|int|bitwise_and(32) > 0 }}"
      smartcharge_unloading_blocked:
        friendly_name: "Entladesperrzeit aktiv"
        value_template: "{{ states('sensor.state_ems')|int|bitwise_and(64) > 0 }}"
      emergency_power_active:
        friendly_name: "Notstrom Modus aktiviert"
        value_template: "{{ is_state('sensor.state_emergency_power', 1) }}"
      #### Wallbox
      wallbox_available:
        friendly_name: "Wallbox vorhanden und verfügbar"
        value_template: "{{ states('sensor.state_wb0')|int|bitwise_and(1) > 0 }}"
      wallbox_solarmode_active:
        friendly_name: "Sonnenmodus aktiv"
        value_template: "{{ states('sensor.state_wb0')|int|bitwise_and(2) > 0 }}"
      wallbox_charging_blocked:
        friendly_name: "Laden blockiert"
        value_template: "{{ states('sensor.state_wb0')|int|bitwise_and(4) > 0 }}"
      wallbox_charging_ongoing:
        friendly_name: "Auto lädt"
        value_template: "{{ states('sensor.state_wb0')|int|bitwise_and(8) > 0 }}"
      wallbox_typ2_plug_locked:
        friendly_name: "Typ-2-Stecker verriegelt"
        value_template: "{{ states('sensor.state_wb0')|int|bitwise_and(16) > 0 }}"
      wallbox_typ2_plug_plugged:
        friendly_name: "Typ-2-Stecker gesteckt"
        value_template: "{{ states('sensor.state_wb0')|int|bitwise_and(32) > 0 }}"
      wallbox_power_plug_active:
        friendly_name: "Schukosteckdose an"
        value_template: "{{ states('sensor.state_wb0')|int|bitwise_and(64) > 0 }}"
      wallbox_power_plug_plugged:
        friendly_name: "Schukostecker gesteckt"
        value_template: "{{ states('sensor.state_wb0')|int|bitwise_and(128) > 0 }}"
      wallbox_power_plug_locked:
        friendly_name: "Schukostecker verriegelt"
        value_template: "{{ states('sensor.state_wb0')|int|bitwise_and(256) > 0 }}"
      wallbox_relais_p1_aktive:
        friendly_name: "Relais 1. Phase an"
        value_template: "{{ states('sensor.state_wb0')|int|bitwise_and(512) > 0 }}"
      wallbox_relais_p2_aktive:
        friendly_name: "Relais 2. Phase an"
        value_template: "{{ states('sensor.state_wb0')|int|bitwise_and(1024) > 0 }}"
      wallbox_relais_p3_aktive:
        friendly_name: "Relais 3. Phase an"
        value_template: "{{ states('sensor.state_wb0')|int|bitwise_and(2048) > 0 }}"
      wallbox_1_phase_active:
        friendly_name: "Eine Phase aktiv"
        value_template: "{{ states('sensor.state_wb0')|int|bitwise_and(4096) > 0 }}"

#### daily meters
utility_meter:
  energy_solar_daily:
    source: sensor.energy_solar
    cycle: daily
  energy_grid_in_daily:
    source: sensor.energy_grid_in
    cycle: daily
  energy_grid_out_daily:
    source: sensor.energy_grid_out
    cycle: daily
  energy_battery_in_daily:
    source: sensor.energy_battery_in
    cycle: daily
  energy_battery_out_daily:
    source: sensor.energy_battery_out
    cycle: daily
  energy_consumption_daily:
    source: sensor.energy_consumption
    cycle: daily
  energy_wallbox_daily:
    source: sensor.energy_wallbox
    cycle: daily
  energy_solar_used_by_wallbox_daily:
    source: sensor.energy_solar_used_by_wallbox
    cycle: daily
  energy_external_source_daily:
    source: sensor.energy_external_source
    cycle: daily

2 Likes

I got my E3DC 10 Compact yesterday and was reading though this thread that helped me a lot to get my system connected to HA. However, I found that some modbus registers were missing and some parts of the configuration caused errors or warnings (probably from HA-upgrades) so now that I have everything working (several hours later…) I thought I share my version with you. Most of it is based on all the configs above, but I believe it’s worth it to put it all together. I’m using Home Assistant 2022.3.8 at the time of writing this.

E3DC 10 Compact Configuration

in config/includes/confirguration.yaml add:

homeassistant:
  customize_glob: !include includes/customize_global.yaml

modbus: !include includes/modbus.yaml
binary_sensor: !include includes/binary_sensors.yaml
sensor: !include includes/sensors.yaml

I hold all my extra-config files in the subfolder config/includes/. Create the file config/includes/customize_global.yaml with the following content:

# Customize Global YAML 
# Customize entities matching a pattern

# General customization for energy sensors
# Set class to energy and enable statistic
"sensor.*_energy":
   last_reset: '1970-01-01T00:00:00+00:00'
   device_class: energy
   state_class: total_increasing

# General customization for power sensors
# Set class to power and enable statistic
"sensor.*_power":
   last_reset: '1970-01-01T00:00:00+00:00'
   device_class: power
   state_class: measurement

This makes the entities we create below in the Energy-Management selectors of HA.

Create the file config/includes/modbus.yaml and insert

- name: "E3DC"
  type: tcp
  host: <<insert_ip_of_e3dc_here>>
  port: 502
  retry_on_empty: true
  sensors:
    - name: E3DC Serial Number
      unique_id: e3dc_serial_number
      address: 40035
      data_type: string
      count: 8
      scan_interval: 86400
    - name: E3DC Model
      unique_id: e3dc_model
      address: 40019
      data_type: string
      count: 8
      scan_interval: 86400
    - name: E3DC Manufacturer
      unique_id: e3dc_manufacturer
      address: 40003
      data_type: string
      count: 8
      scan_interval: 86400
    - name: E3DC Firmware
      unique_id: e3dc_firmware
      address: 40051
      data_type: string
      count: 8
      scan_interval: 86400
    - name: E3DC Modbus Firmware
      unique_id: e3dc_modbus_firmware
      address: 40001
      data_type: uint16
      scan_interval: 86400
    - name: E3DC Solar Power
      unique_id: e3dc_solar_power
      unit_of_measurement: W
      data_type: int16
      address: 40067
      device_class: power
      scan_interval: 2
    - name: E3DC Battery Power
      unique_id: e3dc_battery_power
      unit_of_measurement: W
      address: 40069
      data_type: int16
      device_class: power
      scan_interval: 2
    - name: E3DC Battery State of Charge
      unique_id: e3dc_battery_state_of_charge
      unit_of_measurement: '%'
      address: 40082
      data_type: uint16
      device_class: battery
      scan_interval: 30
    - name: E3DC Power Consumption House
      unique_id: e3dc_house_consumption_power
      unit_of_measurement: W
      data_type: int16
      address: 40071
      device_class: power
      scan_interval: 2
    - name: E3DC Grid Power
      unique_id: e3dc_grid_power
      unit_of_measurement: W
      data_type: int16
      address: 40073
      device_class: power
      scan_interval: 2
    - name: E3DC Emergency Power State
      unique_id: e3dc_emergency_power_state
      data_type: int16
      address: 40083
      scan_interval: 10
    - name: E3DC Autarky and Consumption
      unique_id: e3dc_autarky_and_consumption
      data_type: uint16
      address: 40081
      scan_interval: 60
    - name: E3DC String 1 Power
      unique_id: e3dc_string_1_power
      data_type: uint16
      address: 40101
      device_class: power
      unit_of_measurement: W
      scan_interval: 10
    - name: E3DC String 2 Power
      unique_id: e3dc_string_2_power
      data_type: uint16
      address: 40102
      device_class: power
      unit_of_measurement: W
      scan_interval: 10
    - name: E3DC String 1 Voltage
      unique_id: e3dc_string_1_voltage
      data_type: uint16
      address: 40095
      device_class: voltage
      unit_of_measurement: V
      scan_interval: 10
    - name: E3DC String 2 Voltage
      unique_id: e3dc_string_2_voltage
      data_type: uint16
      address: 40096
      device_class: voltage
      unit_of_measurement: V
      scan_interval: 10
    - name: E3DC String 1 Current
      unique_id: e3dc_string_1_current
      data_type: uint16
      address: 40098
      device_class: current
      unit_of_measurement: A
      scale: 0.01
      precision: 2
      scan_interval: 10
    - name: E3DC String 2 Current
      unique_id: e3dc_string_2_current
      data_type: uint16
      address: 40099
      device_class: current
      unit_of_measurement: A
      scale: 0.01
      precision: 2
      scan_interval: 10
    - name: E3DC Powermeter 1 L1-L3
      unique_id: e3dc_powermeter_1
      data_type: int16
      address: 40105
      device_class: power
      unit_of_measurement: W
      scan_interval: 10
    - name: E3DC Powermeter 1 L1
      unique_id: e3dc_powermeter_1_L1
      data_type: int16
      address: 40106
      device_class: power
      unit_of_measurement: W
      scan_interval: 10
    - name: E3DC Powermeter 1 L2
      unique_id: e3dc_powermeter_1_L2
      data_type: int16
      address: 40107
      device_class: power
      unit_of_measurement: W
      scan_interval: 10
    - name: E3DC Powermeter 1 L3
      unique_id: e3dc_powermeter_1_L3
      data_type: int16
      address: 40108
      device_class: power
      unit_of_measurement: W
      scan_interval: 10

this creates the modbus-config with all the values that I found useful.

Create the file config/includes/binary_sensors.yaml and insert

- platform: template
  sensors:
    e3dc_emergency_power_available:
      friendly_name: "E3DC Emergency Power available"
      value_template: "{{ states('sensor.e3dc_emergency_power_state')|int|bitwise_and(4) > 0 }}"
    e3dc_battery_loading_blocked:
      friendly_name: "E3DC Battery loading blocked"
      value_template: "{{ states('sensor.e3dc_emergency_power_state')|int|bitwise_and(1) > 0 }}"
    e3dc_battery_unloading_blocked:
      friendly_name: "E3DC Battery unloading blocked"
      value_template: "{{ states('sensor.e3dc_emergency_power_state')|int|bitwise_and(2) > 0 }}"
    e3dc_weather_based_loading:
      friendly_name: "E3DC weather based loading limiter"
      value_template: "{{ states('sensor.e3dc_emergency_power_state')|int|bitwise_and(8) > 0 }}"
    e3dc_power_limiter:
      friendly_name: "E3DC power limiter"
      value_template: "{{ states('sensor.e3dc_emergency_power_state')|int|bitwise_and(16) > 0 }}"
    e3dc_smartcharge_loading_blocked:
      friendly_name: "E3DC SmartCharge loading blocked"
      value_template: "{{ states('sensor.e3dc_emergency_power_state')|int|bitwise_and(32) > 0 }}"
    e3dc_smartcharge_unloading_blocked:
      friendly_name: "E3DC SmartCharge unloading blocked"
      value_template: "{{ states('sensor.e3dc_emergency_power_state')|int|bitwise_and(64) > 0 }}"

This parses the sensor.e3dc_emergency_power_state into single binary_sensors.

Create the file config/includes/sensors.yaml and insert

- platform: integration
  source: sensor.e3dc_grid_import_power
  name: E3DC Grid Import Energy
  unit_prefix: k
  round: 2
- platform: integration
  source: sensor.e3dc_grid_export_power
  name: E3DC Grid Export Energy
  unit_prefix: k
  round: 2
- platform: integration
  source: sensor.e3dc_solar_power
  name: E3DC Solar Energy
  unit_prefix: k
  round: 2
- platform: integration
  source: sensor.e3dc_battery_power
  name: E3DC Builtin Battery Energy
  unit_prefix: k
  round: 2
- platform: integration
  source: sensor.e3dc_battery_charge_power
  name: E3DC Battery Charge Energy
  unit_prefix: k
  round: 2
- platform: integration
  source: sensor.e3dc_battery_discharge_power
  name: E3DC Battery Discharge Energy
  unit_prefix: k
  round: 2
    e3dc_grid_export_power:
      unique_id: e3dc_grid_export_power
      friendly_name: E3DC Grid Export Power
      unit_of_measurement: W
      device_class: power
      value_template: >
        {% if states('sensor.e3dc_grid_power') | int > 0 %}
          0
        {% else -%}
          {{ (states('sensor.e3dc_grid_power') | int) | abs }} 
        {% endif %}  
    e3dc_grid_import_power:
      unique_id: e3dc_grid_import_power
      friendly_name: E3DC Grid Import Power
      unit_of_measurement: W
      device_class: power
      value_template: >
        {% if states('sensor.e3dc_grid_power') | int > 0 %}
          {{ states('sensor.e3dc_grid_power') }}
        {% else -%}
          0
        {% endif %}
    e3dc_battery_charge_power:
      unique_id: e3dc_battery_charge_power
      friendly_name: E3DC Battery Charging Power
      unit_of_measurement: W
      device_class: power
      value_template: >
        {% if states('sensor.e3dc_battery_power') | int >= 0 %}
          {{ states('sensor.e3dc_battery_power') }}
        {% endif %}  
    e3dc_battery_discharge_power:
      unique_id: e3dc_battery_discharge_power
      friendly_name: E3DC Battery Discharging Power
      unit_of_measurement: W
      device_class: power
      value_template: >
        {% if states('sensor.e3dc_battery_power') | int <= 0 %}
          {{ (states('sensor.e3dc_battery_power') | int) | abs }} 
        {% endif %} 
    e3dc_autarky:
      friendly_name: 'E3DC Autarky'
      unique_id: e3dc_autarky
      unit_of_measurement: '%'
      value_template: "{{ (states('sensor.e3dc_autarky_and_consumption')|int / 256)|round(0,'floor') }}"
    e3dc_own_consumption:
      friendly_name: 'E3DC Own Consumption ratio'
      unique_id: e3dc_own_consumption_ratio
      unit_of_measurement: '%'
      value_template: "{{ ((states('sensor.e3dc_autarky_and_consumption')|int / 256 - states('sensor.e3dc_autarky')|int) * 256)|round(0,'floor') }}"

This creates first with the integral integration the integral of the power-sensors (to create energy in kWh). It’s a pitty that E3DC doesn’t give the energy out directly, as those integral are less accurate than then value that would come from the machne directly.

Later is create seperate values for energy that flow into either direction, as sometimes you want the directions sepearted into two values rather than a value that is positive or negative.

In the end autarky and consmption ration are bitshifted for better readability.

I hope it works for you faster this way than it did for me. :wink:

Edit 20220403: Added unique_ids to some sensors
Edit 20220409: Thanks @dagra68 for hinting about the scan_interval, I’ve added it and fix a sign-issue with the energy of the grid.

4 Likes

To have a more precise readout I would decrease de scaninterval (defautl ist 30sec) to about 2 for eg power:
grafik

On the other hand I would increase the interval for the serial number, model, manufacturer (I dont think this will change very often :wink: )

1 Like

Thanks ursus_polaris for your configuration. I already tried to integrate E3DC several times to my HA, now I tried your config.

After trying, I got an error: “expected a dictionary for dictionary value”

I found 3 little problems in your yaml files - in the first line:

in modbus.yaml you have to add “modbus:” in the first line
in binary_sensors.yaml you have to add “binary_sensor:” in the first line
in sensors.yaml you have to add “sensor:” in the first line

After that, HA could be restarted - now I’m waiting for Entries in Energy Dashboard

Hi, I´m still fighting with the energy dashboard… Which sensors do I have to place on which entry in HA Energy Board?

Hi @pelo you have to add modbus: etc, in case you have it straight in the configuration.yaml - but if you include the via separate files (as described above in my post) you have to leave them out.

Ahh , ok - I merged the files so I have every configuration in in separate files in the config/packages by
adding in configuration.yaml:

homeassistant:
packages: !include_dir_named packages/

  • that was the problem…

Do you have a hint, which entries do I have to put in the energy dashboard?

Hi,
I’ve got it… Thanks in advance

Pelo

Can you share, which entries you placed where in the energy dashboard? I even can’t see any of the E3DC-entities created in the Dropdown-Menu of the dashboard
Thanks
Karl

I believe there is something missing in the sensors.yaml
After the last platform: integration (line round 2) shouldn’t there be a

  • platform: template
    sensors:

?
At least I did get errors without that

2 Likes

Same here. After adding these two lines it works fine.

Hi; i tried your config and HA could find a lot of entities! great! But I get this message:
This entity does not have a unique ID so HA can get a connection to all the sensors from e3dc. I think I have to write a unique ID but how? thank you

Tx for sharing - would you mind to share what you have included in the /config/configuration.yaml ?

regards Peter

anyone has a working entry in the yaml file file for:

40076 Leistung aller zusätzlichen Einspeiser in Watt 2 Int32 (which will deliver a negative number)
Int16 displays only -1 Int 32 displays only 65565

Hello together,

I read the wole thread but have some problems getting it to work…
@Volker Do you have a running configuration using the packages method and an actual HA version?

@ursus_polaris I also tried your configuration, but I do not understand why you use a second configuration.yaml in the folder includes? And how you nclude that special configuration.yaml in your main configuration.yaml?

@all If anybody else could share a working set of configuration files it would be very kind of you!

Thanks to all
Markus

1 Like