Cannot publish state of HA switch thru lcd_pcf8574

I plan to publish state of the switch from HA to the LCD Display. But the display always shows off even i turn on the pump.

Pls help

The config looks like this:

binary_sensor:
  - platform: homeassistant
    id: water_pump
    entity_id: switch.water_pump

i2c:
  sda: D2
  scl: D1

display:
  - platform: lcd_pcf8574
    dimensions: 16x2
    address: 0x27
    update_interval: 1s
    id: lcd
    lambda: |-
      it.printf("My State: %s", id(water_pump).state ? "on" : "off");

Can you show us your Log?

[13:27:42][I][app:106]: ESPHome version 2021.8.2 compiled on Sep  7 2021, 13:26:47
[13:27:42][C][wifi:499]: WiFi:
[13:27:42][C][wifi:359]:   SSID: [redacted]
[13:27:42][C][wifi:360]:   IP Address: 192.168.1.96
[13:27:42][C][wifi:362]:   BSSID: [redacted]
[13:27:42][C][wifi:363]:   Hostname: 'irrigation-alfa-control'
[13:27:42][C][wifi:367]:   Signal strength: -52 dB ▂▄▆█
[13:27:42][C][wifi:371]:   Channel: 1
[13:27:42][C][wifi:372]:   Subnet: 255.255.255.0
[13:27:42][C][wifi:373]:   Gateway: 192.168.1.1
[13:27:42][C][wifi:374]:   DNS1: (IP unset)
[13:27:42][C][wifi:375]:   DNS2: (IP unset)
[13:27:42][C][i2c:028]: I2C Bus:
[13:27:42][C][i2c:029]:   SDA Pin: GPIO4
[13:27:42][C][i2c:030]:   SCL Pin: GPIO5
[13:27:42][C][i2c:031]:   Frequency: 50000 Hz
[13:27:42][I][i2c:033]: Scanning i2c bus for active devices...
[13:27:42][I][i2c:040]: Found i2c device at address 0x27
[13:27:42][C][logger:189]: Logger:
[13:27:42][C][logger:190]:   Level: DEBUG
[13:27:42][C][logger:191]:   Log Baud Rate: 115200
[13:27:42][C][logger:192]:   Hardware UART: UART0
[13:27:42][C][homeassistant.time:010]: Home Assistant Time:
[13:27:42][C][homeassistant.time:011]:   Timezone: 'TZ-8'
[13:27:42][C][lcd_pcf8574:023]: PCF8574 LCD Display:
[13:27:42][C][lcd_pcf8574:024]:   Columns: 16, Rows: 2
[13:27:42][C][lcd_pcf8574:025]:   Address: 0x27
[13:27:42][C][lcd_pcf8574:026]:   Update Interval: 1.0s
[13:27:42][C][captive_portal:148]: Captive Portal:
[13:27:42][C][web_server:152]: Web Server:
[13:27:42][C][web_server:153]:   Address: 192.168.1.96:80
[13:27:42][C][ota:029]: Over-The-Air Updates:
[13:27:42][C][ota:030]:   Address: 192.168.1.96:8266
[13:27:42][C][ota:032]:   Using Password.
[13:27:42][C][api:095]: API Server:
[13:27:42][C][api:096]:   Address: 192.168.1.96:6053
[13:27:42][C][homeassistant.binary_sensor:038]: Homeassistant Binary Sensor 'water_pump'
[13:27:42][C][homeassistant.binary_sensor:039]:   Entity ID: 'switch.water_pump'

also i have defined in HA the switch.

What do you see in the esphome log when switch.water_pump goes to on?

nothing got updated in the esphome log when switch.water_pump goes to on.

The last entry

[homeassistant.binary_sensor:039]: Entity ID: 'switch.water_pump

Well looks like i solve this by manually adding the ESPHOME node manually instead of auto discovery and added by HA.

That solved the prob. now everything works!

Thanks