I use tasmota firmware on many esp826x devices. Its very handy for interfacing with all sorts of i/o and sensors and hosts its own gui web interface. You just configure whats connected to what gpio pin via the web gui and it will publish all its metrics via mqtt (a broker service you can host on a pi..) and will respond to all sorts of mqtt commends too.
Usually used for reprogramming oem smart devices for a nodemcu or wemos d1 dev board just select "Generic 18" as the module type in the Config/module page for access to all exposed gpio.
On my Pi i also host node red which is a drag n drop interface for responding to events such as mqtt publications from tasmota devices and can be used to create some very powerful flows quite simply once you get the hang of thinking about data flows rather than execution flows..