๐ฆ๐๐ป๐ฑ๐ฎ๐ ๐๐ผ๐ณ๐ณ๐ฒ๐ฒ & ๐๐ผ๐ฑ๐ฒ: ๐๐ต๐ฒ ๐ฝ๐ผ๐ฟ๐ฐ๐ต ๐น๐ถ๐ด๐ต๐ ๐๐ด๐ฒ๐ป๐ ๐๐ต๐ฎ๐ ๐ธ๐ป๐ผ๐๐ ๐โ๐บ ๐ฐ๐ผ๐บ๐ถ๐ป๐ด ๐ต๐ผ๐บ๐ฒ
This weekendโs project continued with the simple idea - as I get close to home, switch on the porch light - but let an AI agent ๐ฅ๐ฆ๐ค๐ช๐ฅ๐ฆ ๐ฉ๐ฐ๐ธ ๐ฃ๐ณ๐ช๐จ๐ฉ๐ต ๐ข๐ฏ๐ฅ ๐ฉ๐ฐ๐ธ ๐ธ๐ข๐ณ๐ฎ based on the time, darkness and weather.
The result is a small experiment in what agentic systems look like when they have control over something in the physical world.
๐ง๐ต๐ฒ ๐ฝ๐ถ๐ฒ๐ฐ๐ฒ๐
- A WiZ smart bulb, wrapped in a small MCP server so an agent can call tools such as
turn_onandget_light_state. - OwnTracks on my phone, publishing locations over MQTT
- Mosquitto running in WSL on my PC.
- Tailscale, allowing the phone to reach the broker from anywhere.
- An OpenWeather API key
- An Agent built with Microsoft Agent Framework. It has tools for sun position and weather, plus a plain-English policy on light bulb settings.
- GoogleGemini 2.5 Flash via OpenRouter - fast, inexpensive for an occasional arrival event.
๐ง๐ต๐ฒ ๐ฑ๐ฒ๐๐ถ๐ด๐ป ๐ฟ๐๐น๐ฒ: ๐ธ๐ฒ๐ฒ๐ฝ ๐๐ต๐ฒ ๐๐๐ ๐ผ๐ป ๐ฎ ๐๐ต๐ผ๐ฟ๐ ๐น๐ฒ๐ฎ๐๐ต
- Anything that must never go wrong is handled by deterministic code, not the model.
- Distance and arrival detection fires once per arrival.
- The agent has a hard 30-second timeout. If the model or weather API fails, deterministic fallback logic turns the light on at 80% after dusk.
- And after the command is sent, the system reads the bulb state back and verifies what actually happened.
- ๐ง๐ต๐ฒ ๐ฎ๐ด๐ฒ๐ป๐ ๐ฐ๐ต๐ผ๐ผ๐๐ฒ๐. ๐ง๐ต๐ฒ ๐ฐ๐ผ๐ฑ๐ฒ ๐ด๐๐ฎ๐ฟ๐ฎ๐ป๐๐ฒ๐ฒ๐ (๐๐ช๐๐จ ๐๐จ๐๐๐) which feels increasingly important when AI starts controlling things outside a chat window.
And on the first real test, I drove more than a kilometre away and came home again, it was a bright, sunny afternoon (๐ต๐ฉ๐ช๐ด ๐ช๐ด ๐๐ช๐ค๐ต๐ฐ๐ณ๐ช๐ข ๐ข๐ง๐ต๐ฆ๐ณ ๐ข๐ญ๐ญ). The agent looked at the conditions, decided the porch light wasnโt needed, switched it off, and wrote a one-line explanation to the log - made me grin.
๐ง๐ต๐ฒ ๐น๐ฒ๐๐๐ผ๐ป ๐ ๐ฑ๐ถ๐ฑ๐ปโ๐ ๐ฒ๐ ๐ฝ๐ฒ๐ฐ๐ - while writing the documentation, my actual home coordinates ended up in a sample log line in a public GitHub repository. So I had to build a new public repo with a clean history and a much more careful scan for information. A useful reminder:
Code and a step-by-step build guide covering WSL, Tailscale, Mosquitto, OwnTracks, MCP and the agent: GitHub Repo
Iโm done for the day - time to grab another coffee - remember: Think-Model-Act. โ
