2024/10/04

ESPHome UDP 컴포넌트: 주방 벽스위치로 후드 제어



ESP device간 제어로 ESPNOW, HTTP Request를 거쳐 최신버전에서 지원되는 UDP로 이동.
주방후드전원을 주방 벽스위치에 UDP상태반영을 한 템플릿스위치를 만들어 HA를 거치지 않고 제어.

주방후드 전원:
esphome:
  name: neo12-outlet
esp8266:
  board: esp01_1m

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

udp:
  binary_sensors:
    - hood

binary_sensor:
  - platform: template
    id: hood
    lambda: "return id(switch1).state;"
  - platform: udp
    provider: zemi5-kitchen
    id: hood2
    on_press:
      switch.turn_on: switch1
    on_release:
      switch.turn_off: switch1
  - platform: gpio
    pin:
      number: GPIO00
      inverted: True
    name: "Hood Button"
    on_press:
      - switch.toggle: switch1

switch:
  - platform: gpio
    name: "Hood Relay"
    id: switch1
    pin:
      number: 14
    on_turn_on:
    - switch.turn_on: switch1
    on_turn_off:
    - switch.turn_off: switch1


주방벽스위치:
esphome:
  name: zemi5-kitchen
esp8266:
  board: esp01_1m

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

udp:
  binary_sensors:
    - hood2

binary_sensor:
  - platform: template
    id: hood2
    lambda: "return id(hood3).state;"
  - platform: udp
    provider: neo12-outlet
    id: hood
    on_press:
      switch.turn_on: hood3

  - platform: gpio
    id: button3
    name: "Kitchen Bottom"
    pin:
      number: GPIO16
      inverted: true
    on_multi_click:
    - timing:
        - ON for 0.6s to 3s
        - OFF for at least 0.1s
      then:
        - switch.toggle: hood3

switch:
  - platform: template
    name: "Hood Switch"
    id: hood3
    optimistic: true



** 참고: ESPHome: HTTP Request 컴포넌트