Skip to content

Instantly share code, notes, and snippets.

@xangin
Last active April 23, 2023 02:10
Show Gist options
  • Save xangin/209171f6126ef35f4277ea146a872c15 to your computer and use it in GitHub Desktop.
Save xangin/209171f6126ef35f4277ea146a872c15 to your computer and use it in GitHub Desktop.
IKEA tradfri遙控器控制智慧風扇
blueprint:
name: IKEA遙控器控制智慧風扇
description: 可控制開關/擺頭/風速增減,遙控器中間鈕為開關鍵
domain: automation
input:
fan_entity:
name: 風扇實體
selector:
entity:
domain: fan
remote_entity:
name: IKEA遙控器實體
description: "請選擇sensor.xxxx_action"
selector:
entity:
domain: sensor
oscillate_select:
name: 擺頭
description: 用哪個鈕來控制?
selector:
select:
options:
- brightness_up_click
- brightness_down_click
speed_up_select:
name: 風速增強
description: 用哪個鈕來控制? (不能與風速減弱重複)
selector:
select:
options:
- arrow_right_click
- arrow_left_click
speed_down_select:
name: 風速減弱
description: 用哪個鈕來控制? (不能與風速增強重複)
selector:
select:
options:
- arrow_right_click
- arrow_left_click
fan_speed_step_percent:
name: 每次風速增減百分比
description: 當按下一次風速增減時,是增加或減少多少百分比
default: 10
selector:
number:
min: 1.0
max: 50.0
unit_of_measurement: '%'
step: 1.0
mode: slider
mode: single
max_exceeded: silent
trigger:
- platform: state
entity_id: !input 'remote_entity'
to: 'toggle'
- platform: state
entity_id: !input 'remote_entity'
to: 'brightness_up_click'
- platform: state
entity_id: !input 'remote_entity'
to: 'brightness_down_click'
- platform: state
entity_id: !input 'remote_entity'
to: 'arrow_right_click'
- platform: state
entity_id: !input 'remote_entity'
to: 'arrow_left_click'
variables:
oscillate_select_entity: !input 'oscillate_select'
speed_up_select_entity: !input 'speed_up_select'
speed_down_select_entity: !input 'speed_down_select'
action:
- choose:
- alias: "Fan power on/off by center button"
conditions: "{{ trigger.to_state.state == 'toggle' }}"
sequence:
- entity_id: !input 'fan_entity'
service: fan.toggle
- alias: "Fan oscillate on/off by brightness up button"
conditions: "{{ trigger.to_state.state == oscillate_select_entity }}"
sequence:
- choose:
- conditions:
- or:
- condition: state
entity_id: !input 'fan_entity'
attribute: oscillate
state: false
- condition: state
entity_id: !input 'fan_entity'
attribute: oscillating
state: false
sequence:
- service: fan.oscillate
data:
oscillating: true
target:
entity_id: !input 'fan_entity'
- conditions:
- or:
- condition: state
entity_id: !input 'fan_entity'
attribute: oscillate
state: true
- condition: state
entity_id: !input 'fan_entity'
attribute: oscillating
state: true
sequence:
- service: fan.oscillate
data:
oscillating: false
target:
entity_id: !input 'fan_entity'
- alias: "Fan decrease speed by arrow left button"
conditions: "{{ trigger.to_state.state == speed_down_select_entity }}"
sequence:
- service: fan.decrease_speed
data:
percentage_step: !input 'fan_speed_step_percent'
target:
entity_id: !input 'fan_entity'
- alias: "Fan increase speed by arrow right button"
conditions: "{{ trigger.to_state.state == speed_up_select_entity }}"
sequence:
- choose:
- conditions:
- condition: state
entity_id: !input 'fan_entity'
state: 'off'
sequence:
- service: fan.turn_on
target:
entity_id: !input 'fan_entity'
default:
- service: fan.increase_speed
data:
percentage_step: !input 'fan_speed_step_percent'
target:
entity_id: !input 'fan_entity'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment