homeassistant-config-example/scripts.yaml

183 lines
5.9 KiB
YAML
Raw Normal View History

2020-01-08 00:02:14 +08:00
# 这里是脚本,可以理解为一些组合命令。
# 不同于automation不会自动触发。
# 虽然script也完全可以写到switch里但有时候为了保持switch简单易读就分离出来。
# https://www.home-assistant.io/integrations/script/
# amplifier ==============================
amplifier_volume_up_10_times:
2020-05-02 18:44:52 +08:00
alias: Amplifier Vol Up
2020-01-08 00:02:14 +08:00
sequence:
- service: switch.turn_on
entity_id: switch.amplifier_volume_up
- service: switch.turn_on
entity_id: switch.amplifier_volume_up
- service: switch.turn_on
entity_id: switch.amplifier_volume_up
- service: switch.turn_on
entity_id: switch.amplifier_volume_up
- service: switch.turn_on
entity_id: switch.amplifier_volume_up
- service: switch.turn_on
entity_id: switch.amplifier_volume_up
- service: switch.turn_on
entity_id: switch.amplifier_volume_up
- service: switch.turn_on
entity_id: switch.amplifier_volume_up
- service: switch.turn_on
entity_id: switch.amplifier_volume_up
- service: switch.turn_on
entity_id: switch.amplifier_volume_up
- delay: 00:00:00
amplifier_volume_down_10_times:
2020-05-02 18:44:52 +08:00
alias: Amplifier Vol Down
2020-01-08 00:02:14 +08:00
sequence:
- service: switch.turn_on
entity_id: switch.amplifier_volume_down
- service: switch.turn_on
entity_id: switch.amplifier_volume_down
- service: switch.turn_on
entity_id: switch.amplifier_volume_down
- service: switch.turn_on
entity_id: switch.amplifier_volume_down
- service: switch.turn_on
entity_id: switch.amplifier_volume_down
- service: switch.turn_on
entity_id: switch.amplifier_volume_down
- service: switch.turn_on
entity_id: switch.amplifier_volume_down
- service: switch.turn_on
entity_id: switch.amplifier_volume_down
- service: switch.turn_on
entity_id: switch.amplifier_volume_down
- service: switch.turn_on
entity_id: switch.amplifier_volume_down
- delay: 00:00:00
# 发送媒体键 shell command 无法被前端直接调用 套个壳
media_play_pause:
2020-05-02 18:44:52 +08:00
alias: Play Pause
2020-01-08 00:02:14 +08:00
sequence:
- service: shell_command.send_play_pause
media_previous:
alias: Previous
sequence:
- service: shell_command.send_previous_track
media_next:
alias: Next
sequence:
- service: shell_command.send_next_track
# theater mode ==============================
theater_mode_on:
alias: 'Theater Mode ON'
sequence:
# 状态记录器
- service: input_boolean.turn_on
entity_id: input_boolean.theater_mode
# 放下幕布 不灵敏多按几次
- service: switch.turn_on
entity_id: switch.screen
- service: switch.turn_on
entity_id: switch.screen
- service: switch.turn_on
entity_id: switch.screen
- service: switch.turn_on
entity_id: switch.screen
- service: switch.turn_on
entity_id: switch.screen
- delay: 00:00:10
2020-07-13 22:07:25 +08:00
# turn on amplifier
- service: switch.turn_on
entity_id: switch.amplifier_smart
2020-01-08 00:02:14 +08:00
# 打开投影仪 为了保险多按几次
- service: switch.turn_on
entity_id: switch.projector_power
- service: switch.turn_on
entity_id: switch.projector_power
- service: switch.turn_on
entity_id: switch.projector_power
2020-01-13 19:12:15 +08:00
- delay: 00:00:20
2020-01-08 00:02:14 +08:00
# 关灯
- service: switch.turn_off
entity_id: group.light
2021-10-06 18:53:11 +08:00
- delay: 00:00:10
2021-06-26 21:20:10 +08:00
# 关电脑屏幕
- service: switch.turn_off
entity_id: switch.monitor
2020-01-08 00:02:14 +08:00
theater_mode_off:
alias: 'Theater Mode OFF'
sequence:
# 状态记录器
- service: input_boolean.turn_off
entity_id: input_boolean.theater_mode
# 关闭投影仪 为了保险多按几次
- service: switch.turn_off
entity_id: switch.projector_power
2020-04-03 20:07:31 +08:00
- delay: 00:00:01
2020-01-08 00:02:14 +08:00
- service: switch.turn_off
entity_id: switch.projector_power
2020-04-03 20:07:31 +08:00
- delay: 00:00:01
2020-01-08 00:02:14 +08:00
- service: switch.turn_off
entity_id: switch.projector_power
2020-04-03 20:07:31 +08:00
# 开灯 天亮的话就不开
2020-04-14 20:53:26 +08:00
- service_template: > # 太阳落山的话开灯
switch.turn_{% if is_state('sun.sun','below_horizon') %}on{% else %}off{% endif %}
entity_id:
2021-06-26 21:20:10 +08:00
- switch.light_3_smart
# 开电脑屏幕
- service: switch.turn_on
entity_id: switch.monitor
2020-01-13 19:12:15 +08:00
# 收起幕布 不灵敏多按几次
- service: switch.turn_off
entity_id: switch.screen
- service: switch.turn_off
entity_id: switch.screen
- service: switch.turn_off
entity_id: switch.screen
- service: switch.turn_off
entity_id: switch.screen
- service: switch.turn_off
entity_id: switch.screen
2020-04-03 20:07:31 +08:00
2020-05-02 21:31:30 +08:00
# return & leave home actions ==============================
2020-05-02 18:44:52 +08:00
home_return:
2020-04-03 20:07:31 +08:00
alias: 'Return Home'
sequence:
2020-05-02 21:31:30 +08:00
- service: input_boolean.turn_on # 状态记录器
entity_id: input_boolean.at_home
2020-04-03 20:07:31 +08:00
# template 如果没有else会导致异常并中断就要放在最后。
- service_template: > # 太阳落山的话开灯
switch.turn_{% if is_state('sun.sun','below_horizon') %}on{% else %}off{% endif %}
entity_id:
- switch.light_2_smart
- switch.light_3_smart
2021-06-26 21:20:10 +08:00
- service: switch.turn_on
entity_id:
- switch.amplifier_smart # 开功放
- switch.monitor # 开显示器
2021-10-06 18:53:11 +08:00
- switch.aircon_smart
- switch.purifier
2020-05-05 21:56:45 +08:00
- service: shell_command.say_welcome_back # 欢迎问候
2020-04-03 20:07:31 +08:00
- service: shell_command.send_volume_up # wakeup screen
2021-10-06 18:53:11 +08:00
- service: shell_command.open_music_player # 打开播放器
- delay: 00:00:05
- service: shell_command.send_space # 播放(远程电脑上已开启的播放器)
2020-05-02 21:31:30 +08:00
home_leave:
alias: 'Leave Home'
sequence:
- service: input_boolean.turn_off # 状态记录器
entity_id: input_boolean.at_home
2020-05-05 21:56:45 +08:00
- service: shell_command.say_welcome_leave # 欢迎问候
2020-05-02 21:31:30 +08:00
- service: switch.turn_off
entity_id:
2021-06-26 21:20:10 +08:00
- switch.monitor
2020-05-02 21:31:30 +08:00
- switch.amplifier_smart
- switch.water_pump
2020-10-07 00:20:31 +08:00
- switch.aircon_smart
2021-06-26 21:20:10 +08:00
- switch.purifier
2020-05-02 21:31:30 +08:00
- group.light
- service: shell_command.screen_off # 息屏