给你一个可以用的配置:
先设一个input_number:
input_number:
cover_slider:
name: cover slider
min: 1
max: 100
step: 1
unit_of_measurement: '%'
然后设置以下两个自动化:
自动化一 同步窗帘状态到slider
- alias: set input number state
initial_state: true
trigger:
platform: template
value_template: "{{ states.cover.hassmart_65c8e4.attributes.current_position }}"
action:
service: input_number.set_value
data_template:
entity_id: input_number.cover_slider
value: "{{ (states.cover.hassmart_65c8e4.attributes.current_position) | int }}"
自动化二 拖动slider操作窗帘(这里面要判断一下只有当窗帘实际位置与slider值不同时,即拖动时才操作窗帘,从窗帘同步过来的状态,不再操作窗帘,防止进入死循环)
- alias: set cover position
initial_state: true
trigger:
platform: state
entity_id: input_number.cover_slider
condition:
- condition: template
value_template: "{{ (states('input_number.cover_slider') | int) != (states.cover.hassmart_65c8e4.attributes.current_position | int) }}"
action:
service: cover.set_cover_position
data_template:
entity_id: cover.hassmart_65c8e4
position: "{{ states('input_number.cover_slider') | int }}"
以上已测试,完美使用。
Happy automating with HASSMART~!
|