The fastest way I've found is https://esphome.io/. You can literally flash an esp32/esp8266 and have a device up and running in minutes.
You of course need some central server to collect and act upon the data. I use HomeAsssistant, but I am sure other options work as well.