How to make code to communicate with OBIS electricity meter and return to home assistant energy?

I have tried connecting with meter using tasmota and their Smart Meter Interface - Tasmota and when i do

->sensor53 r
>M 1

I get bak all the OBIS codes from meter that it can give

so I think it means I need to send 2F3F210D0A on seria/UART and parse the results.

Is there a link describing what exactly i need to return from esphome to HA energy?
Is there simple example of sending text (hex?) on serial and parsing the results?

Update: actually this is it SML (Smart Message Language) — ESPHome I have tried that, but don’t know how to make it send 2F3F210D0A

Update 2: looks like this guy created it ? but it does not work for me

What Energy Meter do you have?
For Mine i Just looked the obis Codes up using google. Many meters are documented.


this is how meter output looks after it receives HEX message 2F3F210D0A, which is /?!\r\n in ascii

11:52:28.479 : �m/ZPA5ZE312.v10_022
11:52:32.179 : �C.1.0(I removed number in brackets here)
11:52:33.013 : 0.0.0(I removed number in brackets here)
11:52:33.746 : 0.3.0(10000*imp/kWh)
11:52:34.179 : F.F(000000)
11:52:34.980 : 1.8.0(0031410.557*kWh)
11:52:35.779 : 1.8.1(0016127.292*kWh)
11:52:36.580 : 1.8.2(0015283.265*kWh)
11:52:37.413 : 21.8.0(0007562.910*kWh)
11:52:38.247 : 41.8.0(0016305.829*kWh)
11:52:39.079 : 61.8.0(0007541.821*kWh)
11:52:39.879 : 2.8.0(0000000.000*kWh)
11:52:40.714 : 22.8.0(0000000.000*kWh)
11:52:41.547 : 42.8.0(0000000.000*kWh)
11:52:42.381 : 62.8.0(0000000.000*kWh)
11:52:43.014 : C.8.1(0211082009)
11:52:43.647 : C.8.2(0204240034)
11:52:44.281 : C.8.0(0400042218)
11:52:44.948 : C.82.0(0000000000)
11:52:45.515 : C.7.1(00000002)
11:52:46.080 : C.7.2(00000003)
11:52:46.647 : C.7.3(00000005)
11:52:47.615 : 0.2.1(ver.02, 100830, B526)
11:52:48.248 : C.2.1(1505031020)
11:52:48.881 : C.2.9(1505031020)
11:52:49.515 : C.3.9(0000000000)
11:52:49.615 : !

esphome SML will not compile, tells me that “1.8.0” is not valid SML, i guess it is not, but anyway I did not found a way to send /?!\r\n to poll the meter

So not even close to home assistant energy dashboard part :slight_smile:

obis_code: "1-0:1.8.0"
Should give you total energy consumed

1.8.0 is what meter returns, what i posted above is reply from the meter, even if SML in esphome would parse “1-0:1.8.0” as “1.8.0” I still don’t know how to make it query the meter.

Could you post your entire code? I assume it’s similar to the example from the docs.

My attempt with esphome sml configuration was

  name: test
  platform: ESP8266
  board: esp01





  version: 2

  baud_rate: 0
  level: DEBUG

  id: uart_bus
  tx_pin: 1
  rx_pin: 3
  baud_rate: 300

  id: mysml
  uart_id: uart_bus

  - platform: sml
    name: "Total energy"
    sml_id: mysml
    obis_code: "1-0:1.8.0"
    unit_of_measurement: kWh
    accuracy_decimals: 3
    device_class: energy
    state_class: total_increasing

If you were asking about tasmota script that successfully polls the meter it is the thing in the first porst, i was never able to parse anything from response.¨

I guess it is worth a try to do


and let’s see what sml component will do (i can’t do ota currently so updating is kinda pain)

And what error message do you get/ why isn’t it working. I suspect the obis code isn’t necesarily the problem. You have your baud rate at 300, is that correct?

