ESPHome Smart Meter OBIS D0 Component

@JWSK This could have several reasons:

  • Does your meter provide 1-0:16:7.0? Which meter do you use?
  • Is the value_regex matching? You can (temporarily) remove the value_regex to check whether this causes the problem.

Do you have access to the esphome logs? If yes you can check the available OBIS codes and the format in the log output.


So this is the Smartmeter.
for testing I deactivated the regex parameter

those are the sensors:

sensor:

  • platform: obis_d0
    name: “Consumed Energy”
    obis_d0_id: my_sm
    obis_code: “1-0:1.8.0*255”
    unit_of_measurement: kWh
    accuracy_decimals: 0
    state_class: total_increasing
    device_class: energy
    value_regex: “\d{6}\.\d{4}\*kWh”

  • platform: obis_d0
    name: “Provided Energy”
    obis_d0_id: my_sm
    obis_code: “1-0:2.8.0*255”
    unit_of_measurement: kWh
    accuracy_decimals: 0
    state_class: total_increasing
    device_class: energy
    value_regex: “\d{6}\.\d{4}\*kWh”

  • platform: obis_d0
    name: “Power”
    obis_d0_id: my_sm
    obis_code: “1-0:16.7.0*255”
    unit_of_measurement: W
    accuracy_decimals: 0
    state_class: measurement
    device_class: power
    #value_regex: “-?\d{6}\*W”`

and this is one logfile segment:

[14:39:59][D][obis_d0:157]: Identification: LOG5XXxXXXXXXXXXXXXXXXXXXXX
[14:39:59][D][obis_d0:201]: OBIS info: 1-0:96.1.0255 → 001LOGXXXXXXXXXXX
[14:39:59][D][obis_d0:201]: OBIS info: 1-0:1.8.0
255 → 034914.9953kWh
[14:39:59][D][sensor:093]: ‘Consumed Energy’: Sending state 34914.99609 kWh with 0 decimals of accuracy
[14:39:59][D][obis_d0:201]: OBIS info: 1-0:2.8.0
255 → 006139.1373kWh
[14:39:59][D][sensor:093]: ‘Provided Energy’: Sending state 6139.13721 kWh with 0 decimals of accuracy
[14:39:59][D][obis_d0:201]: OBIS info: 1-0:0.2.0
255 → ver.03,432F,20170504
[14:39:59][D][obis_d0:201]: OBIS info: 1-0:96.90.2255 → 0F66
[14:39:59][D][obis_d0:201]: OBIS info: 1-0:97.97.0
255 → 00000000
[14:39:59][W][component:204]: Component obis_d0 took a long time for an operation (0.22 s).
[14:39:59][W][component:205]: Components should block for at most 20-30ms.

so there is no 1-0:16:7.0, how could I fix it? I am sure the energy supplier won’t install a new smartmeter.

Thanks for your help


Maybe thats is the problem.
INF on has to be activated after pin input.

I will try when I visit the smart meter next Time :slight_smile:

Yes, that’s the problem.

FYI: My smart meter (different vendor) has the following problem: It forgets the INF configuration when there is a power outage. So I always have to reconfigure…

Hello mampfes,

thanks for your help.

i will check about the blackouts there.
I already know the the entered pin stays active after blackout.

Give me some days and I will be safe to say what is possible and what not

We were right, it was the inf on parameter!
Thank you!

Dear all,
thx for this nice component - unfortunately it does not work for me :frowning:
Hope you could help me: No matter what I do, I always get
"[22:30:00][D][obis_d0:152]: abort"
in the logger. I tried different things, but apparently the data is not comming through. Using NodeMCUv2 (ESP 8266) with the exact example as given by judges.
Any idea where I should be looking at?

Update: Found that my meter uses SML and code 1_8D_0P_N_1S for serial coms.
Meter name: ebz dd3 2r06 dta smz1
How do I activate that in the above example? Thx!

Update 2: The link provided by mampfes in the post below was helpful (THX!) - now the IR readout works without problems.
Further reference: https://www.mittelstedt.net/?tag=esphome (german website)

Thx!

@Ole_North This component only supports D0 based meters. For SML, please use this component: SML (Smart Message Language) — ESPHome

1 Like

Has anyone tried to use this on a tasmota based device like the Hichi IR or ESPLesekopf?

@M92718 There are people out there which use this component with ESP01 based devices:

Scary, is there something pre build that you can just flash over tasmota?

ESPHome is using a different approach than Tasmota: ESPHome doesn’t a provide pre-build binary, but let you build your own application based on your needs. Therefore, please get familiar with ESPHome.

