sensor:
- platform: template
sensors:
xiyiji_state:
friendly_name: 洗衣机
value_template: >-
{% if is_state('switch.0x158d00047994c1_switch','off')%}
关机
{% elif is_state('input_boolean.xiyiji_daiji','on')%}
待机
{% elif is_state('input_boolean.xiyiji_wash','on')%}
运行中
{% elif is_state('input_boolean.xiyiji_yuyue','on')%}
预约中
{% else %}
待机
{% endif %}
icon_template: >-
{% if is_state('switch.0x158d00047994c1_switch','off')%}
mdi:washing-machine-off
{% else %}
mdi:washing-machine
{% endif %}
input_boolean:
xiyiji_wash:
initial: off
xiyiji_daiji:
initial: off
xiyiji_yuyue:
initial: off
automation:
- alias: wash
trigger:
- platform: numeric_state
entity_id: sensor.0x158d00047994c1_power
above: '20'
for: '30'
action:
- service: input_boolean.turn_off
entity_id: input_boolean.xiyiji_yuyue
- service: input_boolean.turn_off
entity_id: input_boolean.xiyiji_daiji
- service: input_boolean.turn_on
entity_id: input_boolean.xiyiji_wash
- alias: washyuyue
trigger:
- platform: numeric_state
entity_id: sensor.0x158d00047994c1_power
above: '4'
below: '7'
for: '30'
action:
- service: input_boolean.turn_on
entity_id: input_boolean.xiyiji_yuyue
- service: input_boolean.turn_off
entity_id: input_boolean.xiyiji_daiji
- service: input_boolean.turn_off
entity_id: input_boolean.xiyiji_wash
- alias: daiji
trigger:
- platform: numeric_state
entity_id: sensor.0x158d00047994c1_power
below: '4'
above: '0'
for: '30'
condition:
- condition: state
entity_id: binary_sensor.0x158d00044feaae_contact
state: 'off'
action:
- service: input_boolean.turn_off
entity_id: input_boolean.xiyiji_wash
- service: input_boolean.turn_off
entity_id: input_boolean.xiyiji_yuyue
- service: input_boolean.turn_on
entity_id: input_boolean.xiyiji_daiji
- alias: restwash
trigger:
- platform: state
entity_id: binary_sensor.0x158d00044feaae_contact
from: 'off'
to: 'on'
condition:
condition: or
conditions:
- condition: state
entity_id: input_boolean.xiyiji_wash
state: 'on'
- condition: state
entity_id: input_boolean.xiyiji_daiji
state: 'on'
- condition: state
entity_id: input_boolean.xiyiji_yuyue
state: 'on'
action:
- delay:
seconds: 0.1
- service: input_boolean.turn_off
entity_id: input_boolean.xiyiji_daiji
- delay:
seconds: 0.1
- service: input_boolean.turn_off
entity_id: input_boolean.xiyiji_wash
- delay:
seconds: 0.1
- service: input_boolean.turn_off
entity_id: input_boolean.xiyiji_yuyue
复制代码
我是由小米zigbee门磁和墙壁插座,两个组合使用的。设置参数值还要看自己洗衣机不同状态时的功率而定。代码应该还可以优化简洁一点。
状态做好了,再增加洗衣完成(从运行变成待机)提醒自动化就简单了。