From e6fc15c162502ed8ab6e6d06fd0aeeca252532bc Mon Sep 17 00:00:00 2001 From: jbouwh Date: Sun, 5 May 2024 15:14:08 +0000 Subject: [PATCH 1/7] Migratie file entry and notify migration --- source/_integrations/file.markdown | 103 +++++------------------------ 1 file changed, 18 insertions(+), 85 deletions(-) diff --git a/source/_integrations/file.markdown b/source/_integrations/file.markdown index 88fb0caf33c8..f16c6587e488 100644 --- a/source/_integrations/file.markdown +++ b/source/_integrations/file.markdown @@ -16,77 +16,28 @@ ha_platforms: ha_integration_type: integration --- +{% include integrations/config_flow.md %} + There is currently support for the following device types within Home Assistant: - [Notifications](#notifications) - [Sensor](#sensor) + - [Examples](#examples) + - [Entries as JSON](#entries-as-json) + - [Entries as CSV](#entries-as-csv) ## 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: - -```yaml -# Example configuration.yaml entry -notify: - - name: NOTIFIER_NAME - platform: file - filename: FILENAME -``` - -{% configuration %} -name: - description: Setting the optional parameter `name` allows multiple notifiers to be created. The notifier will bind to the service `notify.NOTIFIER_NAME`. - required: false - default: notify - type: string -filename: - description: Name of the file to use. The file will be created if it doesn't exist. Add the path of your [configuration](/docs/configuration/) folder (e.g., `/config`) to save the file there. - required: true - type: string -timestamp: - description: Setting `timestamp` to `true` adds a timestamp to every entry. - required: false - default: false - type: boolean -{% endconfiguration %} +The `file` platform allows you to store notifications from Home Assistant as a file. Make sure that the file want to use is added to the [allowlist_external_dirs](https://www.home-assistant.io/integrations/homeassistant/#allowlist_external_dirs). The file will be created if it doesn't exist. Add the path of your [configuration](/docs/configuration/) folder (e.g., `/config`) to save the file there. Setting the optional parameter `name` allows multiple notifiers to be created. Setting `timestamp` to `true` adds a timestamp to every entry. To use notifications, please see the [getting started with automation page](/getting-started/automation/). +Use the `notify.send_message` service to store notification messages. + ## 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 [allowlist_external_dirs](/integrations/homeassistant/#allowlist_external_dirs). -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 %} - ### Examples In this section you find some real-life examples of how to use this sensor. @@ -101,21 +52,12 @@ Assuming that the log file contains multiple values formatted as JSON like shown {"temperature": 22, "humidity": 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.json - value_template: '{{ value_json.temperature }}' - unit_of_measurement: "°C" -``` +This would require the following settings extract the temperature: -{% endraw %} +- Name: `Temperature` +- File path: `/home/user/.homeassistant/sensor.json` +- Value template: `'{{ value_json.temperature }}'` +- Unit of measurement: `"°C"` #### Entries as CSV @@ -127,18 +69,9 @@ timestamp,temperature,humidity 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" -``` +This would require the following settings to extract the temperature: -{% endraw %} +- Name: `Temperature` +- File path: `/home/user/.homeassistant/sensor.csv` +- Value template: `'{{ value.split(",")[1] }}'` +- Unit of measurement: `"°C"` From 81a36d6caae0c70e4e3f69e29abb8b05efb897df Mon Sep 17 00:00:00 2001 From: jbouwh Date: Sun, 5 May 2024 15:20:54 +0000 Subject: [PATCH 2/7] Mark block as raw --- source/_integrations/file.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_integrations/file.markdown b/source/_integrations/file.markdown index f16c6587e488..e971a7ae0f48 100644 --- a/source/_integrations/file.markdown +++ b/source/_integrations/file.markdown @@ -73,5 +73,5 @@ This would require the following settings to extract the temperature: - Name: `Temperature` - File path: `/home/user/.homeassistant/sensor.csv` -- Value template: `'{{ value.split(",")[1] }}'` +- Value template: {% raw %}`'{{ value.split(",")[1] }}'`{% endraw %} - Unit of measurement: `"°C"` From 96daaa377aa87618b1b396c8506b13d5917886b3 Mon Sep 17 00:00:00 2001 From: jbouwh Date: Sun, 5 May 2024 15:27:56 +0000 Subject: [PATCH 3/7] Add general description --- source/_integrations/file.markdown | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/source/_integrations/file.markdown b/source/_integrations/file.markdown index e971a7ae0f48..7a0bd6bfcdb8 100644 --- a/source/_integrations/file.markdown +++ b/source/_integrations/file.markdown @@ -16,15 +16,9 @@ ha_platforms: ha_integration_type: integration --- -{% include integrations/config_flow.md %} - -There is currently support for the following device types within Home Assistant: +The File integration allows to to store notifications to a file or to set up a sensor bases on a file's content. -- [Notifications](#notifications) -- [Sensor](#sensor) - - [Examples](#examples) - - [Entries as JSON](#entries-as-json) - - [Entries as CSV](#entries-as-csv) +{% include integrations/config_flow.md %} ## Notifications From 24c1ed92271d2b3c74d510ab4d9e5e814e61aadf Mon Sep 17 00:00:00 2001 From: jbouwh Date: Thu, 9 May 2024 21:23:56 +0000 Subject: [PATCH 4/7] Still use legacy service name --- source/_integrations/file.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_integrations/file.markdown b/source/_integrations/file.markdown index 7a0bd6bfcdb8..b9808a647bc5 100644 --- a/source/_integrations/file.markdown +++ b/source/_integrations/file.markdown @@ -26,7 +26,7 @@ The `file` platform allows you to store notifications from Home Assistant as a f To use notifications, please see the [getting started with automation page](/getting-started/automation/). -Use the `notify.send_message` service to store notification messages. +Use the `notify.{name}` service to store notification messages. ## Sensor From c361914af68ee7276e2f90af406cda125bc6a57e Mon Sep 17 00:00:00 2001 From: G Johansson Date: Sat, 11 May 2024 23:17:50 +0200 Subject: [PATCH 5/7] Update file.markdown --- source/_integrations/file.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_integrations/file.markdown b/source/_integrations/file.markdown index b9808a647bc5..25101ba85edb 100644 --- a/source/_integrations/file.markdown +++ b/source/_integrations/file.markdown @@ -16,7 +16,7 @@ ha_platforms: ha_integration_type: integration --- -The File integration allows to to store notifications to a file or to set up a sensor bases on a file's content. +The File integration allows to store notifications to a file or to set up a sensor based on a file's content. {% include integrations/config_flow.md %} From 72760508cc947024086fef69102b5733e205cb7c Mon Sep 17 00:00:00 2001 From: G Johansson Date: Sat, 11 May 2024 23:17:57 +0200 Subject: [PATCH 6/7] Update file.markdown --- source/_integrations/file.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_integrations/file.markdown b/source/_integrations/file.markdown index 25101ba85edb..0f190a1468fc 100644 --- a/source/_integrations/file.markdown +++ b/source/_integrations/file.markdown @@ -22,7 +22,7 @@ The File integration allows to store notifications to a file or to set up a sens ## Notifications -The `file` platform allows you to store notifications from Home Assistant as a file. Make sure that the file want to use is added to the [allowlist_external_dirs](https://www.home-assistant.io/integrations/homeassistant/#allowlist_external_dirs). The file will be created if it doesn't exist. Add the path of your [configuration](/docs/configuration/) folder (e.g., `/config`) to save the file there. Setting the optional parameter `name` allows multiple notifiers to be created. Setting `timestamp` to `true` adds a timestamp to every entry. +The `file` platform allows you to store notifications from Home Assistant as a file. Make sure that the file you want to use is added to the [allowlist_external_dirs](https://www.home-assistant.io/integrations/homeassistant/#allowlist_external_dirs). The file will be created if it doesn't exist. Add the path of your [configuration](/docs/configuration/) folder (e.g., `/config`) to save the file there. Setting the optional parameter `name` allows multiple notifiers to be created. Setting `timestamp` to `true` adds a timestamp to every entry. To use notifications, please see the [getting started with automation page](/getting-started/automation/). From 87c1d744682a6b98a183e52dd30a2410ad9043e2 Mon Sep 17 00:00:00 2001 From: jbouwh Date: Sun, 12 May 2024 10:58:53 +0000 Subject: [PATCH 7/7] add raw markers --- source/_integrations/file.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_integrations/file.markdown b/source/_integrations/file.markdown index 0f190a1468fc..73c3a563c73c 100644 --- a/source/_integrations/file.markdown +++ b/source/_integrations/file.markdown @@ -50,7 +50,7 @@ This would require the following settings extract the temperature: - Name: `Temperature` - File path: `/home/user/.homeassistant/sensor.json` -- Value template: `'{{ value_json.temperature }}'` +- Value template: {% raw %}`'{{ value_json.temperature }}'`{% endraw %} - Unit of measurement: `"°C"` #### Entries as CSV