I wanted to understand are you using 2 PCF8574? one for input and another for output?
also in the code which entries are to add the relays and assign a specific button?
the code if inserted on wemos d1 works?
sorry for the many questions because I have to put 8 relays controlled with 8 buttons and interface with domoticz