SML (Smart Meter Language)
SML (Smart Meter Language) is a binary protocol used by smart electricity meters, primarily in Germany. It’s commonly found on meters with an optical interface (the small infrared port with a flashing LED). energy2mqtt can decode SML messages and publish the meter readings to Home Assistant.
Details
SML is standardized in Germany through BSI TR-03109. If your electricity meter has a small optical interface with a blinking LED, it likely supports SML.
How SML Works
Smart meters with SML periodically output data through their optical (infrared) interface. A reading head attached to the meter converts these light pulses into serial data, which is then forwarded to energy2mqtt via MQTT.
Typical Setup
Common IR reading heads:
- Hichi IR reading head (TTL/USB)
- VolkszΓ€hler IR head
- Bitshake Smartmeter Interface
- DIY reading heads with phototransistor
What SML Provides
Depending on your meter model and configuration, SML can provide:
| Data | Description | Typical Update |
|---|---|---|
| Total energy consumed | Meter reading (kWh) | Every message |
| Total energy delivered | For solar feed-in (kWh) | Every message |
| Current power | Instantaneous power (W) | Every 1-2 seconds |
| Voltage per phase | L1, L2, L3 (V) | Every message |
| Current per phase | L1, L2, L3 (A) | Every message |
| Power factor | cos(Ο) | Every message |
| Frequency | Grid frequency (Hz) | Every message |
Details
Not all data is available by default. Some meters require a PIN from your utility to unlock detailed readings. Contact your energy provider to request the PIN.
Protocol Details
Message Structure
SML messages are wrapped in a specific frame format:
Message Types
A typical SML transmission contains multiple messages:
| Type | Description |
|---|---|
| OpenResponse | Start of communication |
| GetListResponse (0x701) | Actual meter data |
| CloseResponse | End of communication |
| AttentionResponse (0x901) | Error or status notifications |
energy2mqtt focuses on the GetListResponse which contains the actual readings.
OBIS Codes
Meter values are identified by OBIS codes - a standardized addressing scheme:
Common OBIS codes:
| OBIS Code | Description |
|---|---|
1-0:1.8.0 |
Total active energy consumed (kWh) |
1-0:2.8.0 |
Total active energy delivered (kWh) |
1-0:16.7.0 |
Current total power (W) |
1-0:36.7.0 |
Current power L1 (W) |
1-0:56.7.0 |
Current power L2 (W) |
1-0:76.7.0 |
Current power L3 (W) |
1-0:32.7.0 |
Voltage L1 (V) |
1-0:52.7.0 |
Voltage L2 (V) |
1-0:72.7.0 |
Voltage L3 (V) |
1-0:31.7.0 |
Current L1 (A) |
1-0:51.7.0 |
Current L2 (A) |
1-0:71.7.0 |
Current L3 (A) |
1-0:14.7.0 |
Grid frequency (Hz) |
1-0:13.7.0 |
Power factor |
Unit Codes
Values include a unit code that energy2mqtt translates:
| Code | Unit | Description |
|---|---|---|
| 27 | Wh | Watt hours |
| 28 | kWh | Kilowatt hours |
| 30 | W | Watts |
| 31 | kW | Kilowatts |
| 37 | V | Volts |
| 40 | A | Amperes |
| 48 | Hz | Hertz |
| 9 | Β°C | Celsius |
Supported Meters
energy2mqtt includes built-in support for these meter types:
EMH Meters
Models: ED300L, ED300S, and similar
Common in many German utility areas. Identified by “EMH” in the meter ID or ID starting with “1E”.
Typical readings:
- Total energy (consumed/delivered)
- Current power
- Voltage and current per phase
- Frequency
Iskraemeco Meters
Models: MT175, MT631
Popular smart meters with detailed phase information. Identified by “ISK” in the meter ID.
Typical readings:
- Energy with tariff support (T1/T2)
- Reactive power
- Detailed phase measurements
Itron Meters
Models: OpenWay 3.HZ
Identified by “ITR” in the meter ID.
EasyMeter
Various models with SML support. Identified by “EAS” in the meter ID.
Generic Support
If your meter isn’t specifically recognized, energy2mqtt falls back to generic OBIS code parsing. Most standard readings will still work.
Details
You can check which meter type was detected in the energy2mqtt logs. If your meter uses non-standard OBIS codes, please open an issue on GitHub.
Configuration
SML requires minimal configuration in energy2mqtt. The meter type is auto-detected from the data.
MQTT Input
energy2mqtt listens for SML data on the MQTT topic:
The message should contain the raw SML data as a hex-encoded string.
Getting Data to MQTT
You need a tool to read from your IR reading head and publish to MQTT. Popular options:
Option 1: sml2mqtt
A dedicated tool for reading SML and publishing to MQTT:
Details
TODO: Add complete sml2mqtt configuration example and link to installation guide.
Option 2: Custom Script
A simple Python script to read and forward SML data:
Details
This is a simplified example. Production code should handle SML framing, error recovery, and reconnection.
No Configuration Needed
Unlike OMS or Modbus, SML doesn’t require explicit meter configuration in e2m.yaml. The protocol is self-describing:
- Meter ID is included in the message
- OBIS codes identify each value
- Units are included with values
energy2mqtt automatically:
- Identifies the meter type from the ID
- Parses all available values
- Creates Home Assistant entities
Output Data
energy2mqtt publishes decoded SML data via MQTT. Example output:
| Field | Example Value | Unit |
|---|---|---|
total_energy_consumed |
12345.678 | kWh |
total_energy_delivered |
1234.567 | kWh |
current_power |
1523 | W |
voltage_l1 |
230.4 | V |
voltage_l2 |
231.2 | V |
voltage_l3 |
229.8 | V |
current_l1 |
2.34 | A |
current_l2 |
1.89 | A |
current_l3 |
3.12 | A |
frequency |
50.01 | Hz |
manufacturer |
EMH | - |
device_id |
1EMH0012345678 | - |
PIN Unlock
Many German smart meters require a PIN to unlock detailed readings (like current power and phase values). Without the PIN, you may only see basic energy totals.
Getting Your PIN
- Contact your electricity provider (Netzbetreiber)
- Request the “Kundenschnittstelle PIN” or “HAN PIN”
- They’re legally required to provide it (in Germany)
Entering the PIN
The PIN entry is done on the meter itself, not in energy2mqtt:
- Press the button on your meter (or use a flashlight)
- Navigate to the PIN entry menu
- Enter your 4-digit PIN
- The meter unlocks detailed readings
After unlocking, SML messages will include all available data automatically.
Details
Once unlocked, the meter stays unlocked. You don’t need to re-enter the PIN unless the meter is reset or replaced.
Troubleshooting
No Data Received
Check your reading head:
- Is it properly attached to the meter?
- Is the LED on the reading head responding to the meter’s flashes?
- Try repositioning the reading head
Check serial connection:
You should see hex data appearing every 1-2 seconds.
Partial Data Only
Only seeing energy totals?
- Your meter is likely PIN-locked
- Request the PIN from your utility provider
Missing phases?
- Single-phase meters don’t report L2/L3
- Some meters need firmware updates
CRC Errors
“CRC verification failed”
- Interference on the serial line
- Reading head not properly aligned
- Try a shielded USB cable
Wrong Values
Values seem off?
- Check if the scaler is being applied correctly
- Verify the unit (Wh vs kWh, W vs kW)
- Compare with your meter’s display
Hardware Recommendations
IR Reading Heads
| Product | Price Range | Notes |
|---|---|---|
| Hichi IR USB | ~β¬15 | Popular, works well |
| Bitshake | ~β¬30 | High quality |
| VolkszΓ€hler | ~β¬10 | DIY-friendly |
| DIY | ~β¬5 | Phototransistor + resistor |
Connection Tips
- Use a short USB cable (< 2m) to avoid signal issues
- Magnetic mounting helps with alignment
- Shield the reading head from ambient light
Details
If you’re getting intermittent data, try adding a small piece of dark tape around the reading head to block ambient light.
Example: Complete Setup
Here’s a complete example of reading a German smart meter with energy2mqtt:
1. Hardware Setup
- Attach IR reading head to meter’s optical interface
- Connect reading head to Raspberry Pi via USB
- Note the serial port (usually
/dev/ttyUSB0)
2. Install sml2mqtt
3. Configure sml2mqtt
Create /etc/sml2mqtt.yaml:
Details
TODO: Verify exact sml2mqtt configuration parameters and add systemd service file example.
4. Start Reading
5. Verify in Home Assistant
After a few seconds, new entities should appear in Home Assistant under the auto-discovered meter device.