三開改裝模塊 + ESPHome = 改裝電風扇
本帖最后由 chinyaolin 于 2019-9-16 15:46 编辑2019/6/17 update: 論壇三開模塊的按鍵觸發太敏感, 代碼新增 filters delayed_on delayed_off
2019/9/14 update: 補兩張很久以前拆開電風扇的圖片
2019/9/16 update: 其實不見得要使用 ESPhome, 只需要選擇能支持 interlock 的固件都能達成目的
https://bbs.hassbian.com/forum.php?mod=image&aid=8989&size=300x300&key=36258275f6774799&nocache=yes&type=fixnonehttps://bbs.hassbian.com/forum.php?mod=image&aid=9001&size=300x300&key=a2459a8fd212a87b&nocache=yes&type=fixnone
直接給代碼
ESPHome 代碼
這裡的重點是 relay1,2,3 必需互鎖(interlock) 以及同按鈕按第二次則關閉電扇
**** Hidden Message *****
建立一個 sensor, 計算風扇檔位
sensor:
- platform: template
sensors:
hassmart_3ch_412707_speed:
value_template: >
{% if states('switch.hassmart_3ch_412707_sw3') == 'on' %}
3
{% elif states('switch.hassmart_3ch_412707_sw2') == 'on' %}
2
{% elif states('switch.hassmart_3ch_412707_sw1') == 'on' %}
1
{% else %}
0
{% endif %}
建立 FAN 元件
- platform: template
fans:
hassmart_3ch_412707:
value_template: >
{% if is_state("sensor.hassmart_3ch_412707_speed", "0") %}
off
{% else %}
on
{% endif %}
speed_template: '{{ states("sensor.hassmart_3ch_412707_speed") }}'
turn_on:
- service: switch.turn_on
entity_id: switch.hassmart_3ch_412707_sw3
turn_off:
- service: switch.turn_off
entity_id: switch.hassmart_3ch_412707_sw1
- service: switch.turn_off
entity_id: switch.hassmart_3ch_412707_sw2
- service: switch.turn_off
entity_id: switch.hassmart_3ch_412707_sw3
set_speed:
- service: switch.turn_on
data_template:
entity_id: >
{% if speed == '1' %}
switch.hassmart_3ch_412707_sw1
{% elif speed == '2' %}
switch.hassmart_3ch_412707_sw2
{% else %}
switch.hassmart_3ch_412707_sw3
{% endif %}
speeds:
- '1'
- '2'
- '3'
成果
谢谢分享。 参考一下,按你这个,我是不是也能把烤火桌给改了:lol 学习一下 楼主太牛了吧,还有这种操作? 感谢大佬分享esphome的教程,新手来学学esphome 不错不错,这个思路很清奇,就需要这种不同的想法才能创造更多的方案,谢谢大佬分享 感谢大佬分享esphome的教程,新手来学学esphome 我正在学 谢谢楼主分享。试试看 有意思,这个电风扇一下子变高级了。