本帖最后由 leoyanger 于 2017-10-23 17:09 编辑
input_boolean:
landing_dim:
name: Landing Dim
initial: off
#变暗脚本
script:
dim_light_landing:
sequence:
- condition: state
entity_id: input_boolean.landing_dim
state: 'on'
- service: light.turn_on
entity_id: light.landing_light
data_template:
brightness: '{{states.light.landing_light.attributes.brightness - 10}}'
- service: script.turn_off
entity_id: script.dim_light_landing
- service: script.turn_on
entity_id: script.dim_light_landing
#变亮脚本
script:
brighten_light_landing:
sequence:
- condition: state
entity_id: input_boolean.landing_dim
state: 'off'
- service: light.turn_on
entity_id: light.landing_light
data_template:
brightness: '{{states.light.landing_light.attributes.brightness + 10}}'
- service: script.turn_off
entity_id: script.brighten_light_landing
- service: script.turn_on
entity_id: script.brighten_light_landing
#开灯并调亮
- alias: xiaomi landing brighten on
initial_state: 'on'
trigger:
- platform: event
event_type: click
event_data:
entity_id: binary_sensor.switch_158d00019df218
click_type: long_click_press
- platform: event
event_type: click
event_data:
entity_id: binary_sensor.switch_158d00016c0bac
click_type: long_click_press
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.landing_dim
state: 'off'
- condition: state
entity_id: light.landing_light
state: 'on'
action:
- service: script.turn_on
entity_id: script.brighten_light_landing
#更改input_boolean.landing_dim状态
- alias: xiaomi landing brighten off
initial_state: 'on'
trigger:
- platform: state
entity_id: binary_sensor.switch_158d00019df218
from: 'on'
to: 'off'
- platform: state
entity_id: binary_sensor.switch_158d00016c0bac
from: 'on'
to: 'off'
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.landing_dim
state: 'off'
- condition: state
entity_id: light.landing_light
state: 'on'
action:
- service: input_boolean.turn_on
entity_id: input_boolean.landing_dim
- alias: xiaomi landing dim on
initial_state: 'on'
trigger:
- platform: event
event_type: click
event_data:
entity_id: binary_sensor.switch_158d00019df218
click_type: long_click_press
- platform: event
event_type: click
event_data:
entity_id: binary_sensor.switch_158d00016c0bac
click_type: long_click_press
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.landing_dim
state: 'on'
- condition: state
entity_id: light.landing_light
state: 'on'
action:
- service: script.turn_on
entity_id: script.dim_light_landing
- alias: xiaomi landing brighten off
initial_state: 'on'
trigger:
- platform: state
entity_id: binary_sensor.switch_158d00019df218
from: 'on'
to: 'off'
- platform: state
entity_id: binary_sensor.switch_158d00016c0bac
from: 'on'
to: 'off'
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.landing_dim
state: 'on'
- condition: state
entity_id: light.landing_light
state: 'on'
action:
- service: input_boolean.turn_off
entity_id: input_boolean.landing_dim
|