ESPHome: Shelly Plus i4 supported? Recommended hardware for 4+ binary inputs, say 4+ buttons? ... General clarity on ESP32 device support

Q1 Is Shelly Plus i4 supported?
From Does ESPHome support [this device/feature]? states:

If it’s not in the docs, it’s probably not supported.

Shelly Plus i4 isn’t listed.

On the other hand, esphome states:

Technically, all ESP8266/ESP32 devices are supported by ESPHome.

and the thread Shelly PLUS i4 Wall Switch Example Automation suggests the i4 is supported:

Q2 If i4 is not supported by ESPHome, what hardware running off 240VAC will provide 4+ binary inputs?

Q3 Are all ESP32 devices supported by ESPHome?
Assuming one can flash the firmware over UART, are all ESP32 devices supported?
Are all Shelly ESP devices supported??

Thanks : )

Everything based on esp8266 or esp32 is technically supported. The questionable are modules with extra chip inside, like sensor, measurement chip… THAT’S when you have to ask yourself if it is supported, since not all special chips are supported.
In your case shelly i4 only contains 4 inputs and nothing else. The only question is to find gpio’s of where relays are connected to, but even this is not the problem…

1 Like

Please see this example, as long as you have a monetary switch or the shelly wall buttons you can flash esphome on the i4 using the serial header pins, make sure your i4 is “OUT” of AC wiring as the GPIO pins are connected to the AC side and will fry any USB TTL adaptors while attempting to flash in circuit: -

pin info: -

in terms of the required template please find example below yaml (untested): -

  device_ssid: "Shelly Plus i4"
  device_name: shellyplusi4
  device_description: "Shelly Plus i4 Switch Module"
  friendly_name: "Shelly Plus i4"
  main_device_id: "shellyplusi4id" # Put the name that you want to see in Home Assistant.
  project_name: "shelly.plusi4-esp32-solo-esp-idf"
  project_version: "1.0"

esphome:
  name: ${device_name}
  comment: ${device_description}
  platformio_options:
    board_build.f_cpu: 160000000L
  project:
    name: "${project_name}"
    version: "${project_version}"

esp32:
  board: esp32doit-devkit-v1
  framework:
    type: esp-idf
    sdkconfig_options:
      CONFIG_FREERTOS_UNICORE: y
      CONFIG_ESP32_DEFAULT_CPU_FREQ_160: y
      CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ: "160"

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: !secret api_password
  encryption:
    key: !secret masterbedroombutton_noise_key

ota:
  safe_mode: true
  password: !secret ota_password

wifi:
    ssid: !secret wifi_all_ssid
    password: !secret wifi_all_password
    power_save_mode: none
    # Enable fallback hotspot (captive portal) in case wifi connection fails
    ap:
      ssid: ${device_ssid} Fallback Hotspot
      password: !secret ap_password
  
# Sensors with general information.
sensor:
  - platform: uptime
    name: "${friendly_name} Uptime"
    id: uptime_sensor
  # WiFi Signal sensor.
  - platform: wifi_signal
    name: ${friendly_name} Signal strength
    update_interval: 60s
    internal: true
    
text_sensor:
  # Expose WiFi information as sensors.
  - platform: wifi_info
    ip_address:
      name: ${friendly_name} IP
    ssid:
      name: ${friendly_name} SSID
    bssid:
      name: ${friendly_name} BSSID
    
switch:
    # this provides for a possibility to restart from the web console or Home automation should we ever need it
  - platform: restart
    name: "${friendly_name} Restart"
  - platform: safe_mode
    name: "${friendly_name} Restart (Safe Mode)"

