This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a Home Assistant custom integration for Moen Smart Water Network devices (smart irrigation controllers). The integration communicates with Moen's IoT API and uses AWS IoT for real-time device state updates via MQTT shadow messages.
- Custom Component Structure: Located in
custom_components/moen_smart_water_network/ - API Client: Handles authentication with Moen's OAuth2 API and AWS IoT MQTT subscriptions
- Data Coordinator: Manages device state updates both via polling and real-time MQTT messages
- Entity Types: Supports sensors, binary sensors, and switches for irrigation zones and device status
- AWS Integration: Uses AWS IoT Device Shadow for real-time state synchronization
# Install dependencies
./scripts/setup
# Development setup (starts Home Assistant in debug mode)
./scripts/develop# Run linter (uses ruff via uv)
uv tool run ruff check .
# Run formatter
uv tool run ruff format .
# Run tests
uv run pytest
# Run specific test file
uv run pytest tests/test_sensors.pyThe integration includes a full Home Assistant development environment:
- Config directory:
config/withconfiguration.yaml - Custom component is automatically loaded via PYTHONPATH in develop script
- Debug logging enabled for the integration in
config/configuration.yaml
The integration uses Moen's OAuth2 API with JWT tokens and AWS Cognito for IoT access:
- Access/refresh tokens from OAuth2 flow
- JWT token validation for AWS Cognito identity
- MQTT connection to AWS IoT using Cognito credentials
The integration subscribes to AWS IoT Device Shadow updates for real-time state changes:
- Shadow messages merged into coordinator state
- Automatic listener updates trigger entity state refreshes
- Fallback to polling every 15 seconds for device information
awsiotsdk- AWS IoT Device SDK for MQTT communicationawscrt- AWS Common Runtime for authentication
ruff- Linter and formatterpytest+pytest-homeassistant-custom-componentmypy- Type checking
Integration configured via Home Assistant UI (config flow). Requires:
- Access token from Moen OAuth2 flow
- Refresh token for token renewal
- Device client IDs for MQTT subscriptions
Home Assistant coding patterns and conventions are in CLAUDE_HASS.md.