From c854742525a2a373dfb7d3e6df1e709d75be3cb4 Mon Sep 17 00:00:00 2001 From: Pieter Rautenbach Date: Wed, 22 Sep 2021 11:55:21 +0200 Subject: [PATCH] Added a CSV example (#19318) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Joakim Sørensen --- source/_integrations/file.markdown | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/source/_integrations/file.markdown b/source/_integrations/file.markdown index 2be2e1855fc..c9f4c9bc856 100644 --- a/source/_integrations/file.markdown +++ b/source/_integrations/file.markdown @@ -115,3 +115,30 @@ sensor: ``` {% endraw %} + +#### Entries as CSV + +Assuming the log file contains multiple values formatted as CSV like shown below: + +```text +timestamp,temperature,humidity +1631472948,21,39 +1631472949,22,36 +``` + +This would require the following entry in the `configuration.yaml` file to extract the temperature: + +{% raw %} + +```yaml +# Example configuration.yaml entry +sensor: + - platform: file + name: Temperature + file_path: /home/user/.homeassistant/sensor.csv + value_template: '{{ value.split(",")[1] }}' + unit_of_measurement: "°C" +``` + +{% endraw %} +