hikhvar / mqtt2prometheus

MQTT to Prometheus gateway
MIT License
350 stars 69 forks source link

Feature request: Support for boolean / non-string datatype mappings #103

Open hacker-h opened 1 year ago

hacker-h commented 1 year ago

I saw the string_value_mapping so something similar or a solution for generic data types should be possible.

This would support more sensors like motion, contact, water etc.

example config:

metrics:
  - prom_name: contact
    mqtt_name: contact
    sensor_name_filter: "^Contact[0-]+$"
    help: Door/Window Contact Sensor
    type: gauge
    bool_value_mapping:
      # A map of bool to metric value.
      map:
        false: 0
        true: 1
      # Metric value to use if a match cannot be found in the map above.
      # If not specified, parsing error will occur.
      error_value: 2
    const_labels:
      sensor_type: aqara
hikhvar commented 1 year ago

Will happily review any pull request in that direction.