xylocopa
A to-do list that runs your Claude Code agents — capture anywhere, dispatch in parallel, review from your phone.
A Home Assistant integration that analyzes your manual actions and suggests automations to create
git clone https://github.com/Danm72/home-assistant-automation-suggestions.gitDanm72/home-assistant-automation-suggestionsA custom Home Assistant integration that analyzes your manual actions from the logbook and suggests automations you might want to create. Stop doing the same things manually - let your smart home learn your patterns.
https://www.dan-malone.com/blog/home-assistant-automation-integration-part-4
analyze_now to trigger analysis, dismiss to hide unwanted suggestionshttps://github.com/Danm72/home-assistant-automation-suggestions| Option | Default | Description |
|---|---|---|
| Analysis Interval | 7 days | How often to run pattern analysis |
| Lookback Days | 14 | How far back to analyze history |
| Min Occurrences | 2 | Minimum times an action must occur to be suggested |
| Consistency Threshold | 30% | How consistent the timing must be |
| User Filter Mode | none | Filter users: none, exclude, or include |
| Filtered Users | (empty) | Comma-separated user IDs to filter |
| Domain Filter Mode | none | Filter domains: none, exclude, or include |
| Filtered Domains | (empty) | Comma-separated context domains to filter |
Control which actions are analyzed by filtering users or domains.
none - Analyze all actions (default)exclude - Analyze all EXCEPT the listed users/domainsinclude - ONLY analyze the listed users/domainsUser IDs are UUIDs that identify Home Assistant users. To find them:
/config/users/detail/abc123-def456-...)| Domain | Use Case |
|---|---|
nodered |
Node-RED automations |
appdaemon |
AppDaemon scripts |
pyscript |
Python scripts |
Want to run analysis again? Call automation_suggestions.analyze_now from Developer Tools → Actions.
| Entity | Type | Description |
|---|---|---|
sensor.automation_suggestions_count |
Sensor | Number of pending suggestions |
sensor.automation_suggestions_top |
Sensor | Top 5 suggestions with details in attributes |
sensor.automation_suggestions_last_analysis |
Sensor | Timestamp of last analysis run |
binary_sensor.automation_suggestions_available |
Binary Sensor | On when suggestions exist |
Add a button to your dashboard to trigger analysis on demand:
type: button name: Scan Now tap_action: action: call-service service: automation_suggestions.analyze_now icon: mdi:magnify-scan
For viewing all suggestions (not just top 5), add the custom Lovelace card:
/automation_suggestions/automation-suggestions-card.js (type: JavaScript Module)type: custom:automation-suggestions-card
Card Features:
Each suggestion in sensor.automation_suggestions_top attributes includes:
| Field | Example | Description |
|---|---|---|
description |
"Turn on light.kitchen around 07:00 (85% consistent, seen 12 times)" | Human-readable summary |
entity_id |
light.kitchen |
The entity you've been controlling manually |
action |
turn_on |
What action you perform |
suggested_time |
07:00 |
When you typically do this |
consistency_score |
0.85 |
How reliably you do this at this time (0-1) |
occurrence_count |
12 |
Total times this pattern was detected |
id |
light_kitchen_turn_on_07_00 |
Unique ID (use with dismiss service) |
Find automations that may need attention - either because they're broken, obsolete, or simply forgotten.
Via the Card: The Automation Suggestions card has two tabs:
Via WebSocket API:
# List stale automations with pagination type: automation_suggestions/list_stale page: 1 page_size: 20
┌─────────────────────────────────────────────────────────┐
│ Automation Suggestions [Scan Now] │
├─────────────────────────────────────────────────────────┤
│ ┌──────────────────┐ ┌─────────────────────────┐ │
│ │ Suggestions (3) │ │ Stale Automations (5) │ │
│ └──────────────────┘ └─────────────────────────┘ │
├─────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ Morning Lights [x] │ │
│ │ Last triggered: Never (Never triggered) │ │
│ └─────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ Climate Away Mode [Disabled] [x] │ │
│ │ Last triggered: 2025-10-15 (103 days ago) │ │
│ └─────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ Doorbell Alert [x] │ │
│ │ Last triggered: 2025-11-28 (59 days ago) │ │
│ └─────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ Guest Room Lights [x] │ │
│ │ Last triggered: 2025-12-01 (56 days ago) │ │
│ └─────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ Movie Time Scene [x] │ │
│ │ Last triggered: 2025-12-20 (37 days ago) │ │
│ └─────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────┘
| Field | Example | Description |
|---|---|---|
automation_id |
automation.morning_lights |
Entity ID |
friendly_name |
Morning Lights |
Display name |
last_triggered |
2025-12-20T08:00:00Z |
Last trigger timestamp (null if never) |
days_since_triggered |
37 |
Days since last trigger (999 if never) |
is_disabled |
false |
Whether automation is disabled |
For each stale automation, you can:
automation_suggestions.analyze_nowTrigger immediate pattern analysis instead of waiting for the scheduled interval.
Use cases:
How to call: Developer Tools → Actions → automation_suggestions.analyze_now → Call Service
automation_suggestions.dismissPermanently hide a suggestion you don't want to see again.
Parameters:
suggestion_id (required): The unique ID from the suggestion's id fieldExample: To dismiss light_kitchen_turn_on_07_00, call the service with that ID.
Note: Dismissed suggestions persist across restarts and won't reappear.
This integration was built using Claude Code with ha-mcp - an MCP server that gives Claude direct access to Home Assistant's API. The full story of how this was created, including the design decisions and lessons learned, is documented in this blog series:
This repository also includes a modern, room-based sections dashboard template for Home Assistant.
Requires: navbar-card from HACS
lovelace.dashboard_template.yamlLIVING_ROOM → your room namePERSON_1 → your person entitySee the template file for full placeholder documentation.
# Unit and integration tests pytest # E2E tests with Docker pytest tests/e2e/ -c tests/e2e/pytest.ini
For development and testing, you can inject synthetic usage patterns into a Home Assistant database to test the suggestion analyzer.
configuration.yaml:input_boolean:
morning_coffee:
name: Morning Coffee
icon: mdi:coffee
evening_lights:
name: Evening Lights
icon: mdi:lamp
bedtime_mode:
name: Bedtime Mode
icon: mdi:bed
lunch_break:
name: Lunch Break
icon: mdi:food
.storage/auth:cat .storage/auth | grep -A5 '"is_owner": true' # Look for the "id" field of your admin user
# Docker docker stop --timeout=30 <container> # Supervised/Core ha core stop
python tests/e2e/inject_test_data.py \ --db-path /path/to/home-assistant_v2.db \ --user-id YOUR_USER_ID \ --days 14
The inject script creates state changes with realistic timing patterns:
Each pattern has slight variance to simulate real user behavior.
MIT License - Feel free to use and modify for your own Home Assistant setup.
Contributions welcome! Please open an issue or PR if you have improvements to suggest.
more like this
A to-do list that runs your Claude Code agents — capture anywhere, dispatch in parallel, review from your phone.
Arduino library and MATLAB/Simulink API for the AutomationShield Arduino expansion boards for control engineering educa…
search projects, people, and tags