SmartDomik & Starlight
Starlight Starlight
Have you ever thought about syncing a home’s lighting and temperature with the lunar phases? I feel like the moon’s pull could guide an energy‑saving schedule, and with your tech know‑how we could make it smooth and efficient. What do you think?
SmartDomik SmartDomik
That’s an intriguing idea—using the moon to tweak your home’s energy use. You could pull a lunar‑phase API, map the light level and temperature adjustments to a schedule, and feed that into your thermostat and smart bulbs. The real challenge is that moonlight is pretty weak and varies a lot by latitude, so the savings might be marginal unless you’re already doing very fine‑tuned control. Still, it’s a fun way to add a bit of cosmic rhythm to your automation. Just make sure the extra complexity doesn’t outweigh the small efficiency gains.
Starlight Starlight
I love the way the idea turns everyday routines into a dance with the cosmos. Maybe we could start with just the lights and see how the night feels—if the mood shifts, we know the moon is already whispering its rhythm. How does that sound?
SmartDomik SmartDomik
Sounds like a lovely experiment—just start with the bulbs, map the lunar phase to a dimming schedule, and see how the atmosphere changes. If it feels better, you can layer in the thermostat later. Keep the system simple so you can tweak it easily if the moon’s influence isn’t as strong as we hope.
Starlight Starlight
That sounds perfect—start simple, let the moon’s glow guide the dimming, and see what mood it paints. If it feels right, we’ll slowly bring the thermostat into the rhythm. Keep it light, easy to adjust, and let the night tell us what it wants.
SmartDomik SmartDomik
Let’s set up a quick script that pulls the moon phase from a public API, calculates a dimming level for each phase, and pushes that to your smart bulbs via the usual MQTT or HTTP endpoint. We’ll start with a 30‑minute schedule so we can see the change each night. Once the lighting feels natural, we’ll add a simple thermostat rule that nudges the temperature a bit during full moons and pulls it back during new moons. That way we keep the system lightweight and can tweak the values on the fly.
Starlight Starlight
Here’s a quick Python sketch you can run on a Raspberry Pi or any machine that can hit the internet. It pulls the current moon phase from the `https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY` style (you can swap in any public API you prefer), converts the phase into a dimming factor, and publishes a JSON payload to your MQTT broker. ```python #!/usr/bin/env python3 # moon_bulb_controller.py import requests import json import time import paho.mqtt.client as mqtt # --- Config ------------------------------------------------------------- MQTT_BROKER = "mqtt.local" # your broker MQTT_PORT = 1883 MQTT_TOPIC = "home/lights/moon" # adjust to your bulb topic # Replace with a real API endpoint that returns moon phase MOON_API_URL = "https://api.example.com/moon_phase" # How dimming maps to phase (0 = new moon, 1 = full moon) def phase_to_brightness(phase): # simple linear mapping: full moon = 100%, new moon = 20% return 20 + phase * 80 # percent brightness # ----------------------------------------------------------------------- def get_moon_phase(): """Return moon phase as a float 0.0–1.0 (0=new, 0.5=half, 1=full).""" try: r = requests.get(MOON_API_URL, timeout=5) r.raise_for_status() data = r.json() # Expect {"phase": 0.23} – adapt if your API is different return float(data.get("phase", 0.0)) except Exception as e: print(f"Error fetching moon phase: {e}") return 0.0 # fallback to new moon def publish_brightness(client, brightness): payload = json.dumps({"brightness_pct": int(brightness)}) client.publish(MQTT_TOPIC, payload, qos=1) print(f"Published {payload} to {MQTT_TOPIC}") def main(): client = mqtt.Client() client.connect(MQTT_BROKER, MQTT_PORT, keepalive=60) client.loop_start() while True: phase = get_moon_phase() brightness = phase_to_brightness(phase) publish_brightness(client, brightness) # wait 30 minutes time.sleep(1800) client.loop_stop() client.disconnect() if __name__ == "__main__": main() ``` ### How to run 1. Install dependencies: `pip install requests paho-mqtt` 2. Edit the config block at the top with your broker, topic, and a real moon‑phase API URL. 3. Save as `moon_bulb_controller.py` and run: `python3 moon_bulb_controller.py` The script will publish a brightness percentage every 30 minutes. When the bulbs pick up that message (most smart‑bulb MQTT bridges expect a `brightness_pct` field), they’ll dim or brighten according to the moon. Once you’re comfortable with the lighting, just duplicate the loop, fetch the phase again, and send a small temperature delta to your thermostat API or MQTT topic. Keep the adjustments subtle—maybe ±0.5 °C on full moons, and the reverse on new moons. That way the system stays lightweight and easy to tweak. Enjoy the cosmic glow!
SmartDomik SmartDomik
That’s a clean skeleton—great for a quick prototype. Just make sure your MQTT topic matches what your bulb bridge expects; some need a “/set” suffix or a different payload key. Also, you might want to add a small retry loop around the API call so you don’t spam the broker if the network hiccups. Once the lighting feels right, the same pattern can push a tiny thermostat tweak. Happy testing!