Skip to content

Add Home Security AI Agent with iOS-Compatible Mobile API#2

Draft
nfaggian wants to merge 3 commits into
mainfrom
cursor/home-security-agent-2693
Draft

Add Home Security AI Agent with iOS-Compatible Mobile API#2
nfaggian wants to merge 3 commits into
mainfrom
cursor/home-security-agent-2693

Conversation

@nfaggian

@nfaggian nfaggian commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

This PR adds a comprehensive home security AI agent that monitors smart locks, cameras, and sensors, with a REST API and a complete native iOS app.

Features

Home Security Agent

Uses Gemma 2 9B model by default via local Ollama for AI interactions.

  • Smart Lock Management: View status, lock/unlock doors remotely with confirmation for unlock operations
  • Camera Monitoring: View camera status, capture snapshots, review motion detection events
  • Sensor Monitoring: Track motion, door/window, smoke, and water leak sensors with battery level monitoring
  • Security System Control: Arm/disarm with multiple modes (away, home, night)
  • AI Chat Interface: Natural language interaction for security queries
  • Activity Logging: Track all security events with timestamps

Mobile API (FastAPI)

  • RESTful endpoints for all device operations
  • Quick action endpoints for common routines
  • Push notification registration and settings management
  • Full Swagger/OpenAPI documentation at /docs

iOS App (NEW)

A complete native SwiftUI iOS application:

Screens:

  • Dashboard: Security score gauge, quick actions (goodnight/leaving/arriving), status overview
  • Locks: View all locks with battery indicators, lock/unlock with confirmation dialogs
  • Cameras: Camera grid with online/offline status, motion events timeline with confidence scores
  • AI Chat: Natural language assistant with conversation history and smart suggestions
  • Settings: Server config, arm/disarm controls, activity log, sensors view

Technical:

  • SwiftUI with MVVM architecture
  • Async/await networking
  • iOS 17.0+ support
  • Full Xcode project included

Project Structure

├── src/
│   ├── agents/
│   │   └── home_security_agent/    # AI agent with Gemma model
│   │       ├── agent.py
│   │       └── tools/device_tools.py
│   └── mobile_api/                 # FastAPI backend
│       ├── app.py
│       └── models.py
├── ios/
│   └── HomeSecurityApp/            # SwiftUI iOS app
│       ├── Views/
│       │   ├── DashboardView.swift
│       │   ├── LocksView.swift
│       │   ├── CamerasView.swift
│       │   ├── ChatView.swift
│       │   └── SettingsView.swift
│       ├── Models/Models.swift
│       └── Services/APIService.swift
└── tests/
    ├── test_home_security_agent.py
    └── test_mobile_api.py

Usage

# Pull Gemma model
ollama pull gemma2:9b

# Start the backend
make mobile-api

# Open iOS app in Xcode
open ios/HomeSecurityApp/HomeSecurityApp.xcodeproj

Testing

52 tests covering all agent tools and API endpoints:

make test

Requirements

  • Python 3.10+
  • Ollama with Gemma model
  • iOS 17.0+ / Xcode 15.0+ (for iOS app)
Open in Web Open in Cursor 

cursoragent and others added 3 commits July 3, 2026 00:20
- Create home_security_agent with Google ADK integration
  - Smart lock management (view status, lock/unlock doors)
  - Camera monitoring (status, snapshots, motion events)
  - Sensor monitoring (motion, door/window, smoke, water leak)
  - Security system control (arm/disarm with modes)
  - AI chat interface for natural language interaction

- Build FastAPI mobile backend for iOS/Android apps
  - RESTful API endpoints for all device operations
  - Quick action endpoints (goodnight, leaving, arriving routines)
  - Push notification registration and settings
  - Pydantic models for request/response validation
  - Full Swagger/OpenAPI documentation at /docs

- Add comprehensive test suite (52 tests)
  - Tests for all device tools
  - Tests for all API endpoints
  - Tests for chat functionality

- Update documentation with usage examples
  - API endpoint reference
  - Swift integration examples
  - New Makefile targets

Co-authored-by: Nathan Faggian <nathan.faggian@gmail.com>
- Change default model from gpt-oss:20b to gemma2:9b via Ollama
- Add HOME_SECURITY_MODEL environment variable for model override
- Support multiple Gemma variants (7b, 9b, 27b) and Google AI Studio
- Update README with Gemma setup instructions

Co-authored-by: Nathan Faggian <nathan.faggian@gmail.com>
Features:
- Dashboard with security score gauge and quick actions (goodnight/leaving/arriving)
- Locks view with real-time status, lock/unlock controls, battery indicators
- Cameras view with motion events timeline and detection confidence
- AI Chat assistant with conversation history and smart suggestions
- Settings with server config, arm/disarm controls, activity log, sensors

Architecture:
- SwiftUI with MVVM pattern
- Async/await networking via URLSession
- Codable models matching API responses
- iOS 17.0+ with modern SwiftUI features

Includes:
- Full Xcode project configuration
- Asset catalogs for app icon and accent color
- Detailed README with setup instructions

Co-authored-by: Nathan Faggian <nathan.faggian@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants