128 lines
2.5 KiB
YAML
128 lines
2.5 KiB
YAML
esphome:
|
|
name: sonoff-arduino-bridge
|
|
platform: ESP8266
|
|
board: esp01_1m
|
|
board_flash_mode: dout
|
|
includes:
|
|
- uart_read_line_sensor.h
|
|
|
|
mqtt:
|
|
broker: 192.168.178.36
|
|
port: 1884
|
|
username: nils
|
|
password: inginf95
|
|
on_message:
|
|
- topic: sonoff-arduino-bridge/cmnd
|
|
qos: 0
|
|
then:
|
|
- uart.write: !lambda |-
|
|
std::vector<unsigned char> data(x.begin(), x.end());
|
|
return data;
|
|
- topic: sonoff-arduino-bridge/pc-on
|
|
qos: 0
|
|
then:
|
|
- uart.write: "OPTO1=ON\r"
|
|
- delay: 2s
|
|
- uart.write: "OPTO1=OFF\r"
|
|
- topic: sonoff-arduino-bridge/pc-off
|
|
qos: 0
|
|
then:
|
|
- uart.write: "OPTO1=ON\n"
|
|
- delay: 5s
|
|
- uart.write: "OPTO1=OFF\n"
|
|
|
|
# Enable logging
|
|
logger:
|
|
baud_rate: 0
|
|
|
|
# Enable Home Assistant API
|
|
#api:
|
|
|
|
web_server:
|
|
port: 80
|
|
auth:
|
|
username: nils
|
|
password: inginf95
|
|
|
|
uart:
|
|
tx_pin: GPIO01
|
|
rx_pin: GPIO03
|
|
baud_rate: 9600
|
|
id: uart_bus
|
|
|
|
ota:
|
|
password: "0848c056d780accd7fbb0dbaf989156b"
|
|
|
|
wifi:
|
|
ssid: "EasyBox-368239"
|
|
password: "inginf95"
|
|
|
|
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
|
ap:
|
|
ssid: "Sonoff-Basic-Test"
|
|
password: "Wky9j6BNCgI0"
|
|
|
|
captive_portal:
|
|
|
|
binary_sensor:
|
|
- platform: gpio
|
|
pin:
|
|
number: GPIO0
|
|
mode: INPUT_PULLUP
|
|
inverted: True
|
|
name: "Sonoff Basic Button"
|
|
on_press:
|
|
- switch.toggle: fakebutton
|
|
|
|
switch:
|
|
- platform: template
|
|
name: "Sonoff Basic Relay"
|
|
optimistic: true
|
|
id: fakebutton
|
|
turn_on_action:
|
|
- switch.turn_on: relay
|
|
- light.turn_on: led
|
|
turn_off_action:
|
|
- switch.turn_off: relay
|
|
- light.turn_off: led
|
|
- platform: gpio
|
|
id: relay
|
|
pin: GPIO12
|
|
|
|
output:
|
|
- platform: esp8266_pwm
|
|
id: basic_green_led
|
|
pin:
|
|
number: GPIO13
|
|
inverted: True
|
|
|
|
light:
|
|
- platform: monochromatic
|
|
name: "Sonoff Basic Green LED"
|
|
output: basic_green_led
|
|
id: led
|
|
|
|
sensor:
|
|
- platform: wifi_signal
|
|
name: "Sonoff Basic WiFi Signal"
|
|
update_interval: 60s
|
|
- platform: uptime
|
|
name: "Sonoff Basic Uptime"
|
|
|
|
|
|
text_sensor:
|
|
- platform: version
|
|
name: "Sonoff Basic ESPHome Version"
|
|
- platform: mqtt_subscribe
|
|
name: "UART Tx"
|
|
id: command
|
|
topic: sonoff-arduino-bridge/cmnd
|
|
- platform: custom
|
|
lambda: |-
|
|
auto my_custom_sensor = new UartReadLineSensor(id(uart_bus));
|
|
App.register_component(my_custom_sensor);
|
|
return {my_custom_sensor};
|
|
text_sensors:
|
|
id: "uart_readline"
|
|
name: "UART Rx"
|