Anyone using the Shelly 1 in combination with ESPHome?

I see that the Shelly 1 is supported but i’m wondering if all functionality stays the same.

The really nice thing about the shelly (1) is that you can switch both with a hardware switch and via Home Assistant.

Is this supported?

It took me a while to install the shelly in the ceiling so i’m not really looking forward to take it out and try :slight_smile:

1 Like

I suspect that

GPIO5 SW Input is the switch input. See https://esphome.io/devices/sonoff.html?highlight=shelly

I have a stationary switch and a light bulb connected.

This works for me:

esphome:
  name: relais_wohnzimmer_lampe
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: "f"
  password: !secret wifipassword

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: !secret password

ota:
  password: !secret password


output:
  - platform: gpio
    pin: GPIO4
    id: gpio_4

light:
  - platform: binary
    name: "Lampe Wohnzimmer"
    output: gpio_4
    id: lightid
    
binary_sensor:
  - platform: gpio
    pin:
      number: GPIO5
      #mode: INPUT_PULLUP
      #inverted: True
    name: "Schalter Wohnzimmer"
    on_state:
      - light.toggle: lightid
    internal: true
4 Likes

Thanks.

Does it still work in combination with a physical switch?

(But now that i read your post again, you probably mean that with a ‘stationary switch’)

If you have momentary switches, you have to change the following I think:

on_state:
      - light.toggle: lightid

-->
on_press:
      - light.toggle: lightid
2 Likes

Ik have a normal toggle switch. It doesn’t bounce back after pressing it.

Used with success here to replace some old “va et vient” as we say in french (basically when you have multiple, well more than one button) wired in parallel to control a single light circuit !). Relays were very noisy (old ones, 40 years old) and impossible to integrate with HA, and wanted also feature to switch off automatically after a while (if it’s forgotten on) !
Wired easily the Shelly 1 in replacement of the relay and used this sketch:. I made a toggle for the relay command as I have only push buttons in this system so I need relay to change state at each push !

esphome:
  name: escaliers
  platform: espressif8266
  board: esp_wroom_02
  board_flash_mode: dout

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_passwd
  fast_connect: True
  manual_ip:
    static_ip: !secret ip_escaliers
    gateway: 192.168.1.1
    subnet: 255.255.255.0

api:

logger:

ota:

binary_sensor:
  - platform: gpio
    pin: GPIO5
    id: 'bouton_escaliers'
    name: "Bouton Escaliers"
    on_press:
      then:
        - switch.toggle: relais

output:
  - platform: gpio
    pin: GPIO4
    id: 'generic_out'

switch:
  - platform: output
    name: "Escaliers"
    output: 'generic_out'
    id: 'relais'
1 Like

With tasmota flashed Sonoff I flashed first sonoff_minimal, and then uploaded ESPhome.

How did you flash the shelly @TimoF ? Also first flash tasmota minimal and then ESPhome, or directly ESPhome?

I flashed directly esphome with the serial programer.

I see, have shelly in enclosure with 220V, kind of difficult to reach and risky. Would need to dismount them all.

Wonder if anyone upgraded OTA, like we do with the Sonoff’s

I did not do this with my shelly but with 2 Gosund wall plugs. They had Tasmota installed. I compiled esphome for them and flashed it OTA in the Tasmota Webinterface of the wall plug.

Worked flawlessly so far.

Hi, I am trying now to flash this particular shelly with ESPhome, I opened my switch, and can access it.

I have on one shelly the same situation (I think) as you but I have an ON/OFF switch (on position for ON and one position for OFF): the SW is connected to the On/OFF phisical switch. and the 1-0 to the same light connected to the mechanical switch.

Basically now I can turn on-off the light from the mechanical switch or from Home assiatant: of course the switch and HA are not sincrnonized (the position of the switch can change depending if HA was used, but I don’t care much about it.

And of course I wish to do the same with ESPHome

How should I change the code?

Thanks for this ! :slight_smile: Shelly 1 1/15 installed… its going to be a long evening

Hello.
I have received my Shelly 1 v3 and Shelly 2.5 today.
Im thinking about flashing my shelly 1 with EspHome.
My wall switch doesnt bounce back so im wondering how this is going to affect syncing the switch state on my hassio. It would be disturbing hassio to state the switch off each time i switch the lights on from the physical switch.

Is there a work-around?

Just use my code. I have stationary switches.

I have some Shelly at home, all with the original firmware that works well and did not gave me any issues in months. I control them via MQTT in Hassio, so I can use the Lovelace interface tu turn them on or off, Alexa (via Hass.io CLOUD), Google Home (via CLOUD), and of course the phisical switches.
As told, I decided to not reflash them with Tasmota or ESPhome since they worked really well (old rule: NEVER change something that works well !!)

I’ll do that… thanx
What about the mode: input_pullup ?
Isnt that for stationary switches?

2 Likes

Could someone elaborate, why in my case it worked without the PULLUP?
Anyone knows how the shelly 1’s circuit is made, so what is the binary_sensor actually physically reading.

As it works, I assume a clear HIGH or LOW arrives at PIN GPIO05.

i suspect that the binary sensor inspects the button’s behaviour (if it is pressed, how it is pressed, how long etc) so that it fires the corresponding action to the relay in the GPIO.
I can’t say that I understood the meaning of the pullup though in practical terms