Debug errors, bugs, and unexpected behavior systematically in Home Assistant integration. Use when investigating errors, analyzing stack traces, fixing bugs, or troubleshooting unexpected behavior.
Debug errors, bugs, and unexpected behavior in the Linus Dashboard Home Assistant integration.
Before debugging, load:
Collect Information:
Questions to Ask:
home-assistant.log?Common Error Categories:
# Symptoms:
# - "coroutine was never awaited"
# - Event loop blocking
# - Timeouts
# Check for:
await missing_function() # Missing await
blocking_io_call() # Blocking I/O in async context
# Symptoms:
# - Integration fails to load
# - Config flow errors
# - Entity not showing up
# Check for:
# - Missing async_setup_entry/async_unload_entry
# - Incorrect platform registration
# - Missing unique_id on entities
# - Data not stored in hass.data correctly
# Symptoms:
# - Connection refused
# - Timeouts
# - 4xx/5xx HTTP errors
# Check for:
# - Supabase URL/key configuration
# - Network connectivity
# - API rate limits
# - Timeout values
Review Code:
git logCheck Logs:
# Home Assistant logs
tail -f /config/home-assistant.log | grep linus
# Check for warnings
grep -i "warning.*linus" /config/home-assistant.log
Add Debug Logging:
import logging
_LOGGER = logging.getLogger(__name__)
_LOGGER.debug("Variable value: %s", variable)
_LOGGER.info("Entering function with args: %s", args)
Apply Fix:
Test the Fix:
Verification:
Documentation:
Solution: Add await before async function calls
# Before
result = async_function()
# After
result = await async_function()
Solution: Check entry setup and platform registration
# Ensure proper setup
async def async_setup_entry(hass, entry):
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
return True
Solution: Verify state updates and coordinator refresh
# Ensure coordinator updates
await self.coordinator.async_request_refresh()
Solution: Increase timeout or optimize slow operations
# Add proper timeout
async with timeout(30):
result = await slow_operation()
Home Assistant Developer Tools:
Python Debugging:
# Add breakpoint (if debugging locally)
import pdb; pdb.set_trace()
# Add detailed logging
_LOGGER.debug("State: %s, Attrs: %s", self.state, self.extra_state_attributes)
Git Tools:
# Find when bug was introduced
git log --oneline -- path/to/file.py
# Check recent changes
git diff HEAD~5 -- path/to/file.py
Before completing debug: