Here is how I make a new device in ESPHome.
The yaml code below is for a Sonoff Basic.
- On the ESPHome dashboard, click on New Device.
- Click on Continue.
- Give your device a name. Click on “Next”.
- In “Select your device type” just click on “Next”. It doesn’t matter what device you select as you will overwrite that data later.
- Ignore the encryption key and click “Skip”. (You can add encryption later if you’re paranoid).
- You should now see your device in the ESPHome dashboard. Click on “Edit”.
- Delete EVERYTHING and paste the code below.
- Change the device name in the pasted code. The name must be exactly the same device name you used earlier.
- Change your WiFi credentials.
- Click on “Install”
- Click on “Manual Download”.
- Click on “Legacy Format”
When it is finished, you will have the .bin file in your downloads folder.
This .bin file is what you want to flash to the device using a UART dongle.
Or if your device has Tasmota already running, you can do an OTA upgrade using the .bin file you just made.
substitutions:
device_name: sonoff_basic
esphome:
name: ${device_name}
platform: ESP8266
board: esp01_1m
wifi:
ssid: myWiFiID
password: myWiFiPassword
logger:
level: VERBOSE
api:
ota:
safe_mode: True
web_server:
port: 80
###############################
# Sonoff Basic peripherals
# Relay on GPIO12
switch:
- platform: gpio
name: ${device_name}
pin:
number: 12
mode: output
id: ${device_name}_relay
# Physical Button on GPIO0
binary_sensor:
- platform: gpio
pin:
number: 0
inverted: False
mode: INPUT_PULLUP
name: ${device_name} button
internal: true
on_press:
- switch.toggle: ${device_name}_relay
# Get the WiFi details
text_sensor:
- platform: wifi_info
ip_address:
name: ${device_name} IP Address
id: ${device_name}_ip
ssid:
name: ${device_name} SSID
mac_address:
name: ${device_name} Mac Address
sensor:
- platform: wifi_signal
name: ${device_name} WiFi Signal Sensor
id: ${device_name}_WiFi_level
update_interval: 60s
#Blink the LED on GPIO13 if there's a problem
status_led:
pin:
number: 13