Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Tuesday, June 3, 2025

WiZ Akıllı Ampulleri PC Üzerinden Kontrol Etmek (Python GUI Arayüzlü Uygulama)

WiZ markalı akıllı ampulleri (Signify/Philips) cep telefonu uygulaması yerine bilgisayardan kontrol etmek için Python tabanlı GUI uygulaması. Bu uygulama sayesinde aynı ağa bağlı WiZ ampulleri PC'den açmak ve kapatmak mümkün.



✨ Özellikler:

  • 3 farklı WiZ ampul için "Aç" ve "Kapat" butonları
  • Tüm ampulleri tek tuşta açıp kapama; "Hepsini Aç" / "Hepsini Kapat"
  • Tkinter tabanlı basit ve hızlı arayüz
  • Kod Python 3 ve pywizlight kütüphanesiyle yazıldı

📅 Gerekenler:

  • Python 3.8+
  • pywizlight kütüphanesi:

pip install pywizlight

Bilgisayar ile ampuller aynı ağda olmalı

⚙️ Kod:


import tkinter as tk
from tkinter import messagebox
import asyncio
from pywizlight import wizlight, PilotBuilder

# Ampul IP listesi, kendi senaryonuza göre düzenleyin
bulb_ips = ["192.168.1.104", "192.168.1.105", "192.168.1.106"]

class WizController:
    def __init__(self):
        self.loop = asyncio.new_event_loop()

    def turn_on(self, ip):
        self.loop.run_until_complete(self._turn_on(ip))

    def turn_off(self, ip):
        self.loop.run_until_complete(self._turn_off(ip))

    async def _turn_on(self, ip):
        try:
            bulb = wizlight(ip)
            await bulb.turn_on(PilotBuilder())
        except Exception as e:
            messagebox.showerror("Bağlantı Hatası", f"{ip} için hata: {e}")

    async def _turn_off(self, ip):
        try:
            bulb = wizlight(ip)
            await bulb.turn_off()
        except Exception as e:
            messagebox.showerror("Bağlantı Hatası", f"{ip} için hata: {e}")

app = tk.Tk()
app.title("WiZ Ampul Kontrol Paneli")
app.geometry("300x300")

controller = WizController()

for idx, ip in enumerate(bulb_ips):
    frame = tk.LabelFrame(app, text=f"Ampul {idx + 1} - {ip}", padx=10, pady=10)
    frame.pack(padx=10, pady=5, fill="x")

    btn_on = tk.Button(frame, text="Aç", width=10, command=lambda ip=ip: controller.turn_on(ip))
    btn_on.pack(side="left", padx=5)

    btn_off = tk.Button(frame, text="Kapat", width=10, command=lambda ip=ip: controller.turn_off(ip))
    btn_off.pack(side="left", padx=5)

bulk_frame = tk.Frame(app)
bulk_frame.pack(pady=15)

btn_all_on = tk.Button(bulk_frame, text="Hepsini Aç", width=12, command=lambda: [controller.turn_on(ip) for ip in bulb_ips])
btn_all_on.pack(side="left", padx=5)

btn_all_off = tk.Button(bulk_frame, text="Hepsini Kapat", width=12, command=lambda: [controller.turn_off(ip) for ip in bulb_ips])
btn_all_off.pack(side="left", padx=5)

app.mainloop()

Sunday, May 7, 2023

pip show packagename

pip show <package name> will provide the location for Windows and macOS, and I'm guessing any system. :)

For example:

> pip show cvxopt
Name: cvxopt
Version: 1.2.0
...
Location: /usr/local/lib/python2.7/site-packages