binary_sensor:
  - platform: gpio
    name: "${device_name} Button 1"
    pin:
      number: GPIO12
      mode:
        input: true
    on_multi_click:
      # double click
      - timing:
          - ON for at most 1s
          - OFF for at most 1s
          - ON for at most 1s
          - OFF for at least 0.2s
        then:
          # send double click event
          - homeassistant.event:
              event: esphome.button_pressed
              data:
                title: button 1 double click
        # long click
      - timing:
          - ON for at least 1.5s
        then:
          - homeassistant.event:
              event: esphome.button_pressed
              data:
                title: button 1 long click
        # single click
      - timing:
          - ON for at most 1s
          - OFF for at least 0.5s
        then:
          - homeassistant.event:
              event: esphome.button_pressed
              data:
                title: button 1 short click
    # internal: true
    id: button1
    filters:
      - delayed_on_off: 50ms
  - platform: gpio
    name: "${device_name} Button 2"
    pin:
      number: GPIO14
      mode:
        input: true
    on_multi_click:
      # double click
      - timing:
          - ON for at most 1s
          - OFF for at most 1s
          - ON for at most 1s
          - OFF for at least 0.2s
        then:
          # send double click event
          - homeassistant.event:
              event: esphome.button_pressed
              data:
                title: button 2 double click
        # long click
      - timing:
          - ON for at least 1.5s
        then:
          - homeassistant.event:
              event: esphome.button_pressed
              data:
                title: button 2 long click
        # single click
      - timing:
          - ON for at most 1s
          - OFF for at least 0.5s
        then:
          - homeassistant.event:
              event: esphome.button_pressed
              data:
                title: button 2 short click
    # internal: true
    id: button2
    filters:
      - delayed_on_off: 50ms
  - platform: gpio
    name: "${device_name} Button 3"
    pin:
      number: GPIO27
      mode:
        input: true
    on_multi_click:
      # double click
      - timing:
          - ON for at most 1s
          - OFF for at most 1s
          - ON for at most 1s
          - OFF for at least 0.2s
        then:
          # send double click event
          - homeassistant.event:
              event: esphome.button_pressed
              data:
                title: button 3 double click
        # long click
      - timing:
          - ON for at least 1.5s
        then:
          - homeassistant.event:
              event: esphome.button_pressed
              data:
                title: button 2 long click
        # single click
      - timing:
          - ON for at most 1s
          - OFF for at least 0.5s
        then:
          - homeassistant.event:
              event: esphome.button_pressed
              data:
                title: button 3 short click
    # internal: true
    id: button3
    filters:
      - delayed_on_off: 50ms
  - platform: gpio
    name: "${device_name} Button 4"
    pin:
      number: GPIO26
      mode:
        input: true
    on_multi_click:
      # double click
      - timing:
          - ON for at most 1s
          - OFF for at most 1s
          - ON for at most 1s
          - OFF for at least 0.2s
        then:
          # send double click event
          - homeassistant.event:
              event: esphome.button_pressed
              data:
                title: button 4 double click
        # long click
      - timing:
          - ON for at least 1.5s
        then:
          - homeassistant.event:
              event: esphome.button_pressed
              data:
                title: button 4 long click
        # single click
      - timing:
          - ON for at most 1s
          - OFF for at least 0.5s
        then:
          - homeassistant.event:
              event: esphome.button_pressed
              data:
                title: button 4 short click
    # internal: true
    id: button4
    filters:
      - delayed_on_off: 50ms

if you have the right adaptors for flashing all should work nicely: -

Regards,
Ash

EDIT - Updated post with correct working YAML

1 Like

Thanks @Protoncek & @ashp : )
Excited about this amazing open source home automation community and ecosystem! :heart:

1 Like

@chendy your most welcome!!!

As other esp32 shelly modules are supported I cannot see why we cannot put esphome on the shelly i4, at least it’s on blakadders site, the issue is no one has posted online a working example apart from @adorobis

1 Like

Thanks for sharing my example. Just keep in mind I have not flashed i4 with esphome. I use it as is with standard HA integration. I have esphome on another module to control the gate input and get additional reed switch for gate close sensor.

So if I understand correctly your other esp module tracks status (open/close) and is a sensor/reed switch?

Correct. But as my gate is controlled with one input only (step-by-step) I’ve added the Shelly i4 to get information about the motors: if and in which direction they are moving, so in HA I can better control the gate - this is done with a template cover in HA taking inputs from i4, esphome module and controling the relay on esphome accordingly.

Thanks for clarifying, thought someone might have ditched shelly firmware and gone for esphome, with the right tools it’s not hard to do

I’ve updated my post with correct working YAML

time to create automations just like my shelly click example: -

Sorry for double posting/interlinking. But any tip from here?