Why do I not see a switch state change?

I am learning ESP Home using a Wemos D1 Mini. I have a button between D1 (GPIO5) and ground. Here is the YAML file:

esphome:
  name: wemos_test
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: "Kaywinnet"
  password: "806194xxxx"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Wemos Test Fallback Hotspot"
    password: "Oi136ZHGIzON"

captive_portal:

# Enable logging
logger:
  level: DEBUG

# Enable Home Assistant API
api:

ota:
  safe_mode: True
  
# Switch on D1, GPIO5  
switch:
  - platform: gpio
    name: "Wemos_Switch"
    pin:
      number: D1
      inverted: False
      mode: INPUT_PULLUP

The log shows the pin D1 (GPIO5) as an input:

INFO Reading configuration /config/esphome/wemos_test.yaml...
INFO Starting log output from wemos_test.local using esphome API
INFO Connecting to wemos_test.local:6053 (192.168.1.59)
INFO Successfully connected to wemos_test.local
[16:05:11][I][app:105]: ESPHome version 1.16.2 compiled on Mar 11 2021, 15:55:25
[16:05:11][C][wifi:443]: WiFi:
[16:05:11][C][wifi:303]:   SSID: [redacted]
[16:05:11][C][wifi:304]:   IP Address: 192.168.1.59
[16:05:11][C][wifi:306]:   BSSID: [redacted]
[16:05:11][C][wifi:307]:   Hostname: 'wemos_test'
[16:05:11][C][wifi:311]:   Signal strength: -65 dB ▂▄▆█
[16:05:11][C][wifi:315]:   Channel: 6
[16:05:11][C][wifi:316]:   Subnet: 255.255.255.0
[16:05:11][C][wifi:317]:   Gateway: 192.168.1.1
[16:05:11][C][wifi:318]:   DNS1: 192.168.1.1
[16:05:11][C][wifi:319]:   DNS2: (IP unset)
[16:05:11][C][switch.gpio:042]: GPIO Switch 'Wemos_Switch'
[16:05:11][C][switch.gpio:043]:   Pin: GPIO5 (Mode: INPUT_PULLUP)
[16:05:11][C][switch.gpio:059]:   Restore Mode: Restore (Defaults to OFF)
[16:05:11][C][logger:185]: Logger:
[16:05:11][C][logger:186]:   Level: DEBUG
[16:05:11][C][logger:187]:   Log Baud Rate: 115200
[16:05:11][C][logger:188]:   Hardware UART: UART0
[16:05:11][C][captive_portal:169]: Captive Portal:
[16:05:11][C][ota:029]: Over-The-Air Updates:
[16:05:11][C][ota:030]:   Address: wemos_test.local:8266
[16:05:11][C][api:095]: API Server:
[16:05:11][C][api:096]:   Address: wemos_test.local:6053

When I ground D1, I see no state change. What did I do wrong?

No need to open another thread. Stay in the original one. :slight_smile:

New ESPHome user- can't see a switch in the entity list

I thought of keeping the original thread, but that question is answered.

It should be a binary sensor if you are detecting something like grounding the pin.

A switch is to operate something external, like a relay attached to a gpio.

Thanks. I really appreciate your feedback. Patrick has been helping on the original thread. He didn’t say it quite as succinct as you, but he gave me an example to go from.

I saw the other thread was still going. If I was a moderator I would combine them. The switch concept is a little confusing, you would connect what we think of as a light switch to the esp as a sensor. But we still think of it as a switch, it takes some head exercise :slight_smile:

“… it takes some head exercise”
That’s the best description of YAML coding yet. :laughing:

1 Like

I’m having deja vu