Skip to content

Commit 76b28de

Browse files
committed
Add GitHub example
1 parent 0aec729 commit 76b28de

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

source/_components/sensor.rest.markdown

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ To enable this sensor, add the following lines to your `configuration.yaml` file
1919
```yaml
2020
# Example configuration.yaml entry
2121
sensor:
22-
platform: rest
23-
resource: http://IP_ADDRESS/ENDPOINT
22+
- platform: rest
23+
resource: http://IP_ADDRESS/ENDPOINT
2424
```
2525
2626
or for a POST request:
2727
2828
```yaml
2929
# Example configuration.yaml entry
3030
sensor:
31-
platform: rest
32-
resource: http://IP_ADDRESS/ENDPOINT
33-
method: POST
34-
payload: '{ "device" : "heater" }'
31+
- platform: rest
32+
resource: http://IP_ADDRESS/ENDPOINT
33+
method: POST
34+
payload: '{ "device" : "heater" }'
3535
```
3636
3737
Configuration variables:
@@ -70,6 +70,7 @@ You can find your external IP address using the service [JSON Test](http://www.j
7070
To display the IP address, the entry for a sensor in the `configuration.yaml` file will look like this.
7171

7272
```yaml
73+
sensor:
7374
- platform: rest
7475
resource: http://ip.jsontest.com
7576
name: External IP
@@ -83,6 +84,7 @@ The [glances](/components/sensor.glances/) sensor is doing the exact same thing
8384
Add something similar to the entry below to your `configuration.yaml` file:
8485

8586
```yaml
87+
sensor:
8688
- platform: rest
8789
resource: http://IP_ADRRESS:61208/api/2/mem/used
8890
name: Used mem
@@ -95,6 +97,7 @@ Add something similar to the entry below to your `configuration.yaml` file:
9597
The Home Assistant [API](/developers/rest_api/) exposes the data from your attached sensors. If you are running multiple Home Assistant instances which are not [connected](/developers/architecture/#multiple-connected-instances) you can still get information from them.
9698

9799
```yaml
100+
sensor:
98101
- platform: rest
99102
resource: http://IP_ADDRESS:8123/api/states/sensor.weather_temperature
100103
name: Temperature
@@ -106,6 +109,7 @@ The Home Assistant [API](/developers/rest_api/) exposes the data from your attac
106109
The REST sensor supports HTTP authentication and customized headers.
107110

108111
```yaml
112+
sensor:
109113
- platform: rest
110114
resource: http://IP_ADDRESS:5000/sensor
111115
username: ha1
@@ -127,3 +131,21 @@ Content-Type: application/json
127131
User-Agent: Home Assistant
128132
```
129133

134+
### {% linkable_title Use GitHub to get the latest release of Home Assistant %}
135+
136+
This sample is very similar to the [`updater`](/components/updater/) component but the information are recieved from GitHub.
137+
138+
```yaml
139+
sensor:
140+
- platform: rest
141+
resource: https://api.github.com/repos/home-assistant/home-assistant/releases/latest
142+
username: YOUR_GITHUB_USERNAME
143+
password: YOUR_GITHUB_ACCESS_TOKEN
144+
authentication: basic
145+
value_template: '{% raw %}{{ value_json.tag_name }}{% endraw %}'
146+
headers:
147+
Accept: application/vnd.github.v3+json
148+
Content-Type: application/json
149+
User-Agent: Home Assistant REST sensor
150+
```
151+

0 commit comments

Comments
 (0)