Hi guys,

I am also trying to read the energy from my energy meter with an ESP01. I have an ACE3000 type 260.

My configuration:

uart:
  id: uart_bus
  tx_pin: 1
  rx_pin: 3
  baud_rate: 300
  data_bits: 7
  parity: EVEN
  stop_bits: 1

obis_d0:
  id: mysml
  uart_id: uart_bus
  optimize_size: true
  on_telegram:
    then:
      - logger.log: "telegram received"

sensor:
  - platform: obis_d0
    name: "PV-Energie"
    obis_d0_id: mysml
    obis_code: "1-0:1.8.0*255"
    unit_of_measurement: kWh
    accuracy_decimals: 1
    device_class: energy
    state_class: total_increasing
    value_regex: "\\d{6}\\.\\d{8}\\*kWh"

interval:
  - interval: 5min
    then:
      - uart.write: "/?!\r\n"

From the log I can see that reading from energy meter seems to work:
image

But it is not showing any information in the dashboard:
image

Do you have any ideas how to fix this?
Thanks and regards.

According to the log, your sensor configuration should look like this:

sensor:
  - platform: obis_d0
    name: "PV-Energie"
    obis_d0_id: mysml
    obis_code: "1.8.0"
    unit_of_measurement: kWh
    accuracy_decimals: 1
    device_class: energy
    state_class: total_increasing
    value_regex: "\\d{6}\\.\\d{1}\\*kWh"

If this is not working, you can temporary remove the value_regex to check whether it is a problem with the obis_code or the regular expression.

Please let me know once it is working, then I would add your configuration to the examples in the documentation.

How would you add a range-check to these sensors so we ignore value changes outside a certain range? Would be a great addition to the example section

@M92718 Should be doable with ESPHome Filters, esp. Clamp: Sensor Component — ESPHome

Hi,

my config looks the following for an ACE 3000 Type 260:
(Only meter reading is available, no power)

external_components:
  - source: github://mampfes/esphome_obis_d0

uart:
  id: uart_bus
  tx_pin: 1
  rx_pin: 3
  baud_rate: 300
  data_bits: 7
  parity: EVEN
  stop_bits: 1

obis_d0:
  id: mysml
  uart_id: uart_bus
  optimize_size: true
# Logging if needed
#  on_telegram:
#    then:
#      - logger.log: "telegram received"

sensor:
  - platform: obis_d0
    name: "PV-Energie"
    obis_d0_id: mysml
    obis_code: "1.8.0"
    unit_of_measurement: kWh
    accuracy_decimals: 1
    device_class: energy
    state_class: total_increasing
    value_regex: "\\d{6}\\.\\d{1}\\*kWh"
# Filter, b/c sometimes NaN is received
    filters:
      - filter_out: nan

# ACE energy meter needs to be triggered
interval:
  - interval: 5min
    then:
# Send start sequence
      - uart.write: "/?!\r\n"

Thanks

1 Like

If I don’t see any logging despite debug level and just a warning to set my baud rate to 0 because uart is interfering, how should I proceed?
How do I figure out if the ibis command is wrong or I just messed up the pin numbers?

@M92718 The UARTs might be already used the the logger: Logger Component — ESPHome

Two small mistakes, the pins were not the default for the board (esp8285) and i got the regex wrong as the accuracy is different for each value read.

So here is the correct version for an EZB DD3 with this Sensor

esphome:
  name: strom-d0
  friendly_name: Strom-D0

esp8266:
  board: esp8285

# Enable Home Assistant API
api:
  encryption:
    key: ""

ota:
  password: ""

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "StromzählerFallbackWifi"
    password: ""

uart:
  id: uart_bus
  tx_pin: 13
  rx_pin: 14
  baud_rate: 9600
  data_bits: 7
  parity: EVEN
  stop_bits: 1

external_components:
  - source: github://mampfes/esphome_obis_d0

logger:
  baud_rate: 0

obis_d0:
  id: mysml
  uart_id: uart_bus
  optimize_size: true
# Logging if needed
  on_telegram:
    then:
      - logger.log: "telegram received"

