Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
197 changes: 197 additions & 0 deletions src/docs/devices/TCP-Smart-4AC-USB-Power-Strip-WPS4WUK/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
# Substitutions
substitutions:
# Device Names
device_name: "plugstrip01"
friendly_name: "plugstrip01"
# Icon
main_icon: "power-socket-uk"
# Default Relay State
# Aka: `restore_mode` in documentation
# Options: `RESTORE_DEFAULT_OFF`, `RESTORE_DEFAULT_ON`, `ALWAYS_ON` & `ALWAYS_OFF`
default_state: "RESTORE_DEFAULT_OFF"

# Basic Config
esphome:
name: "${device_name}"

esp8266:
board: esp01_1m

logger:

# Device Specific Config
binary_sensor:
# Push Button (Toggles All Relays When Pressed)
- platform: gpio
pin:
number: GPIO3
mode: INPUT_PULLUP
inverted: true
name: "${friendly_name} Button"
on_press:
if:
condition:
light.is_on: led
then:
- switch.turn_off: relay_socket_1
- switch.turn_off: relay_socket_2
- switch.turn_off: relay_socket_3
- switch.turn_off: relay_socket_4
- switch.turn_off: relay_usb
- light.turn_off:
id: led
transition_length: 0s
else:
- switch.turn_on: relay_socket_1
- switch.turn_on: relay_socket_2
- switch.turn_on: relay_socket_3
- switch.turn_on: relay_socket_4
- switch.turn_on: relay_usb
- light.turn_on:
id: led
brightness: 100%
transition_length: 0s

switch:
# Relay - Socket 1 (As Switch)
- platform: gpio
name: "${friendly_name} socket 1"
icon: "mdi:${main_icon}"
pin: GPIO13
id: relay_socket_1
restore_mode: "${default_state}"
on_turn_on:
- light.turn_on:
id: led
brightness: 100%
transition_length: 0s
on_turn_off:
if:
condition:
and:
- switch.is_off: relay_socket_1
- switch.is_off: relay_socket_2
- switch.is_off: relay_socket_3
- switch.is_off: relay_socket_4
- switch.is_off: relay_usb
then:
- light.turn_off:
id: led
transition_length: 0s

# Relay - Socket 2 (As Switch)
- platform: gpio
name: "${friendly_name} socket 2"
icon: "mdi:${main_icon}"
pin: GPIO12
id: relay_socket_2
restore_mode: "${default_state}"
on_turn_on:
- light.turn_on:
id: led
brightness: 100%
transition_length: 0s
on_turn_off:
if:
condition:
and:
- switch.is_off: relay_socket_1
- switch.is_off: relay_socket_2
- switch.is_off: relay_socket_3
- switch.is_off: relay_socket_4
- switch.is_off: relay_usb
then:
- light.turn_off:
id: led
transition_length: 0s

# Relay - Socket 3 (As Switch)
- platform: gpio
name: "${friendly_name} socket 3"
icon: "mdi:${main_icon}"
pin: GPIO4
id: relay_socket_3
restore_mode: "${default_state}"
on_turn_on:
- light.turn_on:
id: led
brightness: 100%
transition_length: 0s
on_turn_off:
if:
condition:
and:
- switch.is_off: relay_socket_1
- switch.is_off: relay_socket_2
- switch.is_off: relay_socket_3
- switch.is_off: relay_socket_4
- switch.is_off: relay_usb
then:
- light.turn_off:
id: led
transition_length: 0s

# Relay - Socket 4 (As Switch)
- platform: gpio
name: "${friendly_name} socket 4"
icon: "mdi:${main_icon}"
pin: GPIO5
id: relay_socket_4
restore_mode: "${default_state}"
on_turn_on:
- light.turn_on:
id: led
brightness: 100%
transition_length: 0s
on_turn_off:
if:
condition:
and:
- switch.is_off: relay_socket_1
- switch.is_off: relay_socket_2
- switch.is_off: relay_socket_3
- switch.is_off: relay_socket_4
- switch.is_off: relay_usb
then:
- light.turn_off:
id: led
transition_length: 0s

# Relay - USB (As Switch)
- platform: gpio
name: "${friendly_name} USB"
icon: "mdi:${main_icon}"
pin: GPIO14
id: relay_usb
restore_mode: "${default_state}"
on_turn_on:
- light.turn_on:
id: led
brightness: 100%
transition_length: 0s
on_turn_off:
if:
condition:
and:
- switch.is_off: relay_socket_1
- switch.is_off: relay_socket_2
- switch.is_off: relay_socket_3
- switch.is_off: relay_socket_4
- switch.is_off: relay_usb
then:
- light.turn_off:
id: led
transition_length: 0s

# Relay State LED
output:
- platform: esp8266_pwm
id: state_led
pin:
number: GPIO1
inverted: true

light:
- platform: monochromatic
output: state_led
id: led
Loading
Loading