This is my working code (at the time SML wasn’t supported by ESPHome yet, so i used an external component):

  - source:
      type: git
    components: [ sml ]
  id: uart_bus
  tx_pin: GPIO14
  rx_pin: GPIO12
  baud_rate: 9600
  data_bits: 8
  parity: NONE
  stop_bits: 1
  - platform: sml
    name: "Strom aus dem Netz"
    obis_code: "1-0:1.8.0"
    unit_of_measurement: kWh
    accuracy_decimals: 1
    device_class: energy
    state_class: total_increasing
      - multiply: 0.0001
      - throttle: 1h
  - platform: sml
    name: "Strom eingespeist"
    obis_code: "1-0:2.8.0"
    unit_of_measurement: kWh
    accuracy_decimals: 1
    device_class: energy
    state_class: total_increasing
      - multiply: 0.0001
      - throttle: 300s #5 minutes

  - platform: sml
    name: "Leistung"
    obis_code: "1-0:16.7.0"
    unit_of_measurement: W
    device_class: power
    accuracy_decimals: 1
#      - multiply: 0.1
       - throttle: 10s

I get no response from the meter, no errors.

I have tried as it should support sending payload: "\x2F\x3F\x21\x0D\x0A"
but in the log I see

16:25:55	[D]	[uart_debug:114]	
>>> 2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A:2F:3F:21:0D:0A

so it seems to not send it once, but multiple times.

300 baud is correct, i get it working in tasmota with 300 baud, it should support 9600, but I got it working with 300 so that is what I set

I’m using head from hichi that does have nice provision for esp01, but that alo means i’m limited by the 1MB for OTA, i found pin compatible 4MB board on ali, but that will take about month until i get it here.

Update: i think the issue is with reading head I use “hichi” as with tasmota i can read garbage if i point it to istelf etc. but if i do same with esphome i cannot. I think there is some hacks for tasmote so that it can work with it

I use the hichi board as well, with a esp8266.
OTA is working flawlessly.

It’s basically the same setup as yours apart from the Energy Meter brand (mine is a Iskra).

Are you sure the wiring is correct and you have the magnet of the hichi snapped on in the correct position?

Yes as i can read the meter in tasmota

In esphome i don’t get any response

Using board: esp01_1m instead just eap01 i could get Ota working

Also I verified that uart interface in esphome can send and receive data from IR head.

Meter brand is ZPA.

I’m sorry that I can’t help you any further at this point.
I’d wait for the esp with 4mb so it’s a bit easier to try some different things out OTA.
One of those things could be using the same SML integration I’m using opposed to the build in esp home one.
For me it has been working without skipping a beat for 6 months now and our setups are basically the same.

Do you have Iskra MT 174 ?

If so I will try the custom components you use, as Iskra MT174 has same poll/wakeup string as the meter I have.

But it’s probably the same.

MT 175 is true SML i guess, not obis, and does not require “wake up call” so unfortunately quite different

I still don’t fully understand difference between sml and obis, it is not like sml does not use obis codes

ok, i actually wasn’t aware of that.

So to recap, you still have two problem at the moment:

  1. you’re unable to trigger the smart meter
  2. your readings are gibberish
    is that correct?

I did some digging around and found the following possible solutions.

For 1: some people have succesfully triggered their smart meter. see this link

For 2: this external component should work for obis-based smart meters. It has a different parser then the true SML one which comes built in with ESPHome

  1. correct
  2. no, gibberish was my test that esphome can read ir from the mirror, it could

anyway i read tasmota documentation VERY SLOWLY and managed to get it working with tasmota, so I think I can extract data into HA from the json somehow, dunno anything about energy dashboard yet. will return all sensor data from tasmota as json

Thanks for the links, I will try it sometime.

ESPHome usually also complains, that my OBIS is not obis, as it really is just 61.8.0 and not 1-0:61.8.0 but might work with “D0” custom component still

My setup until i get some low profile USB powr source

  - scan_interval: 20
      - name: total_in
        value_template: "{{value_json.StatusSNS.Ele.Total_in}}"
        unit_of_measurement: "kWh"
        state_class: total_increasing

  - sensor:
      - name: "Total energy in"
        unit_of_measurement: "kWh"
        device_class: energy
        state_class: total_increasing
        state: "{{ states('sensor.Total_in')|float }}" #"{{ states.Total_in | float }}"

hopefully it will work, currently nothing shows up


results in this at it overrides correct value with incorrect one

but it is possible to work around by t1+t2 or l1+l2+l3 … for esphome i would need to write custom code, which, in the hindsight, would probably be fastest as it is nicely documented here Custom UART Text Sensor — ESPHome