From 24834196bc7a7152c0940a4c9e379dd1bd22c359 Mon Sep 17 00:00:00 2001 From: Klaas Schoute Date: Thu, 25 Apr 2019 23:10:36 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=9C=20Merges/Redirects=20File=20compon?= =?UTF-8?q?ent=20pages=20(#9305)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🚜 Merges/Redirects File component pages * :pencil2: Tweak --- source/_components/file.markdown | 77 ++++++++++++++++++++++++- source/_components/sensor.file.markdown | 73 ----------------------- 2 files changed, 74 insertions(+), 76 deletions(-) delete mode 100644 source/_components/sensor.file.markdown diff --git a/source/_components/file.markdown b/source/_components/file.markdown index aa9ccaaf3cc..56a35c24e9e 100644 --- a/source/_components/file.markdown +++ b/source/_components/file.markdown @@ -1,19 +1,31 @@ --- layout: page title: "File" -description: "Instructions on how to add file notifications to Home Assistant." +description: "Instructions on how to integrate sensors which read from files into Home Assistant." date: 2015-06-22 10:00 sidebar: true comments: false sharing: true footer: true logo: file.png -ha_category: Notifications +ha_category: + - Utility + - Notifications + - Sensor ha_release: pre 0.7 +ha_iot_class: Local Polling redirect_from: - - /components/notify.file/ + - /components/notify.file/ + - /components/sensor.file/ --- +There is currently support for the following device types within Home Assistant: + +- [Notifications](#notifications) +- [Sensor](#sensor) + +## {% linkable_title Notifications %} + The `file` platform allows you to store notifications from Home Assistant as a file. To enable file notifications in your installation, add the following to your `configuration.yaml` file: @@ -44,3 +56,62 @@ timestamp: {% endconfiguration %} To use notifications, please see the [getting started with automation page](/getting-started/automation/). + +## {% linkable_title Sensor %} + +The `file` sensor platform reads the entries from a plain-text file and shows the found value. Only the last line of the file is used. This is similar to do `$ tail -n 1 sensor.txt` on the command-line. Note that file paths must be added to [whitelist_external_dirs](/docs/configuration/basic/). + +To enable the `file` sensor, add the following lines to your `configuration.yaml`: + +```yaml +# Example configuration.yaml entry +sensor: + - platform: file + file_path: /home/user/.homeassistant/sensor-data.txt +``` + +{% configuration %} +file_path: + description: Path to file that stores the sensor data. + required: true + type: string +name: + description: Name of the sensor to use in the frontend. + required: false + default: file name + type: string +unit_of_measurement: + description: Defines the units of measurement of the sensor, if any. + required: false + type: string +value_template: + description: Defines a [template](/docs/configuration/templating/#processing-incoming-data) to extract a value from the payload. + required: false + type: template +{% endconfiguration %} + +### {% linkable_title Examples %} + +In this section you find some real-life examples of how to use this sensor. + +#### {% linkable_title Entries as JSON %} + +Assuming that the log file contains multiple values formatted as JSON like shown below: + +```text +[...] +{"temperature": 21, "humidity": 39} +{"temperature": 22, "humidity": 36} +``` + +This would require the following entry in the `configuration.yaml` file to extract the temperature: + +```yaml +# Example configuration.yaml entry +sensor: + - platform: file + name: Temperature + file_path: /home/user/.homeassistant/sensor.json + value_template: {% raw %}'{{ value_json.temperature }}'{% endraw %} + unit_of_measurement: '°C' +``` diff --git a/source/_components/sensor.file.markdown b/source/_components/sensor.file.markdown deleted file mode 100644 index aafb3aa203b..00000000000 --- a/source/_components/sensor.file.markdown +++ /dev/null @@ -1,73 +0,0 @@ ---- -layout: page -title: "File Sensor" -description: "Instructions on how to integrate sensors which read from files into Home Assistant." -date: 2017-05-13 12:10 -sidebar: true -comments: false -sharing: true -footer: true -logo: file.png -ha_category: Utility -ha_iot_class: Local Polling -ha_release: 0.45 ---- - -The `file` sensor platform reads the entries from a plain-text file and shows the found value. Only the last line of the file is used. This is similar to do `$ tail -n 1 sensor.txt` on the command-line. Note that file paths must be added to [whitelist_external_dirs](/docs/configuration/basic/). - -## {% linkable_title Configuration %} - -To enable the `file` sensor, add the following lines to your `configuration.yaml`: - -```yaml -# Example configuration.yaml entry -sensor: - - platform: file - file_path: /home/user/.homeassistant/sensor-data.txt -``` - -{% configuration %} -file_path: - description: Path to file that stores the sensor data. - required: true - type: string -name: - description: Name of the sensor to use in the frontend. - required: false - default: file name - type: string -unit_of_measurement: - description: Defines the units of measurement of the sensor, if any. - required: false - type: string -value_template: - description: Defines a [template](/docs/configuration/templating/#processing-incoming-data) to extract a value from the payload. - required: false - type: template -{% endconfiguration %} - -## {% linkable_title Examples %} - -In this section you find some real-life examples of how to use this sensor. - -### {% linkable_title Entries as JSON %} - -Assuming that the log file contains multiple values formatted as JSON like shown below: - -```text -[...] -{"temperature": 21, "humidity": 39} -{"temperature": 22, "humidity": 36} -``` - -This would require the following entry in the `configuration.yaml` file to extract the temperature: - -```yaml -# Example configuration.yaml entry -sensor: - - platform: file - name: Temperature - file_path: /home/user/.homeassistant/sensor.json - value_template: {% raw %}'{{ value_json.temperature }}'{% endraw %} - unit_of_measurement: '°C' -```