From f057ec3ceb70cb4581a25fc5fed9b2623244c790 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 20 Jun 2016 23:46:11 +0200 Subject: [PATCH] Add detail for text file --- source/_components/sensor.command_line.markdown | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/_components/sensor.command_line.markdown b/source/_components/sensor.command_line.markdown index 0e26cae696f..da311f63516 100644 --- a/source/_components/sensor.command_line.markdown +++ b/source/_components/sensor.command_line.markdown @@ -82,6 +82,16 @@ You can see directly in the frontend (**Developer tools** -> **About**) what rel name: HA release ``` +### {% linkable_title Read value out of a remote text file %} + +If you own a devices which are storing values in text files which are accessible over HTTP then you can use the same approach as shown in the previous section. Instead of looking at the JSON response we directly grab the sensor's value. + +```yaml + - platform: command_line + command: python3 -c "import requests; print(requests.get('http://remote-host/sensor_data.txt').text)" + name: File value +``` + ### {% linkable_title Use an external script %} The example is doing the same as the [aREST sensor](/components/sensor.arest/) but with an external Python script. It should give you an idea about interacting with devices which are exposing a RESTful API.