Advertisement
xangin

XY-WFUSB ESPhome code

Jun 24th, 2023 (edited)
858
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.61 KB | None | 1 0
  1. ######################################################################################################
  2. ## Original post from: https://simondn.blogspot.com/2023/06/usbesphome.html
  3. ## source code from: https://devices.esphome.io/devices/Sinilink-XY-WFUSB-USB-Switch-Relay
  4. ######################################################################################################
  5. substitutions:
  6.   device_name: usb-ctrl
  7.  
  8. esphome:
  9.   name: ${device_name}
  10.   friendly_name: USB-Ctrl
  11.  
  12. esp8266:
  13.   board: esp01_1m
  14.  
  15. # Enable logging
  16. logger:
  17. # Enable Home Assistant API
  18. api:
  19. ota:
  20.   password: !secret ota_password
  21.  
  22. wifi:
  23.   ssid: !secret my_ap_ssid
  24.   password: !secret my_ap_password
  25.  
  26.   # Enable fallback hotspot (captive portal) in case wifi connection fails
  27.   ap:
  28.     ssid: "${device_name}"
  29.     password: "12345678"
  30.     ap_timeout: 3min
  31.  
  32. captive_portal:
  33.  
  34. status_led:
  35.   pin:
  36.     number: GPIO16 # Blue LED
  37.  
  38. switch:
  39.  # Relay
  40.   - platform: gpio
  41.     id: relay
  42.     pin: GPIO5
  43.     name: "${device_name} Relay"
  44.     on_turn_on:
  45.       - switch.turn_on: green_led
  46.     on_turn_off:
  47.       - switch.turn_off: green_led
  48.  
  49.   # Green LED
  50.   # LED is on when relay is off
  51.   - platform: gpio
  52.     pin: GPIO14
  53.     id: green_led
  54.     inverted: true # start on
  55.  
  56. # Button
  57. binary_sensor:
  58.   - platform: gpio
  59.     id: button
  60.     pin:
  61.       number: GPIO04
  62.       mode: INPUT_PULLUP
  63.       inverted: True
  64.     on_press:
  65.       - switch.toggle: relay
  66.  
  67.   - platform: status
  68.     name: "${device_name} WiFi Status"    
  69.  
  70. sensor:
  71.   - platform: wifi_signal
  72.     name: "${device_name} WiFi Signal"
  73.     update_interval: 60s    
Tags: ESPhome ha
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement