mirror of
https://github.com/nikdoof/homeassistant-prometheus-query.git
synced 2025-12-18 04:59:21 +00:00
85d4acb2293e98d47b8615d415c9e4a7f35eef77
Goal is to be usable as a source of energy in the energy dashboard. Starting with HA 2021.9 (still in beta), sensors will be have long term stats and be usable in energy dashboard. It also gives a better integration with base classes of home assistant and decrease code in this custom component. Change-Id: Ide1967ac181c0cf7f093cff539aae2b1cdccd9b4
homeassistant-prometheus-query
Inspired from homeassitant Command line Sensor this sensor take values from Prometheus metrics using PromQL query . It allow to specify one or more query creating a sensors for each query.
Configuration
To enable it, add the following lines to your configuration.yaml:
# Example configuration.yaml entry
sensor:
- platform: prometheus_query
name: Temperature Pisa
prometheus_url: http://localhost:9090
prometheus_query: temperature{location="Pisa",province="PI",region="Tuscany"}
unit_of_measurement: "°C"
state_class: total_increasing
Configuration Variables
- name
(string)(Required) Name of the sensor..
- prometheus_url
(string)(Required) the url of your Prometheus server
- prometheus_query
(string)(Required) the PromQL query to retrieve sensor
- unit_of_measurement
(string)(Optional) Defines the unit of measurement of the sensor, if any.
-
state_class
(string)(Optional) Defines the type of sensor.
measurementfor metrics that are gauges,total_increasingfor metrics that are counters.
It's a custom component so it must be downloaded under /custom_components folder.
Description
Languages
Python
100%