Skip to content

About

💡 Control a Bluetooth LED strip over Wi-Fi via a Python API, n8n & Android app. / Bluetooth şerit LED'i Python API, n8n ve Android uygulama ile Wi-Fi üzerinden kontrol eden bir IoT projesi.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

English | Türkçe


🇬🇧 Smart LED Controller 💡

This project transforms a standard Bluetooth LED strip into a Wi-Fi controllable smart light, accessible from anywhere in the world. It's an end-to-end IoT solution utilizing a Linux server, the n8n automation platform, and a modern Android application.

This repository demonstrates how to extend the capabilities of a local Bluetooth device using web technologies, turning it into a true smart-home component.

📱 Screenshots

Main Screen Settings Dark Theme

✨ Features

  • Remote Control: Control your LED strip even when you're outside of Bluetooth range, from anywhere with an internet connection.
  • Modern & Stateless UI: A sleek, minimalist, and user-friendly interface built with Jetpack Compose that makes no assumptions about the LED's current state.
  • Fully Customizable: Easily configure Webhook URLs and the name of the controlled LED from within the app's settings.
  • Custom Icon & Design: An aesthetic interface with a custom icon, built with modern design principles in mind.
  • Secure & Automated: A robust and flexible automation backend powered by n8n workflows.
  • Background Service: A reliable API server running continuously as a systemd service on Linux.

🛠️ Technical Stack & Architecture

This project consists of 3 main components:

1. Linux API Server

  • Language: Python 3
  • Libraries: Flask (Web server), Bleak (Asynchronous Bluetooth LE client)
  • Service Management: systemd for continuous background operation and auto-start on boot.
  • Role: To receive HTTP requests and translate them into Bluetooth commands for the LED strip.

2. Automation Layer (n8n)

  • Trigger: A Webhook node to securely receive requests from the internet.
  • Action: An HTTP Request node to send commands to the local Linux API server.
  • Role: To act as a secure bridge between the mobile application and the local server.

3. Android Application

  • Language: Kotlin
  • UI: Jetpack Compose (Declarative UI)
  • Architecture: MVVM (Model-View-ViewModel)
  • Asynchronous Operations: Kotlin Coroutines & Flow
  • Networking: Ktor Client
  • Data Persistence: Jetpack DataStore Preferences
  • Navigation: Navigation Compose
  • Role: To provide a polished user interface and trigger the n8n webhooks.

🚀 Setup

