HA有个很好的WEB界面,叫FLOORPLAN,本来也不想搞,觉得大不了就是多点击几下就可以实现效果,后来手痒还是动手把这块给加进来。
在酷家乐找不到现在住的房子的平面图,只好找来一张很模糊的平面图自己用PHTOSHOP把结构给描出来,用推荐的Inkscape免费软件把各种家电添加进去,设置好对象属性,就基本可以控制开关了。
设置entity状态处于ON时以红色表示,处于OFF时以绿色表示,比如红外侦测到客厅有人,那客厅人的图标就显示为红色,书房的电脑PING不同的时候,就显示绿色。
期间碰到点问题的是控制投影仪、电视机和CD机需要涉及的自动化脚本,举播放电影为例,执行的开关顺序为:
– 射频打开明基投影仪电源;
– 射频打开HTMI切换器电源;
– 射频打开音频解码器电源;
– 射频打开功放电源;
– 射频打开芝杜蓝光播放器电源;
– 红外打开投影仪(POWER ON);
– 射频关闭客厅灯、左右射灯;
– 射频打开餐厅灯,不然暗摸摸的;
– 红外切换功放音源输入为AUX;
– 红外切换音频解码器为5.1声道;
– 红外切换音频解码器输入为光纤口1;
– 红外打开芝杜播放器(POWER ON);
– 射频关闭餐厅灯光,开始看电影,关闭所有灯光了。
刚开始使用script组件,是可以达到“开”的效果,但是在FLOORPLAN里“关”无法实现,上网差了一下,建议使用automation+input_boolean,我也不知道input_boolean怎么翻译,就按照这个思路做了一个投影仪的input_boolean,放在FLOORPLAN里,居然就达到我要的效果:点击投影仪,按以上顺序执行各种命令,关闭的时候再依次执行另外一个automation。
configuration.yaml添加的内容为:
input_boolean: benq: name: Play Movie initial: off icon: mdi:keyboard-variant tv: name: Play TV initial: off icon: mdi:keyboard-variant nas_music: name: NAS Music initial: off icon: mdi:keyboard-variant
附上自动化部分的内容。
################# #播放投影仪 ################# - alias: Play Movie via Projector trigger: - platform: state entity_id: input_boolean.benq to: 'on' action: - service: switch.turn_on data: entity_id: group.projector - delay: seconds: 10 - service: switch.turn_on data: entity_id: switch.power_benq - delay: seconds: 1 - service: switch.turn_off data: entity_id: group.projector_on_lights - delay: seconds: 1 - service: switch.turn_on data: entity_id: switch.canting - delay: seconds: 1 - service: switch.turn_on data: entity_id: switch.winner_aux - delay: seconds: 1 - service: switch.turn_on data: entity_id: switch.music_decoder_21 - delay: seconds: 1 - service: switch.turn_on data: entity_id: switch.music_decoder_opt1 - delay: seconds: 15 - service: switch.turn_on data: entity_id: switch.switch_hdmi_to_zidoo - delay: seconds: 60 - service: switch.turn_on data: entity_id: switch.benq_mute - delay: seconds: 5 - service: switch.turn_off data: entity_id: switch.canting - alias: Turn off Movie via Projector trigger: - platform: state entity_id: input_boolean.benq to: 'off' action: - service: switch.turn_off data: entity_id: switch.hdmi_switch - delay: seconds: 1 - service: switch.turn_off data: entity_id: switch.music_decoder - delay: seconds: 1 - service: switch.turn_off data: entity_id: switch.winnder_amplifier - delay: seconds: 1 - service: switch.turn_off data: entity_id: switch.zidoo - delay: seconds: 1 - service: switch.turn_off data: entity_id: switch.power_benq - delay: seconds: 100 - service: switch.turn_off data: entity_id: switch.benq_projector - delay: seconds: 1 - service: switch.turn_on data: entity_id: switch.canting