Planning a DIY Smart Home Setup With MQTT

Hey everyone,

I’m currently planning out a DIY smart home project and I’d love to get some advice before I actually start building anything. This is my first time doing a full IoT setup from scratch, so I want to make sure I’m going in the right direction.

My idea is to take several IoT devices (mainly sensors, switches, plugs, etc.) and flash them, so I can run custom firmware and get rid of the cloud-based ecosystem. I want all devices to communicate locally with my Raspberry Pi 5, without using the Tuya cloud or any external services.

Since I want fast and reliable communication between devices, I was thinking about using MQTT with Mosquitto as the central message broker. The plan is:

  • Raspberry Pi 5 running Mosquitto
  • My custom Python backend handling API calls and device logic
  • IoT devices flashed, publishing/receiving MQTT messages
  • Light switches, sensors, etc. reacting as instantly as possible

I’m aiming for very low latency. For example, if I toggle a light switch through my backend, the response should feel immediate.

I haven’t started building this yet, I’m still collecting information and figuring out the best way to structure everything. Since this is my first time doing this, I’d really appreciate suggestions, recommendations, or potential pitfalls I should watch out for.

Some things I’m especially curious about:

  • Is Mosquitto a good choice for this kind of setup?
  • Any best practices for structuring topics and payloads?
  • Tips for making communication as fast and stable as possible
  • Good ways to secure the system while keeping it simple

Thanks a lot for any insight you can share! I want to set this up properly from the beginning.