From fb1d72a4a4a921bf07ee6d0d082827a38d133fba Mon Sep 17 00:00:00 2001 From: Baptiste Poirriez Date: Thu, 27 Oct 2016 10:57:53 +0200 Subject: [PATCH 1/2] Adding documentation for influxdb sensor --- source/_components/sensor.influxdb.markdown | 71 +++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 source/_components/sensor.influxdb.markdown diff --git a/source/_components/sensor.influxdb.markdown b/source/_components/sensor.influxdb.markdown new file mode 100644 index 000000000000..2e5e849a90bb --- /dev/null +++ b/source/_components/sensor.influxdb.markdown @@ -0,0 +1,71 @@ +--- +layout: page +title: "InfluxDB Sensor" +description: "Instructions how to integrate InfluxDB sensors within Home Assistant." +date: 2016-10-26 23:15 +sidebar: true +comments: false +sharing: true +footer: true +logo: influxdb.png +ha_category: Sensor +ha_release: 0.32 +--- + +The `InfluxDB` sensor allows you to use values from an InfluxDB database to populate a sensor state. + +To configure this sensor, you need to define the sensor connection variables and a list of queries. A sensor will be created for each query. + +Configuration variables for the server: + +- **host** (*Optional*): IP address of your database host, eg. http://192.168.1.10. Defaults to `localhost`. +- **port** (*Optional*): Port to use. Defaults to 8086. +- **username** (*Optional*): The username of the database user. +- **password** (*Optional*): The password for the database user account. +- **ssl** (*Optional*): Use https instead of http to connect. Defaults to false. +- **verify_ssl** (*Optional*): Verify SSL certificate for https request. Defaults to false. +- **queries** (*Required*): List of queries + +Configuration variables for the queries: +- **name** (*Required*): The name of the sensor, +- **unit_of_measurement** (*Required*): Defines the units of measurement of the sensor, +- **measurement** (*Required*): Defines the measurement name in InfluxDB (the from clause of the query), +- **where** (*Required*): Defines the data selection clause (the where clause of the query), +- **value_template** (*Optional*): Defines a [template](/topics/templating/) to extract a value from the payload. +- **database** (*Optional*): Name of the database to use. Defaults to `home_assistant`, +- **group_function** (*Optional*): The group function to be used, default to `mean` +- **field** (*Optional*): The field name to select, default to value. + +## {% linkable_title Examples %} + + +### {% linkable_title Full configuration %} +The example configuration entry bellow create two request to influx db, one to the database db1, the other to db2 : + +- `select last(value) as value from "°C" where "name" = "foo"` +- `select min(tmp) as value from "%" where "entity_id" = ''salon'' and time > now() - 1h` + +```yaml +sensor: + platform: influxdb + host: localhost + username: home-assistant + password: password + queries: + - name: last value of foo + unit_of_measurement: °C + value_template: '{{ value | round(1) }}' + group_function: last + where: '"name" = ''foo''' + measurement: '"°C"' + field: value + database: db1 + - name: Min for last hour + unit_of_measurement: '%' + value_template: '{{ value | round(1) }}' + group_function: min + where: '"entity_id" = ''salon'' and time > now() - 1h' + measurement: '"%"' + field: tmp + database: db2 +``` \ No newline at end of file From ad4bd1362731050b2304013b1ed80a6ec1c9fe3c Mon Sep 17 00:00:00 2001 From: Baptiste Poirriez Date: Thu, 27 Oct 2016 11:28:08 +0200 Subject: [PATCH 2/2] Minimal configuration exemple and fix for host variable (ip address without http) --- source/_components/influxdb.markdown | 2 +- source/_components/sensor.influxdb.markdown | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/source/_components/influxdb.markdown b/source/_components/influxdb.markdown index d8e28d958335..889afd56a707 100644 --- a/source/_components/influxdb.markdown +++ b/source/_components/influxdb.markdown @@ -25,7 +25,7 @@ You will still need to create a database named `home_assistant` via InfluxDB's w Configuration variables: -- **host** (*Optional*): IP address of your database host, eg. http://192.168.1.10. Defaults to `localhost`. +- **host** (*Optional*): IP address of your database host, eg. 192.168.1.10. Defaults to `localhost`. - **port** (*Optional*): Port to use. Defaults to 8086. - **username** (*Optional*): The username of the database user. - **password** (*Optional*): The password for the database user account. diff --git a/source/_components/sensor.influxdb.markdown b/source/_components/sensor.influxdb.markdown index 2e5e849a90bb..ec6e47ff37b0 100644 --- a/source/_components/sensor.influxdb.markdown +++ b/source/_components/sensor.influxdb.markdown @@ -18,7 +18,7 @@ To configure this sensor, you need to define the sensor connection variables and Configuration variables for the server: -- **host** (*Optional*): IP address of your database host, eg. http://192.168.1.10. Defaults to `localhost`. +- **host** (*Optional*): IP address of your database host, eg. 192.168.1.10. Defaults to `localhost`. - **port** (*Optional*): Port to use. Defaults to 8086. - **username** (*Optional*): The username of the database user. - **password** (*Optional*): The password for the database user account. @@ -37,7 +37,18 @@ Configuration variables for the queries: - **field** (*Optional*): The field name to select, default to value. ## {% linkable_title Examples %} - +### {% linkable_title Minimal configuration %} +The example configuration below will create a request to influx db to the default database (`home_assistant`) to get the mean value of `foo` in measurement `°C` + +```yaml +sensor: + - platform: influxdb + queries: + - name: mean value of foo + unit_of_measurement: °C + where: '"name" = ''foo''' + measurement: '"°C"' +``` ### {% linkable_title Full configuration %} The example configuration entry bellow create two request to influx db, one to the database db1, the other to db2 :