Integrate Shelly 1 to Homeassistant
30
Mar 2022
esphome:
name: garage-deckenleuchte
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Garage-Deckenleuchte"
password: !secret ap_password
captive_portal:
# Text sensors with general information.
text_sensor:
- platform: wifi_info
ip_address:
name: garage-deckenleuchte IP
# Sensors with general information.
sensor:
# Uptime sensor.
- platform: uptime
name: garage-deckenleuchte Uptime
# WiFi Signal sensor.
- platform: wifi_signal
name: garage-deckenleuchte WiFi Signal
update_interval: 60s
# Shelly 1 detached switch config with fallback in case of wifi or api fail
switch:
- platform: gpio
name: garage-deckenleuchte
pin: GPIO4
id: shelly_relay
# after reboot, keep the relay off. this prevents light turning on after a power outage
restore_mode: ALWAYS_OFF
binary_sensor:
- platform: gpio
name: garage-deckenleuchte Input
pin:
number: GPIO5
filters:
- delayed_on_off: 50ms
on_state:
then:
- switch.toggle: shelly_relay
- USB Adapter mit dem Shelly 1 verbinden - siehe Bilder für die Pin-Belegung
- Beim einstecken den GPIO mit GND verbinden - für ein paar Sekunden
- mit esptool flashen
esptool.py --port /dev/ttyUSB0 write_flash -fs 1MB -fm dout 0x0 garage-deckenleuchte.bin
esptool.py v3.3
Serial port /dev/ttyUSB0
Connecting....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting...
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 48:55:19:03:17:34
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00068fff...
Compressed 426224 bytes to 294633...
Wrote 426224 bytes (294633 compressed) at 0x00000000 in 27.1 seconds (effective 126.0 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
- Neues Gerät sollte automatisch von HomeAssistant erkannt werden "Discover new Devices"
- Hinter dem Schalter sollte es dann wie folgt verkabelt werden: