dyrkin / tasmota-exporter

A Prometheus exporter for Tasmota-enabled devices
32 stars 11 forks source link

Shelly 2.5 not getting some energy metrics because of 2 outputs #9

Open c4talyst opened 10 months ago

c4talyst commented 10 months ago

Summary

Using a Shelly2.5 with Tasmota 13.2.0 and not getting some energy stats.

Hypothesis

Assuming not working because it's a list of stats in the StatusSNS object; because the Shelly2.5 has 2 outputs.

Issue

Status0 includes this message, note the list of values in ApparentPower as example.

    "StatusSNS": {
        "Time": "2023-11-28T09:52:58",
        "Switch1": "OFF",
        "Switch2": "OFF",
        "ANALOG": {"Temperature": 50.8},
        "ENERGY": {
            "TotalStartTime": "2022-05-12T09:30:00",
            "Total": 0.0,
            "Yesterday": 0.0,
            "Today": 0.0,
            "Power": [6, 0],
            "ApparentPower": [12, 0],
            "ReactivePower": [1, 0],
            "Factor": [0.54, 0.0],
            "Frequency": 50.101,
            "Voltage": 226.343,
            "Current": [0.052, 0.0]
        },
        "TempUnit": "C"
    },

This is what I'm getting in prometheus image

# HELP tasmota_status_sns_analog_temperature 
# TYPE tasmota_status_sns_analog_temperature gauge
tasmota_status_sns_analog_temperature{source="stat/tasmota_034EF5",status_device_name="Shelly2.5-Grid",status_net_hostname="tasmota-034EF5-3829",status_topic="tasmota_034EF5"} 62.4
# HELP tasmota_status_sns_energy_frequency 
# TYPE tasmota_status_sns_energy_frequency gauge
tasmota_status_sns_energy_frequency{source="stat/tasmota_034EF5",status_device_name="Shelly2.5-Grid",status_net_hostname="tasmota-034EF5-3829",status_topic="tasmota_034EF5"} 49.822
# HELP tasmota_status_sns_energy_today 
# TYPE tasmota_status_sns_energy_today gauge
tasmota_status_sns_energy_today{source="stat/tasmota_034EF5",status_device_name="Shelly2.5-Grid",status_net_hostname="tasmota-034EF5-3829",status_topic="tasmota_034EF5"} 0.003
# HELP tasmota_status_sns_energy_total 
# TYPE tasmota_status_sns_energy_total gauge
tasmota_status_sns_energy_total{source="stat/tasmota_034EF5",status_device_name="Shelly2.5-Grid",status_net_hostname="tasmota-034EF5-3829",status_topic="tasmota_034EF5"} 0.003
# HELP tasmota_status_sns_energy_voltage 
# TYPE tasmota_status_sns_energy_voltage gauge
tasmota_status_sns_energy_voltage{source="stat/tasmota_034EF5",status_device_name="Shelly2.5-Grid",status_net_hostname="tasmota-034EF5-3829",status_topic="tasmota_034EF5"} 225.237
# HELP tasmota_status_sns_energy_yesterday 
# TYPE tasmota_status_sns_energy_yesterday gauge
tasmota_status_sns_energy_yesterday{source="stat/tasmota_034EF5",status_device_name="Shelly2.5-Grid",status_net_hostname="tasmota-034EF5-3829",status_topic="tasmota_034EF5"} 0

Expected

Perhaps a label for each output (removed other labels for brevity)

tasmota_status_sns_energy_current{status_output="1"} 0.052
tasmota_status_sns_energy_current{status_output="2"} 0

Will try check it out if I have time!

dyrkin commented 10 months ago

Would it be ok if we have tasmota_status_sns_energy_current1 and tasmota_status_sns_energy_current2 instead of adding tags? In this case metrics/extractor.go could be easily extended to support the case, otherwise, this needs more code to be updated.

c4talyst commented 10 months ago

I guess it would work - I'd need to just think how it might impact templated dashboards in Grafana

You'd need to cater for all, instead of just the one. Not sure how prevalent this problem is though with devices with multiple outputs

tasmota_status_sns_energy_current
tasmota_status_sns_energy_current1 
tasmota_status_sns_energy_current2
...
tasmota_status_sns_energy_currentetc
dyrkin commented 10 months ago

Ah, I see. I've thought that it is possible to use wildcards in metric names, but it seems it doesn't work like this. Adding tags would be a good solution