This post is part of a group of posts all associated with the acquisition of information from external resources and making it available in Home Assistant.
- Simple Sensor (Background Collection: Retrieve one value with each call)
- Multi-Entity Sensor (Background Collection: Retrieve multiple values with each call)
Simple Sensor
In order to set up Home Assistant to collect data at regular intervals from web sites / devices and make the information available, sensors can be used.
This is a really simple example.
Step 1: Include File for Sensor Settings
Update 'configuration.yaml' to include a separate file which will include all of the sensor configurations:
...
sensor: !include sensors.yaml
Note: This is 'sensor:' and not 'sensors:'
Step 2: Add a Sensor
Create a 'sensors.yaml' file alongside the 'configuration.yaml' file
$ vi sensors.yaml
- platform: rest
name: "Json Test - Random Number"
resource: "http://www.randomnumberapi.com/api/v1.0/randomnumber"
method: GET
value_template: "{{ value_json[0] }}"
scan_interval: 900
Step 3: Check Things
Visit your Home Assistant / Developer Tools / Yaml page, and select "check configuration", and if everything is OK, select "Restart".
Once restarted, visit Home Assistant / Settings / Device and Services / Entities, and search for "Json Test - Random Number" in the list - select it, and you should see the results (in this case, the random number is 48).
No comments:
Post a Comment