https://www.vultr.com

The Everywhere Cloud

Deploy an instance.
Accelerate your application.


Enabling REST Apps in Home Assistant


The following procedure shows how to make Home Assistant communicate periodically [ every thirty (30) seconds, by default ] with other endpoints like remote devices or web services. This is made possible by the polling mechanism of its REST "sensor" platform. By default, the "sensor" polls those endpoints for new data every thirty seconds.

==========

1. Log in as the system account (-u), with $HOME "bin" included in $PATH (-i).

user@host: $ sudo -i -u homeassistant

2. Go to the directory containing the YAML configuration files.

user@host: $ cd ~/.homeassistant

3. BACK UP the main YAML configuration file.

user@host: $ cp configuration.yaml configuration_yaml.back

4. Open the main YAML configuration file.

user@host: $ nano configuration.yaml

5. Add the following YAML lines and save the file.

# BEGIN CODE
# ...

sensor:
  - platform: rest
    name: "Dyn Check IP"
    resource: http://checkip.dyn.com
    method: GET

# ...
# END CODE

5.1. For HTTPS with POST data, the general format of the REST "sensor" is as follows.

# BEGIN CODE
# ...

sensor:
  - platform: rest
    name: "My REST App"
    resource: https://my.other.url
    verify_ssl: false
    headers:
      content-type: "application/x-www-form-urlencoded"
    method: POST
    payload: "device=doorbell&tone=DingDong"

# Setting "verify_ssl" as false allows self-signed certificates to be used.
# The POST "method" tells the "resource" that there is incoming "payload".
# The "payload" (empty by default) is a string of URL-encoded "key=value" pairs.

# ...
# END CODE

6. Restart the Home Assistant server via web browser.

http://ip.add.re.ss:8123

Configuration -> Server Controls -> Server management -> Restart

7. Check if the REST app is working properly.

Developer Tools -> States -> Current entities

sensor.my_rest_app

8. Display the REST app on the main interface of Home Assistant.

Overview -> "..." Menu -> Configure UI -> "+" Add Card -> Entity

9. Choose the REST app and click Save.

==========

REFERENCES

1. Home Assistant. Integrations, REST.

==========

Comments

Popular posts from this blog

Enabling HTTPS in Home Assistant

Configuring the FreeBSD Firewall with IPFW

Running Home Assistant on FreeBSD Servers