From 0cc127c7171811cb8d3ebdef98a3c9a478745206 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Thu, 17 Dec 2015 19:29:33 +0100 Subject: [PATCH] Add binary rest sensor docs --- .../_components/binary_sensor.rest.markdown | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 source/_components/binary_sensor.rest.markdown diff --git a/source/_components/binary_sensor.rest.markdown b/source/_components/binary_sensor.rest.markdown new file mode 100644 index 00000000000..6cb56043db0 --- /dev/null +++ b/source/_components/binary_sensor.rest.markdown @@ -0,0 +1,52 @@ +--- +layout: component +title: "RESTful binary sensor" +description: "Instructions how to integrate REST binary sensors into Home Assistant." +date: 2015-12-17 19:10 +sidebar: true +comments: false +sharing: true +footer: true +ha_category: Binary Sensor +--- + + +The `rest` binary sensor platform is consuming a given endpoint which is exposed by a [RESTful API](https://en.wikipedia.org/wiki/Representational_state_transfer) of a device, an application, or a web service. The binary sensor has support for GET and POST requests. + +To enable this sensor, add the following lines to your `configuration.yaml` file for a GET request: + +```yaml +# Example configuration.yaml entry +sensor: + platform: rest + resource: http://IP_ADDRESS/ENDPOINT + method: GET + name: REST GET binary sensor + value_template: '{% raw %}{{ value_json.state }}{% endraw %}' +``` + +or for a POST request: + +```yaml +# Example configuration.yaml entry +sensor: + platform: rest + resource: http://IP_ADDRESS/ENDPOINT + method: POST + value_template: '{% raw %}{{ value_json.state }}{% endraw %}' + payload: '{ "device" : "door" }' + name: REST POST binary sensor +``` + +Configuration variables: + +- **resource** (*Required*): The resource or endpoint that contains the value. +- **method** (*Optional*): The method of the request. Default is GET. +- **value_template** (*Optional*): Defines a [template](/getting-started/templating/) to extract the value. +- **payload** (*Optional*): The payload to send with a POST request. Usualy formed as a dictionary. +- **name** (*Optional*): Name of the REST binary sensor. + +

+Make sure that the URL matches exactly your endpoint or resource. +

+