RESTful Notifications

The rest notification platform allows you to deliver RESTful notifications from Home Assistant to another party.

To enable the REST notification in your installation, add the following to your configuration.yamlconfiguration.yaml 文件是 Home Assistant 的主要配置文件。它列出了要加载的集成及其特定配置。在某些情况下,需要直接在 configuration.yaml 文件中手动编辑配置。大多数集成可以在 UI 中配置。 [Learn more] file:

# Example configuration.yaml entry
notify:
  - name: NOTIFIER_NAME
    platform: rest
    resource: http://IP_ADDRESS/ENDPOINT

Configuration Variables

name string (Optional, default: notify)

Setting the optional parameter name allows multiple notifiers to be created. The notifier will bind to the notify.NOTIFIER_NAME action.

resource string Required

The resource or endpoint that will receive the value.

method string (Optional, default: GET)

The method of the request. Valid options are GET, POST or POST_JSON.

verify_ssl boolean (Optional, default: true)

Verify the SSL certificate of the endpoint.

authentication string (Optional, default: basic)

Type of the HTTP authentication. basic or digest.

username string (Optional)

The username for accessing the REST endpoint.

password string (Optional)

The password for accessing the REST endpoint.

headers string (Optional)

The headers for the request.

message_param_name string (Optional, default: message)

Parameter name for the message.

title_param_name string (Optional)

Parameter name for the title.

target_param_name string (Optional)

Parameter name for the target.

data template (Optional)

Template dictionary of extra parameters to send to the resource.

To use notifications, please see the getting started with automation page.

使用模板

对于传入数据,值模板将传入的 JSON 或原始数据转换为有效的有效负载。 传入的有效负载使用可能的 JSON 值进行渲染,因此在渲染时,可以使用 value_json 访问基于 JSON 的有效负载中的属性,否则可以使用 value 变量来处理非 JSON 基础的数据。

此外,this 可以作为模板中的变量使用。this 属性指的是实体的当前 实体状态。 关于 this 变量的更多信息可以在 模板文档 中找到。

Note

带 json 的示例值模板:

给定有效负载:

{ "state": "ON", "temperature": 21.902 }

模板 {{ value_json.temperature | round(1) }} 渲染为 21.9