Thank you for XOD!
I ask you to make two program modules:
i2c PCF 8574
all use it as an I \ O port extender.
as examle )))
1st (first) module
so that the 8-bit input is sent to the address i2c PCF 8574
2nd (second) module to return 8 bits when reading from i2c PCF 8574
8 out (dots)
note for PCF 8574 inverted HI \ LOW sines and for the relay it is better to take this into account immediately