automation:
trigger:
platform: numeric_state
entity_id: sensor.temperature
# Optional
value_template: '{{ state.attributes.battery }}'
# At least one of the following required
above: 17
below: 25
5.状态触发 这个也是常用的触发条件,例如打开开关触发条件
automation:
trigger:
platform: state
entity_id: device_tracker.paulus, device_tracker.anne_therese
# Optional
from: 'not_home'
# Optional
to: 'home'
# If given, will trigger when state has been the to state for X time.
for:
hours: 1
minutes: 10
seconds: 5
6.日落触发 这个条件就顾名思义了
automation:
trigger:
platform: sun
# Possible values: sunset, sunrise
event: sunset
# Optional time offset. This example is 45 minutes.
offset: '-00:45:00'
automation:
trigger:
platform: time
# Matches every hour at 5 minutes past whole
minutes: 5
seconds: 00
automation 2:
trigger:
platform: time
# When 'at' is used, you cannot also match on hour, minute, seconds.
# Military time format.
at: '15:32:00'
automation 3:
trigger:
platform: time
# You can also match on interval. This will match every 5 minutes
minutes: '/5'
seconds: 00
9.定位触发
automation:
trigger:
platform: zone
entity_id: device_tracker.paulus
zone: zone.home
# Event is either enter or leave
event: enter # or "leave"
10.多个触发条件
automation:
trigger:
# first trigger
- platform: time
minutes: 5
seconds: 00
# our second trigger is the sunset
- platform: sun
event: sunset
-------------------------------------------------分割线------------------------------------------------- 2017年8月15日更新 Condition的几种条件 condition是用来完善trigger触发后执行条件,防止误操作,此项可有可无。 先说说几种条件的逻辑关系 1): and
相当于‘与’只有多个条件同时满足才能执行action
condition:
condition: and
conditions:
- condition: state
entity_id: 'device_tracker.paulus'
state: 'home'
- condition: numeric_state
entity_id: 'sensor.temperature'
below: '20'
2): or
相当于 '或' 只要满足一个即执行action
condition:
condition: or
conditions:
- condition: state
entity_id: 'device_tracker.paulus'
state: 'home'
- condition: numeric_state
entity_id: 'sensor.temperature'
below: '20'
3): 混合使用‘and’和‘or’
condition:
condition: or
conditions:
- condition: state
entity_id: 'device_tracker.paulus'
state: 'home'
- condition: numeric_state
entity_id: 'sensor.temperature'
below: '20'
以上就是几种条件的逻辑关系
1.数字状态条件
condition:
condition: numeric_state
entity_id: sensor.temperature
above: 17
below: 25
# If your sensor value needs to be adjusted
value_template: {{ float(state.state) + 2 }}
2.状态条件
condition:
condition: state
entity_id: device_tracker.paulus
state: not_home
# optional: trigger only if state was this for last X time.
for:
hours: 1
minutes: 10
seconds: 5
3.太阳升起/落下 条件
condition:
condition: state
entity_id: device_tracker.paulus
state: not_home
# optional: trigger only if state was this for last X time.
for:
hours: 1
minutes: 10
seconds: 5