[分享] NT$100,傻瓜插座變智能(ESPHome)

緣由: 書房電腦的DAC跟擴大機都是傳統機械開關,每次開電腦都要另外先開DAC、再開擴大機,關電腦則是先關擴大機、再關DAC,必須按順序,否則…(有玩音響的就知道,就不浪費版面了)

發想: 最簡單的解法當然就是裝兩個智慧插座,但花幾百塊就為了懶的手動開關DAC跟擴大機? 怎麼想都覺得不值得@@,那就DIY吧!

材料:

  1. 插座x2 (我用的型號是Panasonic WTDFP151236,是除了COOPER IG8300之外,我比較喜歡的插座型號
  2. 雙聯明盒x1 (我的飾板不知道丟哪裡去了,算了反正最後也是放在螢幕後面看不到,懶的裝飾了)
  3. esp8266 nodemcu x1
  4. relay x2
  5. ac-dc 供電模塊 x1
  6. 微動開關x2
  7. 電線&插頭&杜邦線&wago快速接頭等
    3~7真的不用百元,1跟2是之前換cooper插座,換下來的舊品拿來廢物利用,如果買全新的,應該還要一百來塊吧。

先看成品:

  1. 左上照片是成品,兩組插座下方各有一顆微動開關控制供電通斷
  2. 右邊及下邊的照片分別是我的DAC跟擴大機的開關

esphome yaml:

<font color="#0000ff" size="3">substitutions:
  device_name: socket4a #機房DAC+擴大機

esphome:
  name: ${device_name}
  platform: ESP8266
  board: nodemcuv2

logger:

api:

ota:
  password: !secret wifi_pw

web_server:
  port: 80

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_pw
  ap:
    ssid: "${device_name}_Fallback"
    password: !secret wifi_pw

captive_portal:

switch:
  - platform: gpio
    pin: 
      number: D6
      inverted: true 
    name: "${device_name}_relay1"
    id: relay1
    restore_mode: always_off
  - platform: gpio
    pin: 
      number: D7
      inverted: true
    name: "${device_name}_relay2"
    id: relay2
    restore_mode: always_off

binary_sensor:
  - platform: gpio
    id: button1
    pin:
      number: D4
      mode: INPUT_PULLUP
      inverted: True
    filters:
      - delayed_on: 30ms
      - delayed_off: 30ms
    on_click:
      - switch.toggle: relay1
  - platform: gpio
    id: button2
    pin:
      number: D5
      mode: INPUT_PULLUP
      inverted: True
    filters:
      - delayed_on: 30ms
      - delayed_off: 30ms
    on_click:
      - switch.toggle: relay2
  - platform: status
    name: "${device_name}_status"
    
sensor:
  - platform: wifi_signal
    name: "${device_name}_WiFi_signal"
    update_interval: 60s

  - platform: uptime
    name: "${device_name}_uptime"

text_sensor:
  - platform: version
    name: "${device_name}_ESPHome_version"    
</font>

本帖最後由 diba 於 2021-10-12 21:50 編輯

繼上一篇 NT$150以內的兩切智能開關,使用220V電器更安全 之後,今天來做智慧插座。

緣由: 書房電腦的DAC跟擴大機都是傳統機械開關,每次開電腦都要另外先開DAC、再開擴大機,關電腦則是先關擴大機、再關DAC,必須按順序,否則…(跟主題無關就不浪費版面啦)

發想: 最簡單的解法當然就是裝兩個智慧插座,但花幾百塊就為了懶的手動開關DAC跟擴大機? 怎麼想都覺得不值得@@,那就DIY吧!

材料:

  1. 插座x2 (我用的型號是Panasonic WTDFP151236,是除了COOPER IG8300之外,我最喜歡的插座型號了
  2. 雙聯明盒x1 (我的飾板不知道丟哪裡去了,算了反正最後也是放在螢幕後面看不到,懶的裝飾了)
  3. esp8266 nodemcu x1
  4. relay x2
  5. ac-dc 供電模塊 x1
  6. 微動開關x2
  7. 電線&插頭&杜邦線&wago快速接頭等
    3~7真的不用百元,1跟2是之前換cooper插座,換下來的舊品拿來廢物利用,如果買全新的,應該還要一百來塊吧

esphome yaml:

copy

<font color="#0000ff" size="3">substitutions:
  device_name: socket4a #機房DAC+擴大機

esphome:
  name: ${device_name}
  platform: ESP8266
  board: nodemcuv2

logger:

api:

ota:
  password: !secret wifi_pw

web_server:
  port: 80

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_pw
  ap:
    ssid: "${device_name}_Fallback"
    password: !secret wifi_pw

captive_portal:

switch:
  - platform: gpio
    pin: 
      number: D6
      inverted: true 
    name: "${device_name}_relay1"
    id: relay1
    restore_mode: always_off
  - platform: gpio
    pin: 
      number: D7
      inverted: true
    name: "${device_name}_relay2"
    id: relay2
    restore_mode: always_off

binary_sensor:
  - platform: gpio
    id: button1
    pin:
      number: D4
      mode: INPUT_PULLUP
      inverted: True
    filters:
      - delayed_on: 30ms
      - delayed_off: 30ms
    on_click:
      - switch.toggle: relay1
  - platform: gpio
    id: button2
    pin:
      number: D5
      mode: INPUT_PULLUP
      inverted: True
    filters:
      - delayed_on: 30ms
      - delayed_off: 30ms
    on_click:
      - switch.toggle: relay2
  - platform: status
    name: "${device_name}_status"
    
sensor:
  - platform: wifi_signal
    name: "${device_name}_WiFi_signal"
    update_interval: 60s

  - platform: uptime
    name: "${device_name}_uptime"

text_sensor:
  - platform: version
    name: "${device_name}_ESPHome_version"    
</font>

PS: 為了不讓"正中"踢群,所有我DIY製作的裝置都可以丟到homekit去用,謝謝。

2個讚