78 lines
1.4 KiB
YAML
78 lines
1.4 KiB
YAML
# Sinilink USB Switch Module (XY-WFUSB)
|
|
esphome:
|
|
name: usb-switch
|
|
|
|
esp8266:
|
|
restore_from_flash: true
|
|
board: esp01_1m
|
|
|
|
|
|
# Enable logging
|
|
logger:
|
|
|
|
# Enable Home Assistant API
|
|
api:
|
|
|
|
ota:
|
|
password:
|
|
|
|
wifi:
|
|
ssid: !secret wifi_ssid
|
|
password: !secret wifi_password
|
|
|
|
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
|
ap:
|
|
ssid: "Usb-Switch-X Fallback Hotspot"
|
|
password: !secret wifi_fallback_password
|
|
|
|
captive_portal:
|
|
|
|
status_led:
|
|
pin:
|
|
number: GPIO16 # Blue LED
|
|
|
|
switch:
|
|
# Relay
|
|
- platform: gpio
|
|
id: usb_switch_1_relay
|
|
pin: GPIO5
|
|
name: USB Switch
|
|
|
|
# Green LED
|
|
- platform: gpio
|
|
pin: GPIO14
|
|
id: green_led
|
|
|
|
# Switch template to link relay and green LED states
|
|
# LED is on when relay is off
|
|
# - platform: template
|
|
# id: "usb_switch_1_relay"
|
|
# name: USB Switch 1
|
|
# lambda: |-
|
|
# if (id(relay).state) {
|
|
# return true;
|
|
# } else {
|
|
# return false;
|
|
# }
|
|
# turn_on_action:
|
|
# - switch.turn_on:
|
|
# id: green_led
|
|
# - switch.turn_on:
|
|
# id: relay
|
|
# turn_off_action:
|
|
# - switch.turn_off:
|
|
# id: green_led
|
|
# - switch.turn_off:
|
|
# id: relay
|
|
|
|
# Button
|
|
binary_sensor:
|
|
- platform: gpio
|
|
id: button
|
|
pin:
|
|
number: GPIO04
|
|
mode: INPUT_PULLUP
|
|
inverted: True
|
|
on_press:
|
|
- switch.toggle: "usb_switch_relay"
|