sensor:
   - platform: obis_d0
     name: "Verbrauch"
     obis_d0_id: mysml
     obis_code: "1-0:1.8.0*255"
     unit_of_measurement: kWh
     accuracy_decimals: 8
     device_class: energy
     state_class: total_increasing
     value_regex: "\\d{6}\\.\\d{8}\\*kWh"
     filters:
     - filter_out: nan

   - platform: obis_d0
     name: "Verbrauch_T1"
     obis_d0_id: mysml
     obis_code: "1-0:1.8.1*255"
     unit_of_measurement: kWh
     accuracy_decimals: 3
     device_class: energy
     state_class: total_increasing
     value_regex: "\\d{6}\\.\\d{3}\\*kWh"
     # Filter, b/c sometimes NaN is received
     filters:
     - filter_out: nan

   - platform: obis_d0
     name: "Verbrauch_T2"
     obis_d0_id: mysml
     obis_code: "1-0:1.8.2*255"
     unit_of_measurement: kWh
     accuracy_decimals: 3
     device_class: energy
     state_class: total_increasing
     value_regex: "\\d{6}\\.\\d{3}\\*kWh"
     # Filter, b/c sometimes NaN is received
     filters:
      - filter_out: nan

   - platform: obis_d0
     name: "Erzeugung"
     obis_d0_id: mysml
     obis_code: "1-0:2.8.0*255"
     unit_of_measurement: kWh
     accuracy_decimals: 8
     device_class: energy
     state_class: total_increasing
     value_regex: "\\d{6}\\.\\d{8}\\*kWh"
     # Filter, b/c sometimes NaN is received
     filters:
      - filter_out: nan

   - platform: obis_d0
     name: "VerbrauchGesamt"
     obis_d0_id: mysml
     obis_code: "1-0:16.7.0*255"
     unit_of_measurement: W
     accuracy_decimals: 8
     device_class: energy
     state_class: measurement
     value_regex: "\\d{6}\\.\\d{2}\\*W"
     # Filter, b/c sometimes NaN is received
     filters:
     - filter_out: nan

   - platform: obis_d0
     name: "Verbrauch_L1"
     obis_d0_id: mysml
     obis_code: "1-0:36.7.0*255"
     unit_of_measurement: W
     accuracy_decimals: 2
     device_class: energy
     state_class: measurement
     value_regex: "\\d{6}\\.\\d{2}\\*W"
     # Filter, b/c sometimes NaN is received
     filters:
      - filter_out: nan

   - platform: obis_d0
     name: "Verbrauch_L2"
     obis_d0_id: mysml
     obis_code: "1-0:56.7.0*255"
     unit_of_measurement: W
     accuracy_decimals: 2
     device_class: energy
     state_class: measurement
     value_regex: "\\d{6}\\.\\d{2}\\*W"
     # Filter, b/c sometimes NaN is received
     filters:
      - filter_out: nan

   - platform: obis_d0
     name: "Verbrauch_L3"
     obis_d0_id: mysml
     obis_code: "1-0:76.7.0*255"
     unit_of_measurement: W
     accuracy_decimals: 2
     device_class: energy
     state_class: measurement
     value_regex: "\\d{6}\\.\\d{2}\\*W"
     # Filter, b/c sometimes NaN is received
     filters:
      - filter_out: nan
#bis hier wars ok
   - platform: obis_d0
     name: "Spannung_L1"
     obis_d0_id: mysml
     obis_code: "1-0:32.7.0*255"
     unit_of_measurement: V
     accuracy_decimals: 1
     device_class: energy
     state_class: measurement
     value_regex: "\\d{3}\\.\\d{1}\\*V"
     # Filter, b/c sometimes NaN is received
     filters:
      - filter_out: nan

   - platform: obis_d0
     name: "Spannung_L2"
     obis_d0_id: mysml
     obis_code: "1-0:52.7.0*255"
     unit_of_measurement: V
     accuracy_decimals: 1
     device_class: energy
     state_class: measurement
     value_regex: "\\d{3}\\.\\d{1}\\*V"
     # Filter, b/c sometimes NaN is received
     filters:
      - filter_out: nan

   - platform: obis_d0
     name: "Spannung_L3"
     obis_d0_id: mysml
     obis_code: "1-0:72.7.0*255"
     unit_of_measurement: V
     accuracy_decimals: 1
     device_class: energy
     state_class: measurement
     value_regex: "\\d{3}\\.\\d{1}\\*V"
     # Filter, b/c sometimes NaN is received
     filters:
      - filter_out: nan

text_sensor:
  - platform: obis_d0
    name: "Device Identification"
    obis_d0_id: mysml
    obis_code: "1-0:96.1.0*255"
    entity_category: diagnostic`

Nice to finally filter out spikes with “nan” when the sensor fails at reading the value properly and transmitting it.

GitHub - aquaticus/esphome-iec62056: IEC 62056-21 component for ESPHome could be another solution. Not sure if there are any major differences.