2023-01-19 15:25:18 +00:00
|
|
|
# Sinilink USB Switch Module (XY-WFUSB)
|
|
|
|
esphome:
|
|
|
|
name: usb-switch
|
2023-11-02 16:46:55 +00:00
|
|
|
|
|
|
|
esp8266:
|
|
|
|
restore_from_flash: true
|
2023-01-19 15:25:18 +00:00
|
|
|
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:
|
2023-11-02 16:46:55 +00:00
|
|
|
- switch.toggle: "usb_switch_relay"
|