Shelly 1 binary_sensor does no change on wall switch change

I have a shelly 1 set up behind my light switch, but the binary_sensor doesn’t change whatever I do. I can measure the 230V or 0V on the shelly screw, dependent of the wall switch, so it must be set up correctly. Can anybody help?

The binary_sensor is always on. If I invert the GPIO pin, it simply is always of. Pullup doesn’t change anything either.

Is this a Shelly 1 flashed with ESPHome? If so, please paste your config file, properly formatted with the </> button.

My relevant section:

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO5
    name: "Utility Room Light Switch"

…and that works fine:

image

Yes it is. My here is my config file:

substitutions:
  device_name: shelly1-bad-deckenlicht
  device_description: "Shelly1 Deckenlicht"
  ort: Bad


esphome:
  name: ${device_name}

esp8266:
  board: esp01_1m

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: true


# Enable logging
logger:


# Enable Home Assistant API
api:
  encryption: 
    key: !secret api_encryption_key


ota:
  password: !secret ha_api_password


# Zeit von Home Assistant
time:
  - platform: homeassistant
    id: homeassistant_time


# Buttons
button:
  # Restart ESP32 Butten
  - <<: !include common/button/restart_button.yaml


# Text-Sensor
text_sensor:
# IP-Adresse als Sensor
  - <<: !include common/text-sensor/ip-adresse.yaml


# Sensoren
sensor:
  # WLAN Signalstärke
  - <<: !include common/sensor/wifi_strength.yaml
  
  # Betriebszeit
  - <<: !include common/sensor/uptime.yaml


# Device Specific Config
output:
  - platform: gpio
    pin: GPIO4
    id: shelly_1_relay


light:
  - platform: binary
    name: "${ort} Deckenlicht ${device_description}"
    output: shelly_1_relay
    id: lightid


binary_sensor:
  - platform: gpio
    pin: 
      number: GPIO5
    name: "${ort} Schalter ${device_description}"
    id: schalter
#    internal: true
    filters:
      - delayed_on_off: 50ms
    on_state:
        then:
          - if:
              condition:
                light.is_on: lightid
              then:
                - light.turn_on: lightid
              else:
                - light.turn_off: lightid

Hm, mine looks exactly alike. So it probably is defect, although it has never been used before, just lay around for a year. :thinking:

No, tried a different new shelly. Doesn’t work either. Is it a problem with the newest firmware?

If you’ve flashed ESPHome, it’s not running Shelly firmware.

How have you wired it? Can you post the startup logs from ESPHome?

It is the shelly. I flashed the original shelly firmware again and it isn’t working either. So I have two malfunctioning shellys. Thanks for your help.

@Troon Maybe try this?

  - platform: gpio
    pin:
      number: GPIO5
    name: ${node_name} Input
    id: button
    # small delay to prevent debouncing
    filters:
      - delayed_on_off: 50ms
    # config for state change of input button
    # When  wifi/api connected, use homeassistant.service
    # otherwise, use switch.turn_on/off shelly_relay
    on_state:
        then:
          - if:
              condition:
               and:
                 - wifi.connected:
                 - api.connected:
                 - switch.is_off: shelly_relay
              # turn_on light if wifi and api are connected and relay is off
              then:
                - homeassistant.service:
                    service: switch.turn_on
                    data:
                      entity_id: switch.shelly1_masterbedroom
              # else, turn off
              else:
                - if:
                    condition:
                      and:
                        - wifi.connected:
                        - api.connected:
                        - switch.is_on: shelly_relay
                    # turn_off switch if wifi and api are connected and relay is on
                    then:
                      - homeassistant.service:
                          service: switch.turn_off
                          data:
                            entity_id: switch.shelly1_masterbedroom
                    else:
                      if:
                        condition:
                          - switch.is_off: shelly_relay
                        then:
                          - switch.turn_on: shelly_relay
                        else:
                          - switch.turn_off: shelly_relay

# Shelly 1 detached switch config with fallback in case of wifi or api fail
switch:
  - platform: gpio
    name: ${node_name}
    pin: GPIO4
    id: shelly_relay
    # after reboot, keep the relay off. this prevents light turning on after a power outage
    restore_mode: ALWAYS_OFF

And if you enable the web interface, you can also see if the input sensor is working :stuck_out_tongue:

# Enable Web server (optional).
web_server:
  port: 80

sorry, @dflvunoooooo i ment

Mine is working fine, thanks. :wink:

1 Like