Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration example for Shelly 3em Energy Meter #96

Closed
brainsht opened this issue Aug 31, 2022 · 3 comments
Closed

Add configuration example for Shelly 3em Energy Meter #96

brainsht opened this issue Aug 31, 2022 · 3 comments

Comments

@brainsht
Copy link

Hi,

I've spent some time to figure out how to configure mqtt2prometheus for my Shelly 3em Energy Meter.
Guess this might be usefull to others as well and could be inlcuded in the configuration examples.

Shelly 3em metrics example

$ mosquitto_sub -t "shellies/shellyem3-123456789/emeter/+/+" -v

shellies/shellyem3-123456789/emeter/0/power 41.25
shellies/shellyem3-123456789/emeter/0/pf 0.18
shellies/shellyem3-123456789/emeter/0/current 0.99
shellies/shellyem3-123456789/emeter/0/voltage 232.25
shellies/shellyem3-123456789/emeter/0/total 13372.4
shellies/shellyem3-123456789/emeter/0/total_returned 0.0
shellies/shellyem3-123456789/emeter/1/power 275.04
shellies/shellyem3-123456789/emeter/1/pf 0.72
shellies/shellyem3-123456789/emeter/1/current 1.65
shellies/shellyem3-123456789/emeter/1/voltage 232.83
shellies/shellyem3-123456789/emeter/1/total 27948.4
shellies/shellyem3-123456789/emeter/1/total_returned 0.0
shellies/shellyem3-123456789/emeter/2/power -2.23
shellies/shellyem3-123456789/emeter/2/pf -0.02
shellies/shellyem3-123456789/emeter/2/current 0.39
shellies/shellyem3-123456789/emeter/2/voltage 233.14
shellies/shellyem3-123456789/emeter/2/total 4107.8
shellies/shellyem3-123456789/emeter/2/total_returned 186.9

shelly_3em.yaml configuration

# Settings for the MQTT Client. Currently only these three are supported
mqtt:
  # The MQTT broker to connect to
  server: tcp://127.0.0.1:1883
  # Optional: Username and Password for authenticating with the MQTT Server
  # user: bob
  # password: happylittleclouds
  
  # The Topic path to subscribe to. Be aware that you have to specify the wildcard.
  topic_path: shellies/shellyem3-123456789/emeter/+/+

  # Use the phase number as device_id in order to see all three phases in /metrics
  device_id_regex: "shellies/(.*)/emeter/(?P<deviceid>.*)/.*"

  # Metrics are being published on a per-topic basis.
  metric_per_topic_config:
    metric_name_regex: "shellies/(?P<deviceid>.*)/emeter/(.*)/(?P<metricname>.*)"
  # The MQTT QoS level
  qos: 0
cache:
  timeout: 60m

metrics:
  - prom_name: power
    mqtt_name: power
    type: gauge
    const_labels:
      sensor_type: shelly

  - prom_name: voltage
    mqtt_name: voltage
    type: gauge
    const_labels:
      sensor_type: shelly

Result in /metrics. Label "sensor" = energy meter phase

# HELP power 
# TYPE power gauge
power{sensor="0",sensor_type="shelly",topic="shellies/shellyem3-123456789/emeter/0/power"} 35.4 1661984533463
power{sensor="1",sensor_type="shelly",topic="shellies/shellyem3-123456789/emeter/1/power"} 401.45 1661984533465
power{sensor="2",sensor_type="shelly",topic="shellies/shellyem3-123456789/emeter/2/power"} -2.31 1661984533467
# TYPE received_messages counter
received_messages{status="success",topic="shellies/shellyem3-123456789/emeter/0/current"} 4
received_messages{status="success",topic="shellies/shellyem3-123456789/emeter/0/pf"} 4
received_messages{status="success",topic="shellies/shellyem3-123456789/emeter/0/power"} 4
received_messages{status="success",topic="shellies/shellyem3-123456789/emeter/0/total"} 4
received_messages{status="success",topic="shellies/shellyem3-123456789/emeter/0/total_returned"} 4
received_messages{status="success",topic="shellies/shellyem3-123456789/emeter/0/voltage"} 4
received_messages{status="success",topic="shellies/shellyem3-123456789/emeter/1/current"} 4
received_messages{status="success",topic="shellies/shellyem3-123456789/emeter/1/pf"} 4
received_messages{status="success",topic="shellies/shellyem3-123456789/emeter/1/power"} 4
received_messages{status="success",topic="shellies/shellyem3-123456789/emeter/1/total"} 4
received_messages{status="success",topic="shellies/shellyem3-123456789/emeter/1/total_returned"} 4
received_messages{status="success",topic="shellies/shellyem3-123456789/emeter/1/voltage"} 4
received_messages{status="success",topic="shellies/shellyem3-123456789/emeter/2/current"} 4
received_messages{status="success",topic="shellies/shellyem3-123456789/emeter/2/pf"} 4
received_messages{status="success",topic="shellies/shellyem3-123456789/emeter/2/power"} 4
received_messages{status="success",topic="shellies/shellyem3-123456789/emeter/2/total"} 4
received_messages{status="success",topic="shellies/shellyem3-123456789/emeter/2/total_returned"} 4
received_messages{status="success",topic="shellies/shellyem3-123456789/emeter/2/voltage"} 4
# HELP voltage 
# TYPE voltage gauge
voltage{sensor="0",sensor_type="shelly",topic="shellies/shellyem3-123456789/emeter/0/voltage"} 231.78 1661984533464
voltage{sensor="1",sensor_type="shelly",topic="shellies/shellyem3-123456789/emeter/1/voltage"} 232.46 1661984533466
voltage{sensor="2",sensor_type="shelly",topic="shellies/shellyem3-123456789/emeter/2/voltage"} 232.71 1661984533468
@hikhvar
Copy link
Owner

hikhvar commented Sep 1, 2022

I would like to have the given config beneath /examples as a PR.

@hikhvar
Copy link
Owner

hikhvar commented Jan 2, 2023

Fixed in #114

@hikhvar hikhvar closed this as completed Jan 2, 2023
@pdostal
Copy link
Contributor

pdostal commented Jan 21, 2024

Hello,

I'm planning to deploy Shelly 3EM Pro in several days so I'm grateful for this example.
I however will have multiple of those devices so instead of hardcoding the device name I will need to find a better solution.

If you have an idea feel free to reply here otherwise I will attempt to make this example more universal later.

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants