树莓派遥控器 LIRC 添加到homeassistant

做这些的前提是你已经能够用树莓派发射电视的遥控信号。

1.在congfiguration.yaml 添加如下设置

shell_command: !include shell.yaml
# 输入选项
input_select:
  ac_setting:
    name: '空调设置'
    icon: mdi:air-conditioner
    options:
      - kaiji
      - queding
      - xiangzuo
      - xiangyou
      - xiangshang
      - xiangxia

一定要注意空格。

2.在shell.yaml中加入如下内容。

ac_kaiji: irsend SEND_ONCE hezi KEY_ENTER
ac_queding: irsend SEND_ONCE  hezi KEY_SPACE
ac_zuo: irsend SEND_ONCE  hezi KEY_LEFT
ac_you: irsend SEND_ONCE  hezi KEY_RIGHT
ac_shang: irsend SEND_ONCE  hezi KEY_UP
ac_xia: irsend SEND_ONCE  hezi KEY_DOWN
 

一定要注意冒号后面有空格。

3.在automation.yaml 添加如下内容,把面板上的选项对应到相应的服务上。

- alias: ac_kaiji
  trigger:
    platform: state
    entity_id: input_select.ac_setting
    to: 'kaiji'
  action:
    - service: shell_command.ac_kaiji

- alias: ac_queding
  trigger:
    platform: state
    entity_id: input_select.ac_setting
    to: 'queding'
  action:
    - service: shell_command.ac_queding

- alias: ac_shang
  trigger:
    platform: state
    entity_id: input_select.ac_setting
    to: 'xiangshang'
  action:
    - service: shell_command.ac_shang

- alias: ac_xia
  trigger:
    platform: state
    entity_id: input_select.ac_setting
    to: 'xiangxia'
  action:
    - service: shell_command.ac_xia

- alias: ac_zuo
  trigger:
    platform: state
    entity_id: input_select.ac_setting
    to: 'xiangzuo'
  action:
    - service: shell_command.ac_zuo

- alias: ac_you
  trigger:
    platform: state
    entity_id: input_select.ac_setting
    to: 'xiangyou'
  action:
    - service: shell_command.ac_you

4.在groups.yaml添加如下内容,把组件合成一组。

ac_setting:
    view: no
    name: '电视遥控'
    icon: mdi:air-conditioner
    entities:
        - input_select.ac_setting

 

改完以后,重启lircd,并运行hass。

sudo /etc/init.d/lircd restart 

hass

树莓派遥控器 LIRC 添加到homeassistant_第1张图片

你可能感兴趣的:(树莓派)