DEV Community

Om Gedam
Om Gedam

Posted on

The Midnight Logs: When Your Smart Home Confesses

Hacktoberfest Open-Source AI Challenge: Ghost in the Machine Submission 👻🌼

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine

What I Built

The Midnight Logs is a full-stack web application that ingests raw smart home sensor logs and transforms them into atmospheric, first-person ghost stories — complete with AI-generated narration in multiple languages.

The premise is simple and unsettling: your smart home logs everything. Motion sensors. Door locks. Thermostat changes. Voice assistant triggers. Most nights, the logs are boring. But sometimes there are gaps, anomalies, impossible events. This app treats every glitch as evidence of something that was awake while you weren't.

Code

https://github.com/itsomg134/The-Midnight-Logs-When-Your-Smart-Home-Confesses

How I Built It

Tech Stack
Layer Tool Purpose
Log Ingestion Python + JSON parser Normalize raw IoT events into a timeline
Story Generation OpenAI gpt-4o-mini Turn anomalies into first-person horror prose
Translation OpenAI (same key) Preserve tone across languages
Text-to-Speech Deepgram Aura / Aura-2 Multi-language audio narration
Web Server Flask 3.1 Serve UI + orchestrate API calls
Frontend Vanilla HTML/CSS/JS Dark streaming-platform aesthetic
The Open-Source AI Angle
I deliberately designed the pipeline to be portable and local-friendly. The story generation uses OpenAI's Chat Completions API, but the architecture is a drop-in replacement for Ollama — which means you can run the entire story-generation step on local open-weight models like llama3.1:8b or gemma4:e4b without ever sending your home's activity logs to a third party.

Why this matters: Smart home logs are deeply personal. They reveal when you're home, when you're asleep, when you leave, when you return. Sending that data to a cloud LLM is a privacy nightmare. The open-source path (Ollama + local inference) means the "ghost in the machine" stays in your machine.

python

Swap to Ollama locally — no API key required

import requests
response = requests.post(
"http://localhost:11434/api/chat",
json={
"model": "llama3.1:8b",
"messages": [{"role": "user", "content": prompt}],
"stream": False
}
)
DevRelay Agent Session
I used DevRelay to capture the agent session where I:

Debugged the Flask import errors (ModuleNotFoundError: flask, ImportError: run)

Fixed Windows PowerShell-specific issues (touch → New-Item, \ line continuations)

Iterated on the Deepgram TTS model selection for multilingual support

Refined the system prompt to avoid "explaining the ghost"

Why Does Open Innovation Matter?

This project would be impossible as a closed product.

Smart home platforms are fragmented. Home Assistant, SmartThings, Apple Home, Google Home, Hubitat — each has its own log format, its own API, its own quirks. A closed SaaS ghost story generator would need partnerships with every platform and would lock users into a specific ecosystem.

By building on open standards (JSON logs, standard HTTP APIs) and open AI (the Ollama swap-in), I created something that:

Works with any smart home platform that can export logs

Can run entirely offline for privacy-conscious users

Can be forked to support new formats, new languages, new TTS engines

Doesn't rely on a single vendor's API to survive

The real innovation here isn't the ghost story — it's the architecture of portability. It shows that AI-powered creativity doesn't need to be a walled garden. It can be a toolkit that anyone can adapt, extend, and own.

What open innovation made possible:

I could swap OpenAI for Ollama in ten lines of code

I could swap Deepgram for Piper (local TTS) without touching the pipeline

I could add new languages by editing a config file

I could fork this for any log format — not just smart homes, but server logs, car telemetry, medical devices

That's the difference between a product and a platform. Open innovation made this a platform.

The Spirit of It

The moment it landed for me was when I ran the pipeline on my own logs for the first time.

I had a simple setup: bedroom motion sensor, hallway light, front door lock, thermostat. Boring data. But the AI looked at 03:03 — front_door → opened and wrote:

"The front door opened at 03:03. The deadbolt was engaged. The app logged it anyway. Then, one minute later, it closed."

I live alone. The deadbolt was engaged. And I had no memory of getting up.

I know it was a sensor glitch. I know the door didn't actually open. But for one perfect, horrible second, the machine had told me a truth I didn't want to hear: something happened while I was asleep, and I was the only one who didn't see it.

That's the ghost in the machine. Not an AI pretending to be haunted — an AI faithfully reporting what the logs actually say, and letting me fill in the horror.

If this project gives even one person chills at 3 AM, it's done its job.

Prize Categories

🎃 Best Horror / Creepy Experience

🔌 Best Use of Smart Home / IoT Data

🌍 Best Multilingual AI Application

🔒 Best Privacy-First AI Project (Ollama-ready architecture)

Top comments (0)