Yes I know ESPHomeYaml exists, here is my naive attempt at making relays talk to HA!
Home Assistant Switch for 8 Relays: PCF8574 can be used to extend the GPIO of ESP8266/32 and here we use 8 ports of PCF8574 to control 8 Relay module
Code/Parts/Schematic: https://github.com/debsahu/PCF8574_8Relay
Video: https://youtu.be/6CzkeJei5i0