Esphome, NodeMCU and I2C port expander module

I am wondering if anyone uses a pcf8574 or pcf8575 port expander together with esphome and an 8266 ?
I suspect that I am missing some basic understanding somewhere but I do not now where. The port expander pins are all available to me as switches under esphome but the physical output pins do not change states when I flip the switch under my lovelace interface.
The physical setup is a Wemos 8266 board hooked up via I2C (pins D1 and D2 plus ground and power) to the expander module shown here: PCF8575 IO Expander Module I2C To 16IO Integrated Circuits New 2018 | eBay
There is nothing set up in the configuration.yaml file to enable everything and under ESPHome I have the following code on the NodeMCU device:

==========================================================================================================================


esphome:
  name: wemos_esp8266_2
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: !secret wifi_iot_ssid
  password: !secret wifi_iot_password
  fast_connect: true # required when using a hidden network
  
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Wemos Esp8266 2 Fallback Hotspot"
    password: "ZU8JEmHrsxIL"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:


i2c:
  sda: 04
  scl: 05
  scan: True
#  id: bus_a



pcf8574:
  - id: 'pcf8575_1'
    address: 0x20
    pcf8575: True

# Individual outputs
switch:
  - platform: gpio
    name: "PCF8575 Pin #0"
    pin:
      pcf8574: pcf8575_1
      # Use pin number 0
      number: 0
      # One of INPUT or OUTPUT
      mode: OUTPUT
      inverted: False

  - platform: gpio
    name: "PCF8575 Pin #1"
    pin:
      pcf8574: pcf8575_1
      # Use pin number 1
      number: 1
      # One of INPUT or OUTPUT
      mode: OUTPUT
      inverted: False

 
status_led:
  pin:
    number: GPIO13
    inverted: yes

=====================================================================================================================
...

 When the nodeMCU powers up it connects, goes out and finds an I2C device on 0x20 and all outputs are set to zero. Unfortunately they stay at zero. I set them up as switches under lovelace and can flip them but nothing happens on the port expander output pins.

I was going to try to put the I2C definition into configuration.yam but as soon as I remove it out of the esphome file it complains.
I am wondering if I am using the device (pcf8574) correctly in the esphome file above as the actual device is the pcf8575 (16 port) version?

So close yet so far away ......

PCF8574 has open drain outputs, not classic ones like MCP23017. That means, that you won’t see/measure pin changing it’s value without external circuitry. You must at least connect a pull-up resistor (from pin to +Vcc) and then measure voltage: once time it will be +Vcc, when active it will drop to zero (it will sink current from pin into ground).
So, say, resistor from +Vcc to LED, from LED to pin. That way LED will lit when active.

Thank you for your input. I looked at the TI application notes and they only show pullup resistors if the pins are configured as inputs. I will try my test circuit with some pullups tomorrow and see how that works out.

Well, actually, pullups are not required for proper working. For example, a relay (up to 25mA, of course, to prevent pin overload) can be connected directly between +Vcc and output pin and it will work. Pull-up is only required if you plan to connect small NPN for more powerfull relay. (well, in that case a resistor in series between output and Base of NPN is also required).
But in this case such relay will work inverted, of course…

the nature of open-drain (or open-collector) output is such that when activated it only connects output pin to GND. When it’s NOT active it’s kinda high-resistance (“in the air”). That’s why you can’t measure it with multimeter. SEE THIS. PCF does have a small pull-up resistor inside, but it’s very small, so it can happen that your circuit won’t work without external one.

I’ve had PCF in one of my projects, but i replaced it with MCP exactly because of that: this reverse working caused startup click when power-on. Since i use it for my automatic gates that behaviour caused gate to open…

Pavel, thanks again for pointing out that the outputs on the IO expander were sinking outputs. While I had looked at the TI data sheet, this was not clear to me.
Your solution worked just fine and everything is working as it should.
In the ‘as shipped’ configuration, the IO expander is set up for 3.3V operation and that works just fine with a 5V relay board. I still have to decide if I want to operate that way or if I want to set up the IO expander for 5V outputs to drive the relay board that way.