name: sdm120
description: Eastron SDM120 single-phase energy meter
function_code: 4          # input registers (FC04)
word_order: big           # high register first (big-endian word order)
byte_order: big           # high byte first within each register

blocks:
  # Registers 30001–30095 (0x0000–0x005F): voltage through max export demand
  - { start: 0x0000, count: 0x0060 }
  # Registers 30343–30346 (0x0156–0x0159): total active/reactive energy
  - { start: 0x0156, count: 0x0004 }

metrics:
  # Core measurements — addresses from SDM120 Modbus Protocol §4 (FC04 input registers)
  # Each float32 occupies two consecutive 16-bit registers; address = Hex start in §4.

  - key: voltage
    address: 0x0000        # register 30001 — Voltage (V)
    type: float32
    unit: "V"
    device_class: voltage
    ha_component: sensor

  - key: current
    address: 0x0006        # register 30007 — Current (A)
    type: float32
    unit: "A"
    device_class: current
    ha_component: sensor

  - key: active_power
    address: 0x000C        # register 30013 — Active power (W)
    type: float32
    unit: "W"
    device_class: power
    ha_component: sensor

  - key: power_factor
    address: 0x001E        # register 30031 — Power factor (dimensionless)
    type: float32
    unit: ""
    device_class: power_factor
    ha_component: sensor

  - key: frequency
    address: 0x0046        # register 30071 — Frequency (Hz)
    type: float32
    unit: "Hz"
    device_class: frequency
    ha_component: sensor

  - key: import_energy
    address: 0x0048        # register 30073 — Import active energy (kWh)
    type: float32
    unit: "kWh"
    device_class: energy
    state_class: total_increasing
    ha_component: sensor

  - key: export_energy
    address: 0x004A        # register 30075 — Export active energy (kWh)
    type: float32
    unit: "kWh"
    device_class: energy
    state_class: total_increasing
    ha_component: sensor

  - key: total_energy
    address: 0x0156        # register 30343 — Total active energy (kWh)
    type: float32
    unit: "kWh"
    device_class: energy
    state_class: total_increasing
    ha_component: sensor
