Commit 7ceba5b
feat: add diagnostic mode for empty automation traces (#235)
* feat: add diagnostic mode for empty automation traces
When ha_get_automation_traces returns no traces, the tool now includes
diagnostic information to help users understand why traces are missing:
- automation_exists: Whether the automation entity exists
- automation_enabled: Whether the automation is enabled (on/off)
- trace_storage_enabled: Whether trace storage is enabled
- last_triggered: Timestamp of last trigger
- suggestion: Actionable hint based on the diagnostics
This helps users troubleshoot common issues like disabled automations,
automations that have never triggered, or expired/cleared traces.
Closes #212
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* test: add E2E tests for automation/script trace retrieval
Add comprehensive E2E tests to verify ha_get_automation_traces tool:
- test_automation_trace_after_trigger: Create, trigger, verify non-empty traces
- test_empty_traces_with_diagnostics: Verify diagnostics when traces are empty
- test_script_traces: Verify trace retrieval works for scripts too
Tests validate:
- Traces are recorded after automation.trigger service call
- Trace structure includes run_id, timestamp, state
- Detailed trace retrieval by run_id
- Diagnostic mode for never-triggered automations
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: correct parameter format for ha_config_set_script in trace tests
The ha_config_set_script tool expects {"script_id": ..., "config": ...}
format, not the config directly. Also fixed variable naming to avoid
confusion between script_id_base and script_entity_id.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: use correct CleanupTracker.track() method signature
CleanupTracker has track(entity_type, entity_id) not track_automation()
or track_script() methods. Updated all calls to use the correct API.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: use correct ha_call_service parameter format
The ha_call_service tool uses entity_id as a direct parameter, not
nested inside a target dict. Fixed both automation trigger and script
turn_on calls in trace tests.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent c68b5bf commit 7ceba5b
3 files changed
Lines changed: 724 additions & 3 deletions
File tree
- src/ha_mcp/tools
- tests/src
- e2e/workflows/automation
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
157 | 158 | | |
158 | 159 | | |
159 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
160 | 171 | | |
161 | 172 | | |
162 | 173 | | |
| |||
224 | 235 | | |
225 | 236 | | |
226 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
227 | 346 | | |
228 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
229 | 351 | | |
230 | | - | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
231 | 360 | | |
232 | 361 | | |
233 | 362 | | |
| |||
254 | 383 | | |
255 | 384 | | |
256 | 385 | | |
257 | | - | |
| 386 | + | |
258 | 387 | | |
259 | 388 | | |
260 | 389 | | |
| |||
263 | 392 | | |
264 | 393 | | |
265 | 394 | | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
266 | 401 | | |
267 | 402 | | |
268 | 403 | | |
| |||
0 commit comments