本帖最后由 roc227 于 2021-1-12 00:31 编辑
硬件: 阳台插的小米网关(用于接入传感器和判断阳台流明),晾衣架门磁2个(根据晾衣架两侧X结构,判断晾衣架是升起还是降到某预置位置),博联(用于发射晾衣架的射频),小米插座(用于采集洗衣机功率),洗衣机门磁1个
虚拟状态: 流明700(switch.lux700)和流明800(switch.lux800)(作为判断黑天和白天的分界点),普通洗衣模式(switch.wash),洗衣机烘干模式(switch.washdry)
几个基础自动化: 根据流明判断当前是白天还是黑天
#流明低于800
- alias: lux800low
trigger:
- platform: numeric_state
entity_id: sensor.illumination_78
below: '800'
action:
- service: switch.turn_on
entity_id: switch.lux800
#流明高于800
- alias: lux800high
trigger:
- platform: numeric_state
entity_id: sensor.illumination_78
above: '800'
condition:
condition: time
after: '00:04:00'
before: '9:30:00'
action:
- service: switch.turn_off
entity_id: switch.lux800
- service: switch.turn_off
entity_id: switch.lux700
#流明低于700
- alias: lux700low
trigger:
- platform: numeric_state
entity_id: sensor.illumination_78
below: '700'
action:
- service: switch.turn_on
entity_id: switch.lux700
根据功率判断洗衣机当前为普通洗衣状态,开门后需要晾衣服(比如大于100W),打开洗衣虚拟状态
根据功率判断洗衣机当前为烘干状态,开门后不需要晾衣服(比如大于800W),打开烘干虚拟状态
洗衣虚拟状态或烘干虚拟状态打开时,打开洗衣机门后,复归洗衣机状态至停机(洗衣机两个虚拟状态为关)
#烘干状态
- alias: washdry
trigger:
- platform: numeric_state
entity_id: switch.plug_15
value_template: '{{ state.attributes.load_power }}'
above: '800'
action:
- service: switch.turn_on
entity_id: switch.washdry
- service: switch.turn_off
entity_id: switch.wash
#复归洗衣
- alias: restwash
trigger:
- platform: state
entity_id: binary_sensor.door_window_sensor_15
from: 'off'
to: 'on'
condition:
condition: or
conditions:
- condition: state
entity_id: switch.wash
state: 'on'
- condition: state
entity_id: switch.washdry
state: 'on'
action:
#复归洗衣模式
- delay:
seconds: 0.5
- service: switch.turn_off
entity_id: switch.wash
#复归烘干模式
- delay:
seconds: 0.8
- service: switch.turn_off
entity_id: switch.washdry
开始联动了:
洗衣机停机状态下,因为洗机衣两个虚拟状态都是关闭状态,晾衣架不会动作。
普通洗完,打开门,降下晾衣架,延时恢复至升起前状态(其中晚上会把窗帘打开一半,打开晾衣架灯)。
烘干洗完,因为因为洗机衣两个虚拟状态都是打开状态,晾衣架不会动作。
#晚上降晾衣架
- alias: bondnightdown
trigger:
- platform: state
entity_id: binary_sensor.door_window_sensor_15
from: 'off'
to: 'on'
condition:
condition: and
conditions:
- condition: state
entity_id: switch.lux700
state: 'on'
- condition: state
entity_id: switch.wash
state: 'on'
action:
#开一半客厅纱帘
- service: cover.set_cover_position
data:
entity_id: cover.curtain_15
position: 30
#开一半客厅窗帘
- delay:
seconds: 1
- service: cover.set_cover_position
data:
entity_id: cover.curtain_15
position: 30
#开晾衣架灯
- delay:
seconds: 2
- service: switch.turn_on
entity_id: switch.bondlight
#降晾衣架
- delay:
seconds: 2
- service: switch.turn_on
entity_id: switch.bondupdown
- service: hello_miai.force_send
data_template:
message: "正在为您降下晾衣架"
miai_num: "3"
#停降晾衣架
- delay:
seconds: 18
- service: switch.turn_off
entity_id: switch.bondstop
#升晾衣架
- delay:
seconds: 280
- service: switch.turn_off
entity_id: switch.bondupdown
#关晾衣架灯
- delay:
seconds: 2
- service: switch.turn_off
entity_id: switch.bondlight
- service: hello_miai.force_send
data_template:
message: "正在为您升起晾衣架"
miai_num: "3"
#关客厅纱帘
- delay:
seconds: 2
- service: cover.set_cover_position
data:
entity_id: cover.curtain_15
position: 0
#关客厅窗帘
- delay:
seconds: 2
- service: cover.set_cover_position
data:
entity_id: cover.curtain_15
position: 0
#白天降晾衣架
- alias: bonddown
trigger:
- platform: state
entity_id: binary_sensor.door_window_sensor_15
from: 'off'
to: 'on'
condition:
condition: and
conditions:
- condition: state
entity_id: switch.lux700
state: 'off'
- condition: state
entity_id: switch.wash
state: 'on'
action:
#降晾衣架
- delay:
- service: switch.turn_on
entity_id: switch.bondupdown
- service: hello_miai.force_send
data_template:
message: "正在为您降下晾衣架"
miai_num: "3"
#停降晾衣架
- delay:
seconds: 15
- service: switch.turn_off
entity_id: switch.bondstop
#升晾衣架
- delay:
seconds: 290
- service: switch.turn_off
entity_id: switch.bondupdown
- service: hello_miai.force_send
data_template:
message: "正在为您升起晾衣架"
miai_num: "3"
还做了一个按钮,白天按一下降下晾衣架,延时升起或者再按一下升起。晚上按一下,降晾衣架+开一半窗帘+打开晾衣架灯,延时恢复或再按一下恢复。
[size=15.008px]
|