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