To run this project with your own hardware:

  1. Linux Server:

    • Copy the api_server.py script to a Linux machine (e.g., a Raspberry Pi).
    • Install the required Python libraries: pip install flask bleak.
    • Update the LED_MAC_ADRESI and YAZMA_UUID variables in the script to match your LED strip.
    • Set up and enable the led-api.service file with systemd to start the service.
  2. n8n Workflow:

    • Create a new n8n workflow.
    • Add two Webhook nodes, one for .../on and one for .../off. (Note: Ensure the HTTP Method for the webhooks is set to GET.)
    • Connect each webhook to an HTTP Request node that sends a request to the appropriate endpoint on your Linux API server (e.g., http://[SERVER_IP]:18331/ac or /kapat).
    • Take note of the production Webhook URLs.
  3. Android Application:

    • Open the project in Android Studio.
    • Build and install the app on your phone (preferably by signing it with your own keystore).
    • Navigate to the in-app settings screen, enter the Webhook URLs from n8n and a custom name for your LED, then save.

You're all set!

📜 License

This project is licensed under the MIT License. See the LICENSE file for details.


🇹🇷 Akıllı LED Kontrolcüsü 💡

Bu proje, standart bir Bluetooth şerit LED'i, bir Linux sunucusu, n8n otomasyon platformu ve modern bir Android uygulaması kullanarak dünyanın her yerinden kontrol edilebilir bir Wi-Fi destekli akıllı LED'e dönüştürür.

Bu repozitori, yerel bir Bluetooth cihazının yeteneklerini web teknolojileriyle nasıl genişletebileceğimizi gösteren baştan sona bir IoT (Nesnelerin İnterneti) çözümüdür.

📱 Ekran Görüntüleri

Ana Ekran Ayarlar Karanlık Tema

✨ Özellikler

  • Uzaktan Kontrol: Bluetooth menzili dışında olsanız bile LED'inizi internet olan her yerden kontrol edin.
  • Modern ve Durumsuz Arayüz: Jetpack Compose ile oluşturulmuş, LED'in durumu hakkında varsayımda bulunmayan, sadece eylem odaklı şık bir arayüz.
  • Tamamen Kişiselleştirilebilir: Webhook URL'lerini ve kontrol edilen LED'in ismini uygulama içinden kolayca ayarlayabilme.
  • Özel İkon ve Tasarım: Modern tasarım prensipleriyle oluşturulmuş, özel ikona sahip estetik bir arayüz.
  • Güvenli ve Otomatize: n8n workflow'ları ile güvenli ve esnek bir otomasyon altyapısı.
  • Arka Plan Servisi: Linux üzerinde systemd ile çalışan, sürekli aktif ve güvenilir bir API sunucusu.

🛠️ Teknik Yapı ve Mimarî

Bu proje 3 ana bileşenden oluşur:

1. Linux API Sunucusu

  • Dil: Python 3
  • Kütüphaneler: Flask (Web sunucusu), Bleak (Asynchron Bluetooth LE istemcisi)
  • Servis Yönetimi: systemd ile arka planda sürekli çalışma ve otomatik başlama.
  • Görevi: Gelen web isteklerini (HTTP) alıp Bluetooth komutlarına çevirerek LED'e göndermek.

2. Otomasyon Katmanı (n8n)

  • Tetikleyici: Webhook node'u ile internetten gelen güvenli istekleri yakalar.
  • Eylem: HTTP Request node'u ile yerel ağdaki Linux API sunucusuna komut gönderir.
  • Görevi: Mobil uygulama ile yerel sunucu arasında güvenli bir köprü oluşturmak.

3. Android Uygulaması

  • Dil: Kotlin
  • Arayüz: Jetpack Compose (Deklaratif UI)
  • Mimarî: MVVM (Model-View-ViewModel)
  • Asenkron İşlemler: Kotlin Coroutines & Flow
  • Ağ: Ktor Client
  • Veri Saklama: Jetpack DataStore Preferences
  • Navigasyon: Navigation Compose
  • Görevi: Kullanıcıya şık bir arayüz sunmak ve n8n webhook'larını tetiklemek.

🚀 Kurulum

Bu projeyi kendi donanımınızla çalıştırmak için:

  1. Linux Sunucusu:

    • api_server.py script'ini bir Linux makinesine (örn: Raspberry Pi) kopyalayın.
    • Gerekli Python kütüphanelerini kurun: pip install flask bleak.
    • Script içindeki LED_MAC_ADRESI ve YAZMA_UUID değişkenlerini kendi LED'inize göre güncelleyin.
    • led-api.service dosyasını systemd ile kurarak servisi başlatın.
  2. n8n Workflow:

    • Yeni bir n8n workflow'u oluşturun.
    • Biri .../ac diğeri .../kapat için olmak üzere iki adet Webhook node'u ekleyin. (Not: Webhook node'larının HTTP metodunun GET olduğundan emin olun.)
    • Her webhook'u, Linux API sunucunuzun ilgili endpoint'ine (http://[SUNUCU_IP]:18331/ac veya /kapat) istek gönderen bir HTTP Request node'una bağlayın.
    • Üretim (production) Webhook URL'lerini not alın.
  3. Android Uygulaması:

    • Projeyi Android Studio ile açın.
    • Projeyi kendi imzalama anahtarınızla imzalayıp derleyin ve telefonunuza kurun.
    • Uygulama içindeki ayarlar ekranına, n8n'den aldığınız webhook URL'lerini ve LED'inize vermek istediğiniz ismi girin ve kaydedin.

Artık kullanıma hazır!

📜 Lisans

Bu proje MIT Lisansı altında lisanslanmıştır. Detaylar için LICENSE dosyasına bakınız.

About

💡 Control a Bluetooth LED strip over Wi-Fi via a Python API, n8n & Android app. / Bluetooth şerit LED'i Python API, n8n ve Android uygulama ile Wi-Fi üzerinden kontrol eden bir IoT projesi.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages