Template Alarm control panel
The template
integration集成将 Home Assistant 与您的设备、服务等连接和集成。 [Learn more] creates alarm control panels that combine integrations or adds preprocessing logic to actions.
There are several powerful ways to use this integration集成将 Home Assistant 与您的设备、服务等连接和集成。 [Learn more], including grouping existing integrations into a simpler integrations, or adding logic that Home Assistant will execute when accessed.
For example, if you want to expose a true alarm panel to Google Home, Alexa, or HomeKit - but limit its ability to disarm when there’s no one home, you can do that using a template.
Another use case could be grouping a series of sensors and services together to represent various “armed” and “disarmed” states and actions.
This can simplify the GUI and make it easier to write automations.
In optimistic mode, the alarm control panel will immediately change state after every command. Otherwise, the alarm control panel will wait for state confirmation from the template. Try to enable it, if experiencing incorrect operation.
配置
要将 Template Alarm control panel helper 添加到您的 Home Assistant 实例中,请使用此 My 按钮:
手动配置步骤
如果上述 My 按钮不起作用,您也可以手动执行以下步骤:
-
浏览到您的 Home Assistant 实例。
-
转到
设置 > 设备与服务。 -
在屏幕顶部,选择标签:Helpers。
-
在右下角,选择
创建助手 按钮。 -
从列表中选择 Template Alarm control panel。
-
按照屏幕上的说明完成设置。
YAML Configuration
To enable a template alarm control panel in your installation, add the following to your configuration.yaml
configuration.yaml 文件是 Home Assistant 的主要配置文件。它列出了要加载的集成及其特定配置。在某些情况下,需要直接在 configuration.yaml 文件中手动编辑配置。大多数集成可以在 UI 中配置。 [Learn more] file.
在更改了configuration.yaml
configuration.yaml 文件是 Home Assistant 的主要配置文件。它列出了要加载的集成及其特定配置。在某些情况下,需要直接在 configuration.yaml 文件中手动编辑配置。大多数集成可以在 UI 中配置。 [Learn more] 文件后,重启 Home Assistant 以应用更改。
# Example configuration.yaml entry
alarm_control_panel:
- platform: template
panels:
safe_alarm_panel:
value_template: "{{ states('alarm_control_panel.real_alarm') }}"
arm_away:
action: alarm_control_panel.alarm_arm_away
target:
entity_id: alarm_control_panel.real_alarm
data:
code: !secret alarm_code
arm_home:
action: alarm_control_panel.alarm_arm_home
target:
entity_id: alarm_control_panel.real_alarm
data:
code: !secret alarm_code
disarm:
- condition: state
entity_id: device_tracker.paulus
state: "home"
- action: alarm_control_panel.alarm_disarm
target:
entity_id: alarm_control_panel.real_alarm
data:
code: !secret alarm_code
Configuration Variables
List of your panels.
The slug of the panel.
An ID that uniquely identifies this alarm control panel. Set this to a unique value to allow customization through the UI.
Defines a template to set the state of the alarm panel. Only the states armed_away
, armed_home
, armed_night
, armed_vacation
, arming
, disarmed
, pending
, triggered
and unavailable
are used.
Defines an action to run when the alarm is disarmed.
Defines an action to run when the alarm is armed to away mode.
Defines an action to run when the alarm is armed to home mode.
Defines an action to run when the alarm is armed to night mode.
Defines an action to run when the alarm is armed to vacation mode.
Defines an action to run when the alarm is armed to custom bypass mode.
Defines an action to run when the alarm is triggered.
Template and action variables
State-based template entities have the special template variable this
available in their templates and actions. The this
variable aids self-referencing of an entity’s state and attribute in templates and actions.
Considerations
If you are using the state of an integration that takes extra time to load, the template alarm control panel may get an unknown
state during startup. This results in error messages in your log file until that integration has completed loading. If you use is_state()
function in your template, you can avoid this situation.
For example, you would replace {{ states.switch.source.state == 'on' }}
with this equivalent that returns true
/false
and never gives an unknown result: {{ is_state('switch.source', 'on') }}