大佬能帮忙看看不,我照猫画虎根据自己的情况改的,没有效果。
表现为:不显示倒数读秒,有时候有,但是时间不对;自己算着时间,风扇并不会自动关闭(空调没有试);
代码:
homeassistant:
customize:
timer.timer:
friendly_name: 定时时间
hidden: false
homebridge_hidden: true
input_text.timer:
friendly_name: 设置定时
icon: mdi:timer
hidden: false
homebridge_hidden: true
script.timer_cancel:
friendly_name: 取消定时
icon: mdi:timer-off
hidden: false
homebridge_hidden: true
automation.text_timer:
friendly_name: 定时设置自动化
icon: mdi:timer-off
hidden: false
homebridge_hidden: true
automation.timer_climate_delay:
friendly_name: 空调定时自动化
icon: mdi:timer-off
hidden: false
homebridge_hidden: true
automation.timer_fan_delay:
friendly_name: 风扇定时自动化
icon: mdi:timer-off
hidden: false
homebridge_hidden: true
group:
Climate_Fan_Timer:
name: 设备定时
control: hidden
icon: mdi:timer
entities:
- input_select.timer_climate
- input_select.timer_fan
- input_text.timer
- timer.timer
- script.timer_cancel
- automation.text_timer
- automation.timer_climate_delay
- automation.timer_fan_delay
timer:
timer:
duration: '00:00:00'
input_text:
timer:
name: timer
initial: 00:00:00
pattern: '([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]'
input_select:
timer_climate:
name: 空调定时
options:
- 选择空调
- 客厅空调
- 主卧空调
- 次卧空调
initial: '选择空调'
icon: mdi:air-conditioner #toggle-switch-off
timer_fan:
name: 风扇定时
options:
- 选择风扇
- 主卧风扇
- 厕所风扇
- 厕所浴霸
initial: '选择风扇'
icon: mdi:fan #toggle-switch-off
script:
timer_cancel:
sequence:
service: timer.cancel
entity_id: timer.timer
automation:
- alias: text_timer
hide_entity: true
trigger:
platform: state
entity_id: input_text.timer
action:
service: timer.start
data_template:
entity_id: timer.timer
duration: >
{{ states("input_text.timer") }}
- alias: timer_climate_delay
trigger:
platform: event
event_type: timer.finished
event_data:
entity_id: timer.timer
action:
- service: climate.set_operation_mode
data_template:
entity_id: >-
{% if is_state("input_select.timer_climate_fan", "客厅空调") %}
climate.ac_livingroom
{% elif is_state("input_select.timer_climate_fan", "主卧空调") %}
climate.ac_bedroom
{% elif is_state("input_select.timer_climate_fan", "次卧空调") %}
climate.mi_acpartner
{% endif %}
operation_mode: '关闭'
- service: input_select.select_option
data:
entity_id: input_select.timer_climate
option: "选择空调"
- alias: timer_fan_delay
trigger:
platform: event
event_type: timer.finished
event_data:
entity_id: timer.timer
action:
- service: fan.turn_off
data_template:
entity_id: >-
{% if is_state("input_select.timer_switch", "主卧风扇") %}
fan.sonoff06
{% elif is_state("input_select.timer_switch", "厕所风扇") %}
fan.sonoff09
{% elif is_state("input_select.timer_switch", "厕所浴霸") %}
fan.sonoff08
{% endif %}
- service: input_select.select_option
data:
entity_id: input_select.timer_fan
option: "选择风扇"
|