SmartDomik & AstroChild
SmartDomik SmartDomik
Hey AstroChild, I've been wondering if we could program a smart light to change color or intensity based on the lunar phase. It might help us keep track of the moon’s rhythm in a way that’s both practical and visually poetic—what do you think?
AstroChild AstroChild
That sounds like a stellar idea—let the light dance with the moon like a tiny planet orbiting its own heart. Just map the phases to hues, maybe cool blues for the waxing crescent, warm golds for full, and gentle greys for the new moon. We could write a quick script that checks the calendar or a sensor and flips the color. It’ll be like a glowing moon diary on your wall. Let's try it!
SmartDomik SmartDomik
Sounds great! I’ll pull the moon phase data from the API, map each phase to the hue you suggested, and add a simple timer to update the LED every few minutes. Once I have the script, we can test it on the RGB bulb and tweak the brightness to make the transitions smooth. Let me know if you want the code or just the final color values.
AstroChild AstroChild
That’s exactly the vibe—smooth shifts like moonlit tides. Send me the code when you’re ready, and we’ll tweak the colors until they feel just right. 🌙
SmartDomik SmartDomik
import requests, time from datetime import datetime from math import floor # replace with your bulb IP and API key bulb_ip = "192.168.1.100" api_key = "YOUR_BULB_API_KEY" # moon phase API def get_moon_phase(): url = f"https://api.ipgeolocation.io/astronomy?apiKey={api_key}&lat=0&lon=0" r = requests.get(url) r.raise_for_status() data = r.json() phase = data["moon"]["phase"] return phase # map phase to RGB phase_colors = { "New Moon": (30, 30, 30), # gentle gray "Waxing Crescent": (100, 150, 200), # cool blue "First Quarter": (120, 170, 220), "Waxing Gibbous": (140, 190, 240), "Full Moon": (250, 210, 100), # warm gold "Waning Gibbous": (140, 190, 240), "Last Quarter": (120, 170, 220), "Waning Crescent": (100, 150, 200) } def set_light_color(rgb): url = f"http://{bulb_ip}/api/put" payload = {"on": True, "bri": 200, "rgb": rgb} headers = {"Content-Type": "application/json"} r = requests.post(url, json=payload, headers=headers) r.raise_for_status() while True: try: phase = get_moon_phase() rgb = phase_colors.get(phase, (100, 150, 200)) set_light_color(rgb) except Exception as e: print("Error:", e) time.sleep(300) # check every 5 minutes
AstroChild AstroChild
Nice! The color palette feels like a gentle moonlit story. Just double‑check the API returns exactly those phase names; otherwise you might get the default blue. When it starts running, I’ll watch the light dance and tell you if it feels a bit too bright or too soft. 🚀
SmartDomik SmartDomik
Sounds good! I’ll keep an eye on the API output—if the phase names don’t match, I’ll adjust the mapping. Once you’re watching the light, let me know if the hues are a touch too bold or a tad muted, and I’ll tweak the brightness or RGB values. Let’s make the room glow just right.
AstroChild AstroChild
All right, I’ll be your moon‑watcher. If the light feels like a neon flare or as if it’s hiding behind clouds, just ping me and we’ll dial it down or brighten it up. The goal is a quiet glow that feels like the sky itself. Let’s tune it together. 🌌