前言:
这个自动化不可能满足或者说符合所有人的需求,分享出来,给大家提供一些思路
【简单除暴】
#分享出来,大家能直接用更好,
#因设备及环境差异,自动化需求会有差异,用不上就仅提供些思路
#主要实现以下功能
#1、进卧室(或者下床活动等)时 天黑且所有灯是关闭的(也就是
# 卧室黑),自动开床头灯,待无人-关闭床头灯
#2、手动打开床头灯,自动开关床头灯失效;关闭床头灯,恢复自动开关床头灯 1-1,1-2,1-3
#3、开吸顶灯,床头灯自动关;开床头灯,吸顶灯自动关 1-4,1-5
#4、多控吸顶灯 1-6
group:
automation_light: # Tab页 自动化 中group
name: 灯光自动化
view: no
icon: mdi:fingerprint
entities:
- automation.auto_BedRoom1_lamp #灯1-1
- automation.auto_BedRoom1_lamp_on #灯1-2
- automation.auto_BedRoom1_lamp_off #灯1-3
- automation.auto_BedRoom1_ceiling_lamp #灯1-4
- automation.auto_BedRoom1_lamp_ceiling #灯1-5
- automation.switch_3_ceiling_toggle #灯1-6
#####################################################################################
homeassistant:
customize:
automation.auto_BedRoom1_lamp:
friendly_name: 1-1米家床头灯常开取消自动关
homebridge_hidden: true
icon: mdi:hotel
automation.auto_BedRoom1_lamp_on:
friendly_name: 1-2米家床头灯自动开、关
homebridge_hidden: true
icon: mdi:hotel
automation.auto_BedRoom1_lamp_off:
friendly_name: 1-3米家床头灯自动关(无人)
homebridge_hidden: true
icon: mdi:hotel
automation.auto_BedRoom1_ceiling_lamp:
friendly_name: 1-4开主卧吸顶灯关米家床头灯
homebridge_hidden: true
icon: mdi:hotel
automation.auto_BedRoom1_lamp_ceiling:
friendly_name: 1-5开米家床头灯关主卧吸顶灯
homebridge_hidden: true
icon: mdi:hotel
automation.switch_3_ceiling_toggle:
friendly_name: 1-6主卧三个无线(单击)开关主卧吸顶灯
homebridge_hidden: true
icon: mdi:hotel
automation:
##灯1-1主卧室:主卧人体1或主卧人体2感应-主卧吸顶灯关且米家床头灯开且太阳落山-灯1-3自动关自动化 关
- alias: auto_BedRoom1_lamp
#initial_state: true #重启HA自动化是开启(true)还是关闭(false)
hide_entity: false #隐藏自动化
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor_158XXXXXXXXXX #主卧人体传感器
to: 'on'
- platform: state
entity_id: binary_sensor.motion_sensor_158dXXXXXXXXX #主卧人体传感器2
to: 'on'
condition:
condition: and #or
conditions:
- condition: state
entity_id: sun.sun
state: "below_horizon"
- condition: state
entity_id: light.yeelight_ceiling_28XXXXXXXXX #主卧吸顶灯
state: 'off'
- condition: state
entity_id: light.yeelight_bedside_78XXXXXXXXX #米家床头灯
state: 'on'
#光线传感器
# condition:
# condition: numeric_state
# entity_id: sensor.illumination_34ce00xxxx11
# below: 300
action:
#通过IF判断感应器的状态
# - service_template: "light.turn_{% if trigger.to_state.state == 'on' %}on{% else %}off{% endif %}"
# entity_id: light.yeelight_bedside_7811dc9013d8 #米家床头灯
- service: automation.turn_off
data:
entity_id: automation.auto_BedRoom1_lamp_off #灯1-3自动化
##灯1-2主卧室:主卧人体1或主卧人体2感应-主卧吸顶灯关且米家床头灯关且太阳落山-米家床头灯开且灯1-3自动关自动化 开
- alias: auto_BedRoom1_lamp_on
#initial_state: true
hide_entity: false
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor_158XXXXXXXXX #主卧人体传感器
to: 'on'
- platform: state
entity_id: binary_sensor.motion_sensor_158XXXXXXXXXX #主卧人体传感器2
to: 'on'
condition:
condition: and
conditions:
- condition: state
entity_id: sun.sun
state: "below_horizon"
- condition: state
entity_id: light.yeelight_ceiling_28XXXXXXXXX #主卧吸顶灯
state: 'off'
- condition: state
entity_id: light.yeelight_bedside_78XXXXXXXXX #米家床头灯
state: 'off'
action:
- service_template: light.turn_on
entity_id: light.yeelight_bedside_78XXXXXXXXX #米家床头灯
- service: automation.turn_off
data:
entity_id: automation.auto_BedRoom1_lamp #灯1-1自动化
- service: automation.turn_on
data:
entity_id: automation.auto_BedRoom1_lamp_off #灯1-3自动化
##灯1-3主卧室:主卧人体1或主卧人体2无感应5秒后-米家床头灯及自动化 关
- alias: auto_BedRoom1_lamp_off
#initial_state: false
hide_entity: false
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor_158XXXXXXXXXX #主卧人体传感器
to: 'off'
for:
seconds: 5 #等待5秒
- platform: state
entity_id: binary_sensor.motion_sensor_158XXXXXXXXXX #主卧人体传感器2
to: 'off'
for:
seconds: 5 #等待5秒
action:
- service_template: light.turn_off
entity_id: light.yeelight_bedside_78XXXXXXXXX #米家床头灯
- delay:
seconds: 0.5
- service: automation.turn_off
data:
entity_id: automation.auto_BedRoom1_lamp_off #灯1-3自动化
- service: automation.turn_on
data:
entity_id: automation.auto_BedRoom1_lamp #灯1-1自动化
##灯1-4主卧室:开主卧吸顶灯关米家床头灯
- alias: auto_BedRoom1_ceiling_lamp
#initial_state: true #重启HA自动化是开启(true)还是关闭(false)
hide_entity: false #隐藏自动化
trigger:
- platform: state #设备状态
entity_id: light.yeelight_ceiling_28XXXXXXXXX #主卧吸顶灯
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: light.yeelight_bedside_78XXXXXXXXX #米家床头灯
state: 'on'
action:
- service: light.turn_off
entity_id: light.yeelight_bedside_78XXXXXXXXX ##米家床头灯
##灯1-5主卧室:开米家床头灯关主卧吸顶灯
- alias: auto_BedRoom1_lamp_ceiling
#initial_state: true #重启HA自动化是开启(true)还是关闭(false)
hide_entity: false #隐藏自动化
trigger:
- platform: state #设备状态
entity_id: light.yeelight_bedside_78XXXXXXXXX #米家床头灯
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: light.yeelight_ceiling_28XXXXXXXXX #主卧吸顶灯
state: 'on'
action:
- service: light.turn_off
entity_id: light.yeelight_ceiling_28XXXXXXXXX ##主卧吸顶灯
##灯1-6主卧室:主卧无线开关(一、二、墙壁)单击开关主卧吸顶灯
- alias: switch_3_ceiling_toggle
#initial_state: true
trigger:
- platform: event
event_type: xiaomi_aqara.click
event_data:
entity_id: binary_sensor.wall_switch_right_158XXXXXXXXXX #主卧墙壁无线开关右键
click_type: single
- platform: event
event_type: xiaomi_aqara.click
event_data:
entity_id: binary_sensor.switch_158XXXXXXXXXX #主卧无线开关一
click_type: single
- platform: event
event_type: xiaomi_aqara.click
event_data:
entity_id: binary_sensor.switch_158XXXXXXXXXX #主卧无线开关二
click_type: single
action:
- service_template: "light.toggle"
entity_id: light.yeelight_ceiling_28XXXXXXXXX #主卧吸顶灯
可复制上面自己保存,可下载下面的直接放入packages文件夹下
|