Look at running OpenWRT on a cheapo consumer router (I use a TP-Link router, but nowadays TP-Link is being stupid and shutting down the ability to load custom firmware so avoid them).  You can install all kinds of packages like mosquitto MQTT server.