Skip to content

Muawiya-contact/Smart-Home-Simulator-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🏠 Smart Home Simulator 🔦 | Powered by Python OOP + Flask + IoT

Welcome to the Smart Home Simulator — a creative and fully functional IoT-based project where your smartphone acts as a Smart Flashlight (Light Device), and your laptop acts as the Controller! Built entirely using Python, Flask, and Object-Oriented Programming (OOP) concepts. No extra hardware required! 💻📱


Watch Demo

💡 Project Highlights

  • ✅ Fully Object-Oriented Python structure
  • ✅ Real-time client-server communication via HTTP
  • ✅ Turns ON/OFF simulated Smart Flashlight remotely
  • ✅ Uses only a laptop & phone to simulate real-world IoT
  • ✅ Manual IP input = 🔌 easily connect to any smart device on same network
  • ✅ Bonus: 🔁 Blink effect included!
  • ✅ Future-ready: Easily expandable to other smart home devices

⚙️ Technologies Used

  • 🐍 Python 3
  • 🌐 Flask (REST API)
  • 📡 Wi-Fi LAN (Local Network Communication)
  • 🧠 Object-Oriented Programming (OOP)
  • 📱 Termux (on Android for server)

🧱 Project Structure

smart-home-simulator/
│
├── controller.py        # 💻 Laptop - sends commands to the smart light
├── smart_light_server.py  # 📱 Phone - handles light states via Flask
├── README.md            # 📘 You're here!

🚀 How It Works

Think of this like a real-world smart home controller, but using basic devices and Python logic.

🔁 Communication Flow:

Run smart_light_server.py on your friend’s phone (Android + Termux + Flask)

Run controller.py on your laptop

Enter the phone’s IP address in your controller

Control light via options:

1️⃣ Flash ON

2️⃣ Flash OFF

3️⃣ Blink

Flash is simulated as a virtual smart light using OOP

🔧 Setup Instructions

📱 On Phone (Server):

  1. Install Termux from F-Droid

  2. Run these commands in Termux:

pkg update
pkg install python
pip install flask termux-api
termux-setup-storage
  1. Run the smart light server:
python smart_light_server.py

💻 On Laptop (Client):

  1. Install Flask & Requests:
pip install flask requests
  1. Run the controller:
python controller.py
  1. Enter IP of the phone when prompted

🎮 Sample Controller Menu

Select the action:
1. Flash ON
2. Flash OFF
3. Blink
4. Exit

👨‍💻 Code Sample (Flashlight Class)

class SmartFlashlight:
    def __init__(self):
        self.state = "off"

    def turn_on(self):
        self.state = "on"
        return "Smart Flashlight is ON"

    def turn_off(self):
        self.state = "off"
        return "Smart Flashlight is OFF"

    def get_state(self):
        return self.state

🛠️ Future Improvements

  • 📡 Auto IP detection & device scanning

  • 📱 Mobile-friendly web GUI

  • 📲 Integrate with real flashlight or LED (via GPIO/Arduino)

  • 📈 Analytics & dashboard for smart home actions

  • 🌍 Control multiple devices (Fan, AC, etc.)

🧠 What We Learned

  • Real-world implementation of OOP in Python

  • Building REST APIs with Flask

  • Local network-based IoT simulation

  • Client-server architecture

  • Collaboration and modular design in code

🙋 Author

👨‍💻 Muawiya — @Coding_Moves

🌟 Show Your Support

If you found this project inspiring:

  • ⭐ Star this repo

  • 📢 Share with friends

  • 📽️ Watch the video demo on YouTube

  • 🔗 Post it on LinkedIn with us!