本帖最后由 liuccb 于 2019-1-21 19:21 编辑
首先家里有几个已经接入ha的switch开关设备,分别是吸顶灯,饮水机,台灯。
吸顶灯用的是博联的FA-2开关,饮水机用的是博联的SPMini2插座,台灯是用的小米的BigZee智能插座。
然后家里有一套已经接入ha的小米智能套装,传感器分别有米家门窗传感器X2、人体传感器、网关、温湿度传感器、小米无线开关。
小米无线开关可以由三个动作触发:单击、双击、长按,可以分别控制三个设备的开关。
家里有一台Airx的空气净化器,一台Airx的加湿器.
吧内已经有大神将Airx的空气净化器成功接入Ha,链接:https://bbs.hassbian.com/forum.php?mod=viewthread&tid=2879&highlight=airx
以下是我的自动化场景:
#打开窗户,自动关闭airx
- alias: close airx when open the windows
initial_state: true
trigger:
- platform: state
entity_id: binary_sensor.door_window_sensor_158d000277009d
from: 'off'
to: 'on'
action:
- service: fan.turn_off
entity_id: fan.airx
#关闭窗户,自动打开airx
- alias: open airx when close the windows
initial_state: true
trigger:
- platform: state
entity_id: binary_sensor.door_window_sensor_158d000277009d
from: 'on'
to: 'off'
action:
- service: fan.turn_on
entity_id: fan.airx
#长按开关 打开或关闭吸顶灯
- alias: open light when press the lock
initial_state: true
trigger:
- platform: event
event_type: click
event_data:
entity_id: binary_sensor.switch_158d00026d4f51
click_type: long_click_press
action:
- service: switch.toggle
entity_id: switch.light_xiding
#长按开关 打开或关闭饮水机
- alias: open light when press the lock
initial_state: true
trigger:
- platform: event
event_type: click
event_data:
entity_id: binary_sensor.switch_158d00026d4f51
click_type: double
action:
- service: switch.toggle
entity_id: switch.broadlink_water
#当回家打开门时,屋子里面光线强度在200以下并且屋子里大于1750秒没有检测到人体移动,自动打开吸顶灯
- alias: open light when back home
initial_state: true
trigger:
- platform: state
entity_id: binary_sensor.door_window_sensor_158d0002b4e63d
from: 'off'
to: 'on'
condition:
condition: and
conditions:
- condition: numeric_state
entity_id: sensor.illumination_7c49eb1b3f74
below: 200
- condition: template
value_template: '{{states.binary_sensor.motion_sensor_158d00026e1622.attributes["No motion since"] | int >= 1750}}'
action:
- service: switch.turn_on
entity_id: switch.light_xiding
|