jaketbd/tasmoprom

By jaketbd

Updated 7 months ago

Prometheus Exporter for Tasmota Energy Data

Image
Databases & Storage
Internet of Things
Web Servers

41

TasmoProm

https://github.com/jaketbd/tasmoprom

Prometheus Exporter for Tasmota Energy Data

TasmoProm is a server that helps you get energy statistics from your Tasmota devices into Prometheus for monitoring and analysis. It does this by directly scraping the data from the Tasmota web interface, making it easy to set up and get started quickly.

Key Points:

  • No additional server (like Mosquitto) required.
  • Faster updates, the update via mqtt is limited to 10 seconds, the WebUI updates approximately every 3 seconds.
  • Use blueprints to customize the scraping process for different Tasmota devices and setups.
  • Comes with a template that works with NOUS A1T (v13.4.0) out of the box.

Installation

docker pull jaketbd/tasmoprom:1.1-linux-<amd64/arm64>

Configuration

The default location for the configuration file is /etc/tasmoprom/config.yaml.

You can change the path to the configuration file with the TASMOPROM_CONFIG_FILE_PATH variable

Top-Level Configuration
  • log_mode: Controls the verbosity of logs. Options:
    • debug: Most detailed logs, including debugging information
    • info: General events and information (default)
    • error: Logs only errors
  • web: Configures the built-in web server for Prometheus metrics.
    • addr: Address and port to listen on (default: :2112)
    • path: Path to expose metrics on (default: /metrics)
  • blueprints: Defines the blueprints to use for scraping Tasmota devices.
  • jobs: Defines the jobs to run, which include the devices to scrape and the blueprint to use
Blueprint Configuration

The blueprints can be used to adapt the scraping to other devices and the scope of the collected data

  • name: Name of the blueprint
  • specs: List of specifications to scrape
    • metric_name: Name of the metric in Prometheus
    • selector: CSS selector to find the value in the HTML
    • remap_values: Optional mapping of values to other values
    • error_value: Value to use if the selector is not found or if an error occurs (default: -1)
Job Configuration

The jobs define the devices to scrape and the blueprint to use for each device.

  • name: Name of the job
  • namespace: Namespace to use for the metrics
  • subsystem: Subsystem to use for the metrics
  • interval: Interval as a duration string (e.g. 10s, 1m, 1h) (default: 5s)
  • blueprint_name: Name of the blueprint to use (if not specified, the default blueprint is used)
  • host: Hostname or IP address of the Tasmota device (scheme and port are required)
  • path: Path to the Tasmota web interface (default: /?m=1)

NOTE: The metric name provided to prometheus is created from the name of the blueprint specification and the name of the scrape job. For example, if the blueprint specification is named voltage and the job is named plug1, the metric name will be plug1_voltage.

Default Blueprint

The default blueprint is a template that works with the NOUS A1T (v13.4.0) out of the box.

name: default
specs:
  - metric_name: voltage
    selector: table:nth-of-type(2) tr:nth-child(2) td:nth-child(3)
  - metric_name: current
    selector: table:nth-of-type(2) tr:nth-child(3) td:nth-child(3)
  - metric_name: active_power
    selector: table:nth-of-type(2) tr:nth-child(4) td:nth-child(3)
  - metric_name: apparent_power
    selector: table:nth-of-type(2) tr:nth-child(5) td:nth-child(3)
  - metric_name: reactive_power
    selector: table:nth-of-type(2) tr:nth-child(6) td:nth-child(3)
  - metric_name: power_actor
    selector: table:nth-of-type(2) tr:nth-child(7) td:nth-child(3)
  - metric_name: energy_today
    selector: table:nth-of-type(2) tr:nth-child(8) td:nth-child(3)
  - metric_name: energy_yesterday
    selector: table:nth-of-type(2) tr:nth-child(9) td:nth-child(3)
  - metric_name: energy_total
    selector: table:nth-of-type(2) tr:nth-child(10) td:nth-child(3)
  - metric_name: state
    selector: table:nth-of-type(4) tr td
    remap_values:
      OFF: 0
      ON: 1

Example Configuration

jobs:
  - name: plug1
    host: http://1.2.3.1
  - name: plug2
    host: http://1.2.3.2
  - name: plug3
    host: http://1.2.3.3
  - name: plug4
    host: http://1.2.3.4

Changelog

  • 1.1
    • Added option to add http metadata like response code and time. (jobs.include_metadata)

Docker Pull Command

docker pull jaketbd/tasmoprom