Tasmota Energy Meter

Tasmota Smart Meter Interface can be used to intregrate energymeters. It's based on the Tasmota scripting language.

Tasmota

The Smart Meter Interface is not included in the precompiled binaries, so we have to compile our own.

The following features needs to be defined:

#ifndef USE_SCRIPT
#define USE_SCRIPT
#endif
#ifndef USE_SML_M
#define USE_SML_M
#endif
#ifdef USE_RULES
#undef USE_RULES
#endif

Tasmota script

I followed a few examples and made this script. It sends a trigger message to the meter and can also change the baudrate after initiated. After that we simply look for a OBIS code that represent the data we want and map that to a sensor.

>D
res=0  
scnt=0    
;For this Example in the >F section  
>F
;count 100ms   
scnt+=1  
switch scnt  
case 6  
;set sml driver to 300 baud and send /?! as HEX to trigger the Meter   
res=sml(1 0 300)  
res=sml(1 1 "2F3F210D0A")  
;1800ms later \> Send ACK and ask for switching to 9600 baud  
case 18  
:res=sml(1 1 "063035300D0A")  
;2000ms later \> Switching sml driver to 9600 baud    
case 20  
res=sml(1 0 300)   
;Restart sequence after 50x100ms    
case 50  
; 5000ms later \> restart sequence    
scnt=0  
ends        
>M 1
+1,3,o,0,300,KMP
1,1.8.0(@1,Total consumption,kWh,Total_in,4`  

Home Assistant

To get the data into Home Assistant we define a MQTT sensor and get the value in the json message.

In configuration.yaml add:

mqtt:
  sensor:
  - name: "Total consumption"
    state_topic: "tele/tasmota_8AEC62/SENSOR"
    value_template: "{{ value_json.KMP.Total_in }}"
    unit_of_measurement: "kWh"
    state_class: total
    unique_id: meter_1234
    device_class: energy

Contact me