dicio-android icon indicating copy to clipboard operation
dicio-android copied to clipboard

Changes for Home assistant support

Open mretallack opened this issue 2 months ago • 2 comments

[HomeAssistant] Proof of Concept - Voice Control Integration

⚠️ Status: Proof of Concept - NOT READY FOR MERGE

This PR is a proof of concept to demonstrate Home Assistant integration with Dicio. It is not ready for production and requires review, testing, and refinement before merging.

Note: This implementation was developed with assistance from AWS Kiro AI to accelerate the initial development and explore the feasibility of Home Assistant integration.

Overview

Adds a new skill that allows users to control and query Home Assistant entities using voice commands. Users can turn devices on/off, check status, and query person locations through natural language.

Features Implemented

Voice Commands

Entity Control:

  • Turn entities on/off/toggle: "Turn living room light on", "Switch bedroom lamp off"
  • Check entity status: "Get status of garage door", "Check front door"
  • Person location: "Where is the person Mark", "What is Sarah location"

Supported Entity Types

  • Lights, switches, covers, locks, fans, media players
  • Person entities for location tracking
  • Any entity that supports standard Home Assistant services

Configuration

  • Settings UI for Base URL and Access Token
  • Entity mapping system (friendly name → entity ID)
  • Secure token storage using DataStore

Technical Implementation

Files Added/Modified

Core Implementation:

  • app/src/main/kotlin/org/stypox/dicio/skills/homeassistant/
    • HomeAssistantInfo.kt - Skill registration
    • HomeAssistantSkill.kt - Main skill logic
    • HomeAssistantOutput.kt - Output handling
    • HomeAssistantApi.kt - REST API client
    • HomeAssistantSettings.kt - Settings UI

Sentence Definitions:

  • app/src/main/sentences/skill_definitions.yml - Added sentence IDs
  • app/src/main/sentences/en/home_assistant.yml - English patterns

Proto/DataStore:

  • app/src/main/proto/skill_settings_home_assistant.proto - Settings schema

Tests:

  • app/src/test/kotlin/org/stypox/dicio/skills/homeassistant/HomeAssistantSkillTest.kt - 19 comprehensive tests

Documentation:

  • SETUP.md - Complete setup guide for users

Resources:

  • String resources for UI and speech output
  • Icon for the skill

Architecture

  • Uses Home Assistant REST API for all operations
  • Implements entity mapping for flexible friendly names
  • Handles multiple entity domains (light, switch, cover, lock, person, etc.)
  • Provides detailed error messages for troubleshooting

Testing

✅ All 19 unit tests passing:

  • Entity control (on/off/toggle) - 8 tests
  • Status queries - 7 tests
  • Person location - 4 tests

Tests cover:

  • All sentence pattern variations
  • With/without "the" article
  • Different command verbs (turn, switch, get, check, etc.)
  • Edge cases and pattern conflicts

Known Issues / TODO

Before Merge:

  • [ ] Security review - Token storage and transmission
  • [ ] Error handling - More robust network error handling
  • [ ] UI/UX review - Settings screen design
  • [ ] Localization - Add translations for other languages
  • [ ] Integration tests - Test against real Home Assistant instance
  • [ ] Code review - General code quality and style
  • [ ] Performance - Test with large numbers of entities
  • [ ] Documentation - Review and improve setup guide

Pattern Conflicts:

  • Avoided conflict with navigation skill by using "where is the person <name>" instead of "where is <name>"

Limitations:

  • Only supports basic on/off/toggle/status operations
  • No support for setting specific values (brightness, temperature, etc.)
  • No support for scenes or automations
  • Person location returns raw state (not formatted nicely)

Future Enhancements

Potential improvements for future iterations:

  • Support for setting brightness, color, temperature
  • Scene activation
  • Automation triggering
  • Better person location formatting (zone names)
  • Support for climate entities (thermostats)
  • Multi-entity commands ("Turn off all lights")
  • Confirmation prompts for sensitive actions

How to Test

  1. Set up a Home Assistant instance (or use existing)
  2. Build and install the app
  3. Go to Settings > Skills > Home Assistant
  4. Configure Base URL and Access Token
  5. Add entity mappings
  6. Try voice commands (see SETUP.md for examples)

Screenshots

TODO: Add screenshots of settings UI and example interactions

Related Issues

Link to any related issues or discussions

Checklist

  • [x] Code compiles without errors
  • [x] All tests pass
  • [x] Documentation added (SETUP.md)
  • [ ] Translations added for all supported languages
  • [ ] Screenshots added
  • [ ] Code reviewed by maintainer
  • [ ] Tested on physical device
  • [ ] Security review completed
  • [ ] Ready for merge

Again, this is a PROOF OF CONCEPT developed with AI assistance (AWS Kiro). It demonstrates the feasibility and basic functionality but requires significant review and refinement before being production-ready.

Feedback and suggestions are welcome!

mretallack avatar Dec 08 '25 10:12 mretallack

A screen shot. Screenshot_20251210-180927_Dicio-changes-for-ha

mretallack avatar Dec 10 '25 18:12 mretallack

The main area to review are the rule, especially the "where is person xxx". It can sometimes trigger the navigation skill.

mretallack avatar Dec 10 '25 18:12 mretallack