Energy integration from Tasmota SML (Json encoded data via MQTT)

Hello everyone,
I just got my electric meter connected to a hitchi IR Head (German page). Basicly it’s tasmota running on a ESP8266 with IR Head. This is working fine so far, I installed mosquitto MQTT broker on HA and receive the json encoded MQTT information from the sensor. Example:

{
    "Time": "2022-05-08T19:35:38",
    "SML": {
        "Total_in": 15739.95,
        "Total_out": 0,
        "Power_curr": 538,
        "Volt_p1": 227.3,
        "Volt_p2": 229.3,
        "Volt_p3": 229.3,
        "Ampere_p1": 2.1,
        "Ampere_p2": 1,
        "Ampere_p3": 0.8,
        "Freq": 50
    }
}

Now i would like to include this information to the enery integration of HA. Could anyone give me a hint what’s the best practise to do so?
Thanks :slight_smile:

I use this

sensor:

  - platform: mqtt
    name: "EB1 Voltage L1"
    unique_id: EB1_VolL1
    state_topic: "tele/edpbox1/SENSOR"
    value_template: >-
        {% set x = value_json.EB1.Voltage|float(0) %}
        {% if x > 0 %}
          {{ x }}
        {% endif %}
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement

  - platform: mqtt
    name: "EB1 Current L1"
    unique_id: EB1_CurL1
    state_topic: "tele/edpbox1/SENSOR"
    value_template: >-
        {{ value_json.EB1.Current|float(0.0) }}
    unit_of_measurement: "A"
    device_class: current
    state_class: measurement

  - platform: mqtt
    name: "EB1 Power Factor"
    unique_id: EB1_PowFac
    state_topic: "tele/edpbox1/SENSOR"
    value_template: >-
        {% set x = value_json.EB1.Power_Factor|float(0) %}
        {% if x > 0 %}
          {{ x }}
        {% endif %}
    unit_of_measurement: "pu"
    device_class: power_factor
    state_class: measurement

  - platform: mqtt
    name: "EB1 Active Power"
    unique_id: EB1_ActPow
    state_topic: "tele/edpbox1/SENSOR"
    value_template: >-
        {% set x = value_json.EB1.Active_Power|int(0) %}
        {% if x %}
          {{ x }}
        {% endif %}
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement

  - platform: mqtt
    name: "EB1 Frequency"
    unique_id: EB1_Frequency
    state_topic: "tele/edpbox1/SENSOR"
    value_template: >-
        {% set x = value_json.EB1.Frequency|float(0) %}
        {% if x > 0 %}
          {{ x }}
        {% endif %}
    unit_of_measurement: "Hz"
    device_class: frequency
    state_class: measurement


  - platform: mqtt
    name: "EB1 Import"
    unique_id: EB1_TotEneImp
    state_topic: "tele/edpbox1/SENSOR"
    value_template: >-
        {% set x = value_json.EB1.Energy|float(0) %}
        {% if x > 0 %}
          {{ x }}
        {% endif %}
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing

  - platform: mqtt
    name: "EB1 Export"
    unique_id: EB1_TotEneExp
    state_topic: "tele/edpbox1/SENSOR"
    value_template: >-
        {{ value_json.EB1.TotEneExp|float(0.0) }}
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing

You need change topic

And json.EB1.xxxx to json.SML.xxxx

2 Likes

Thanks! Up and runnung :+1:

1 Like

Hi, I need some help. I hope my english is good enought to explain… I’m German :slight_smile:
I got the same Isssue but I can’t fix it myself…

This is my Message receiving
MQT: tele/tasmota_11CDD1/SENSOR = {“Time”:“2022-09-27T18:01:35”,“SML”:{“Total_in”:9236.5,“Power_curr”:592}}

I can See the Values in the Dashboard
Pic 1

I already used the Json from nikito7 changing to my sensors

 - platform: mqtt
    name: "SML_Aktueller_Verbrauch"
    unique_id: sensor.tasmota_sml_power_curr
    state_topic: "tele/tasmota_11CDD1/SENSOR"
    value_template: >-
        {% set x = value_json.SML.Power_curr|int(0) %}
        {% if x %}
          {{ x }}
        {% endif %}
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement

  - platform: mqtt
    name: "Gesamt"
    unique_id: sensor.tasmota_sml_total_in
    state_topic: "tele/tasmota_11CDD1/SENSOR"
    value_template: >-
        {% set x = value_json.SML.Total_in|float(0) %}
        {% if x > 0 %}
          {{ x }}
        {% endif %}
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing

I’d like to see the Power in W update every 5 Seconds in the Dashboard. The best would be if there where an option like the kWh see picture 1 red drawn circle

Can anyone help?
Thanks alot

TelePeriod 10 in tasmota console

Or tper=10 in script