本帖最后由 情非殇 于 2019-3-22 22:00 编辑
我给你的代码,是删减版的,是面板效果中的其中一条代表分minute的拉杆,你把拉杆做到你灯开关的下面靠着就好了
一条拉杆就可以实现你的要求了,这样比较简单
homeassistant:
customize:
input_number.timer_min:
friendly_name: 分
icon: mdi:av-timer
sensor:
- platform: template
sensors:
timer_setting:
friendly_name: 'Time'
value_template: '{{ "%0.02d:%0.02d:%0.02d" | format(states("input_number.timer_hour") | int, states("input_number.timer_min") | int, states("input_number.timer_sec") | int) }}'
input_number:
timer_min:
name: TimerMinute
min: 0
max: 100 # 拉杆分钟峰值
step: 1
timer:
timer:
duration: '00:00:00'
automation:
- alias: test1
hide_entity: true
trigger:
- platform: state
entity_id: sensor.timer_setting
action:
- service: timer.cancel
entity_id: timer.test
- service: timer.start
data_template:
entity_id: timer.test
duration: >
{{ states("sensor.timer_setting") }}
## 倒计时完成,灯为on的话执行off,灯为off的话执行on
- alias: test2
hide_entity: true
initial_state: true
trigger:
# 定时器结束启动
platform: event
event_type: timer.finished
event_data:
entity_id: timer.test
condition:
- condition: state
entity_id: light.xxxxx
state: 'on'
action:
- service: light.turn_off
entity_id: light.xxxxx
- alias: test3
hide_entity: true
initial_state: true
trigger:
# 定时器结束启动
platform: event
event_type: timer.finished
event_data:
entity_id: timer.test
condition:
- condition: state
entity_id: light.xxxxx
state: 'off'
action:
- service: light.turn_on
entity_id: light.xxxxx
|