# Smart Energy Meter Simulation
# Simulates smart electricity meters sending readings over MQTT.
# Includes per-phase measurements for three-phase meters.
#
# Usage:
#   mer mqtt run -f examples/energy-meter.yaml

protocol: mqtt

target:
  broker: "mqtt://localhost:1883"
  topic: "meters/{device_id}/reading"
  client_id: "mer-energy"
  qos: 1
  retain: true

device:
  count: 5
  id_prefix: meter

payload:
  mode: template
  template_inline: |
    {
      "meter_id": "{{device_id}}",
      "ts": "{{now_utc}}",
      "seq": {{seq}},
      "phase_a": {
        "voltage_v": {{random_float 218.0 242.0}},
        "current_a": {{random_float 0.0 63.0}},
        "power_w": {{random_float 0.0 14000.0}},
        "power_factor": {{random_float 0.7 1.0}}
      },
      "phase_b": {
        "voltage_v": {{random_float 218.0 242.0}},
        "current_a": {{random_float 0.0 63.0}},
        "power_w": {{random_float 0.0 14000.0}},
        "power_factor": {{random_float 0.7 1.0}}
      },
      "phase_c": {
        "voltage_v": {{random_float 218.0 242.0}},
        "current_a": {{random_float 0.0 63.0}},
        "power_w": {{random_float 0.0 14000.0}},
        "power_factor": {{random_float 0.7 1.0}}
      },
      "total_active_power_w": {{random_float 0.0 42000.0}},
      "total_energy_kwh": {{random_float 0.0 100000.0}},
      "frequency_hz": {{random_float 49.9 50.1}},
      "tariff": {{random_int 1 3}}
    }

run:
  total_messages: 30
  interval_ms: 2000
