想做个自动化. 通过设备 属性 下面的 数值变化 触发. 比如 只有从 0.9 到 1.5 然后触发!.
从网上找个各种例子模仿写了一个,但是不工作. 请各位大佬帮忙指教一下!
下面是我编写的自动化
alias: Presence/Relative Motion in a specific range controls switch
description: ‘Turn switches off if distance increases’
trigger:
- platform: state
entity_id: sensor.fsc_bp104_room_presence
attribute: distance
condition:
- condition: template
value_template: '{{ 1.5 >= trigger.to_state.attributes.distance|float(0) >= 0.9 }}'
- condition: template
value_template: >-
{{ trigger.to_state.attributes.distance|float(0) >
trigger.from_state.attributes.distance|float(0)}}
- condition: state
entity_id: switch.tuya_garage_door
state: 'on'
for:
seconds: 15
- condition: state
entity_id: switch.zigbee_da_men_switch_1
state: 'on'
for:
seconds: 15
action:
- type: turn_off
device_id: 22bc57c19a420ade5d81e5d698ad6f12
entity_id: switch.tuya_garage_door
domain: switch
- type: turn_off
device_id: eaf2d2f99cee274ded0fe7f0ff052503
entity_id: switch.zigbee_da_men_switch_1
domain: switch
mode: single
下面是监听的设备信息, 我想使用 attributes distance 后面的数值变化 ( 不是大小的变化, 是一个数到另一个数的变化, 比如 从0.9 到 1.5 然后触发)
"event_type": "state_changed",
"data": {
"entity_id": "sensor.fsc_bp104_room_presence",
"old_state": {
"entity_id": "sensor.fsc_bp104_room_presence",
"state": "Garage",
"attributes": {
"distance": 0.1,
"last_updated_at": "2021-11-12T06:43:42.577Z",
"friendly_name": "FSC_BP104 Room Presence",
"icon": "mdi:bluetooth"
},
"last_changed": "2021-11-12T06:06:00.031802+00:00",
"last_updated": "2021-11-12T06:43:42.682339+00:00",
"context": {
"id": "a45ef4552c2d857e2a8997bc5eb046e9",
"parent_id": null,
"user_id": null
|