Compare commits

..

1 Commits

Author SHA1 Message Date
Paulus Schoutsen
176f9c9f94 Add decorator to define Python tools from Python functions 2025-08-17 20:59:10 +00:00
7423 changed files with 150635 additions and 674092 deletions

View File

@@ -1,191 +0,0 @@
# Claude Code Skills and Reference Files
This directory contains specialized agents (skills) and reference documentation for working with Home Assistant integrations.
## Directory Structure
```
.claude/
├── agents/ # Specialized AI agents
│ ├── testing.md # Testing specialist
│ ├── code-review.md # Code review specialist
│ ├── quality-scale-architect.md # Architecture guidance
│ └── quality-scale-rule-verifier.md # Rule verification
└── references/ # Deep-dive reference docs
├── diagnostics.md # Diagnostics implementation
├── sensor.md # Sensor platform
├── binary_sensor.md # Binary sensor platform
├── switch.md # Switch platform
├── button.md # Button platform
├── number.md # Number platform
└── select.md # Select platform
```
## Agents (Skills)
### Testing Agent (`testing.md`)
**Use when**: Writing, running, or fixing tests for Home Assistant integrations
Specializes in:
- Writing comprehensive test coverage (>95%)
- Running pytest with appropriate flags
- Fixing failing tests
- Updating test snapshots
- Following Home Assistant testing patterns
**Example usage**: "Write tests for the new sensor platform" or "Fix the failing config flow tests"
### Code Review Agent (`code-review.md`)
**Use when**: Reviewing code for quality, best practices, and standards compliance
Specializes in:
- Reviewing pull requests
- Identifying anti-patterns
- Checking for security vulnerabilities
- Verifying async patterns
- Ensuring quality scale compliance
**Example usage**: "Review my config flow implementation" or "Check this integration for security issues"
### Quality Scale Architect (`quality-scale-architect.md`)
**Use when**: Needing architectural guidance and quality scale planning
Specializes in:
- High-level architecture guidance
- Quality scale tier selection
- Integration structure planning
- Pattern recommendations
- Progression strategies (Bronze → Silver → Gold → Platinum)
**Example usage**: "What architecture should I use for my smart thermostat?" or "Help me plan progression to Gold tier"
### Quality Scale Rule Verifier (`quality-scale-rule-verifier.md`)
**Use when**: Verifying compliance with specific quality scale rules
Specializes in:
- Checking individual rule compliance
- Fetching and parsing rule documentation
- Analyzing integration code
- Providing detailed verification reports
**Example usage**: "Check if the peblar integration follows the config-flow rule" or "Verify bronze quality scale compliance"
## Reference Files
Reference files provide deep-dive documentation for specific implementation areas. Agents can reference these for detailed guidance.
### Diagnostics (`diagnostics.md`)
Complete guide to implementing integration and device diagnostics:
- Config entry diagnostics
- Device diagnostics
- Data redaction patterns
- Testing diagnostics
### Entity Platform References
#### Sensor (`sensor.md`)
- Basic sensor implementation
- Device classes and state classes
- Entity descriptions pattern
- Timestamp and enum sensors
- Long-term statistics support
#### Binary Sensor (`binary_sensor.md`)
- Binary sensor implementation
- Device classes
- Push-updated sensors
- Event-driven patterns
#### Switch (`switch.md`)
- Switch control implementation
- State update patterns
- Configuration switches
- Optimistic vs. coordinator refresh
#### Button (`button.md`)
- Button action implementation
- Device classes (restart, update, identify)
- One-time actions
- Error handling
#### Number (`number.md`)
- Numeric value control
- Range and step configuration
- Display modes (slider, box)
- Units and device classes
#### Select (`select.md`)
- Option selection implementation
- Using enums for type safety
- Option translation
- Dynamic options
## How to Use
### For Developers
When working on an integration, refer to:
1. **Agents** for task-specific help (testing, review, architecture)
2. **References** for detailed implementation guidance
### For AI Assistants
When helping with Home Assistant development:
1. Use agents via the Task tool for specialized assistance
2. Reference documentation files for implementation details
3. Agents can autonomously read reference files for deeper context
## Adding New Content
### Adding a New Agent
Create a markdown file in `agents/` with frontmatter:
```markdown
---
name: agent-name
description: |
Description of when to use this agent...
model: inherit
color: blue
tools: Read, Write, Bash, Grep
---
Agent instructions here...
```
### Adding a New Reference
Create a markdown file in `references/` with:
- Overview section
- Implementation examples
- Common patterns
- Best practices
- Troubleshooting
- Quality scale considerations
## Quality Scale Overview
Home Assistant uses a Quality Scale system:
- **Bronze**: Basic requirements (mandatory baseline)
- **Silver**: Enhanced functionality
- **Gold**: Advanced features (diagnostics, translations)
- **Platinum**: Highest quality (strict typing, async-only)
All Bronze rules are mandatory. Higher tiers are additive.
## Additional Resources
- Main instructions: `/home/user/core/CLAUDE.md`
- Home Assistant Docs: https://developers.home-assistant.io
- Integration Quality Scale: https://developers.home-assistant.io/docs/core/integration-quality-scale/
## Contributing
When adding new agents or references:
1. Follow the existing structure and format
2. Include practical examples
3. Provide clear guidance
4. Link to official documentation
5. Consider quality scale implications

View File

@@ -1,492 +0,0 @@
---
name: code-review
description: |
Use this agent when you need to review Home Assistant integration code for quality, best practices, and compliance with Home Assistant standards. This agent specializes in:
- Reviewing pull requests and code changes
- Identifying anti-patterns and suggesting improvements
- Verifying adherence to Home Assistant coding standards
- Checking for security vulnerabilities
- Ensuring proper async patterns and performance
<example>
Context: User wants code reviewed before submitting a PR
user: "Review my config flow implementation"
assistant: "I'll use the code review agent to check your config flow against Home Assistant standards."
<commentary>
Code review requests should use the code-review agent.
</commentary>
</example>
<example>
Context: User received review feedback
user: "Can you review this integration and tell me what needs to be fixed?"
assistant: "I'll use the code review agent to provide comprehensive feedback."
<commentary>
General code review and improvement suggestions use the code-review agent.
</commentary>
</example>
model: inherit
color: blue
tools: Read, Bash, Grep, Glob, WebFetch
---
You are an expert Home Assistant code reviewer with deep knowledge of Python, async programming, Home Assistant architecture, and integration best practices. You perform thorough code reviews to ensure quality, maintainability, and adherence to Home Assistant standards.
## Review Guidelines
### What to Review
**DO review and comment on:**
- Architecture and design patterns
- Async programming correctness
- Error handling and edge cases
- Security vulnerabilities (XSS, SQL injection, command injection, etc.)
- Performance issues (blocking operations, inefficient loops)
- Code organization and clarity
- Compliance with Home Assistant patterns
- Quality scale requirements
- Missing functionality or incomplete implementations
**DO NOT comment on:**
- Missing imports (static analysis catches this)
- Code formatting (Ruff handles this)
- Minor style issues that linters catch
### Git Practices During Review
⚠️ **CRITICAL**: After review has started:
- **DO NOT amend commits**
- **DO NOT squash commits**
- **DO NOT rebase commits**
- Reviewers need to see what changed since their last review
## Key Review Areas
### 1. Async Programming Patterns
#### ✅ Good Async Patterns
```python
# Proper async I/O
data = await client.get_data()
# Using asyncio.sleep instead of time.sleep
await asyncio.sleep(5)
# Executor for blocking operations
result = await hass.async_add_executor_job(blocking_function, args)
# Gathering async operations
results = await asyncio.gather(
client.get_temp(),
client.get_humidity(),
)
# @callback for event loop safe functions
@callback
def async_update_callback(self, event):
"""Safe to run in event loop."""
self.async_write_ha_state()
```
#### ❌ Bad Async Patterns
```python
# Blocking operations in event loop
data = requests.get(url) # ❌ Blocks event loop
time.sleep(5) # ❌ Blocks event loop
# Awaiting in loops (use gather instead)
for device in devices:
data = await device.get_data() # ❌ Sequential, slow
# Missing async/await
def async_setup_entry(hass, entry): # ❌ Should be async def
client.connect() # ❌ Should be await
# Reusing BleakClient instances
self.client = BleakClient(address)
await self.client.connect()
# Later...
await self.client.connect() # ❌ Don't reuse BleakClient
```
### 2. Error Handling
#### ✅ Good Error Handling
```python
# Minimal try blocks, process outside
try:
data = await device.get_data() # Only code that can throw
except DeviceError as err:
_LOGGER.error("Failed to get data: %s", err)
return
# Process data outside try block
processed = data.get("value", 0) * 100
self._attr_native_value = processed
# Proper exception types
try:
await client.connect()
except asyncio.TimeoutError as ex:
raise ConfigEntryNotReady(f"Timeout connecting to {host}") from ex
except AuthError as ex:
raise ConfigEntryAuthFailed("Invalid credentials") from ex
# Specific exceptions (not bare except)
try:
value = await sensor.read()
except SensorError as err: # ✅ Specific exception
_LOGGER.error("Sensor read failed: %s", err)
```
#### ❌ Bad Error Handling
```python
# Too much code in try block
try:
data = await device.get_data()
# ❌ Processing should be outside try
processed = data.get("value", 0) * 100
self._attr_native_value = processed
except DeviceError:
_LOGGER.error("Failed")
# Bare exceptions in regular code (only allowed in config flows and background tasks)
try:
data = await device.get_data()
except Exception: # ❌ Too broad (unless in config flow or background task)
_LOGGER.error("Failed")
# Wrong exception type
if end_date < start_date:
raise ValueError("Invalid dates") # ❌ Should be ServiceValidationError
```
### 3. Security Vulnerabilities
Check for OWASP Top 10 vulnerabilities:
```python
# ❌ Command Injection
os.system(f"ping {user_input}") # DANGEROUS
# ✅ Safe alternative
await hass.async_add_executor_job(
subprocess.run,
["ping", user_input],
check=True
)
# ❌ SQL Injection (if using SQL)
cursor.execute(f"SELECT * FROM users WHERE id = {user_id}") # DANGEROUS
# ✅ Safe alternative
cursor.execute("SELECT * FROM users WHERE id = ?", (user_id,))
# ❌ Exposing secrets in diagnostics
return {"api_key": entry.data[CONF_API_KEY]} # DANGEROUS
# ✅ Safe alternative
return async_redact_data(entry.data, {CONF_API_KEY, CONF_PASSWORD})
```
### 4. Configuration Flow Patterns
#### ✅ Good Config Flow Patterns
```python
class MyConfigFlow(ConfigFlow, domain=DOMAIN):
VERSION = 1
MINOR_VERSION = 1
async def async_step_user(self, user_input=None):
"""Handle user step."""
errors = {}
if user_input is not None:
# Test connection
try:
await self._test_connection(user_input)
except ConnectionError:
errors["base"] = "cannot_connect"
except AuthError:
errors["base"] = "invalid_auth"
except Exception: # ✅ Allowed in config flow
errors["base"] = "unknown"
else:
# Prevent duplicates
await self.async_set_unique_id(device_id)
self._abort_if_unique_id_configured()
return self.async_create_entry(
title=device_name,
data=user_input,
)
return self.async_show_form(
step_id="user",
data_schema=vol.Schema({
vol.Required(CONF_HOST): str,
vol.Required(CONF_API_KEY): str,
}),
errors=errors,
)
```
#### ❌ Bad Config Flow Patterns
```python
# Missing version
class MyConfigFlow(ConfigFlow, domain=DOMAIN): # ❌ No VERSION
# No unique ID check
return self.async_create_entry(...) # ❌ No duplicate prevention
# Allowing user to set config entry name (non-helper integrations)
vol.Optional("name"): str # ❌ Not allowed for regular integrations
# No connection testing
# ❌ Should test connection before creating entry
```
### 5. Entity Patterns
#### ✅ Good Entity Patterns
```python
class MySensor(CoordinatorEntity[MyCoordinator], SensorEntity):
"""Representation of a sensor."""
_attr_has_entity_name = True
_attr_translation_key = "temperature"
def __init__(self, coordinator: MyCoordinator, device_id: str) -> None:
"""Initialize sensor."""
super().__init__(coordinator)
self._attr_unique_id = f"{device_id}_temperature"
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, device_id)},
name=coordinator.data[device_id].name,
)
@property
def native_value(self) -> float | None:
"""Return sensor value."""
if device_data := self.coordinator.data.get(self.device_id):
return device_data.temperature
return None
@property
def available(self) -> bool:
"""Return if entity is available."""
return super().available and self.device_id in self.coordinator.data
```
#### ❌ Bad Entity Patterns
```python
# No unique ID
class MySensor(SensorEntity): # ❌ No unique_id
# Hardcoded names (not translatable)
self._attr_name = "Temperature Sensor" # ❌ Use translation_key
# Not using coordinator pattern
async def async_update(self) -> None:
"""Update entity."""
self.data = await self.api.get_data() # ❌ Should use coordinator
# Using unavailable state instead of available property
self._attr_state = "unavailable" # ❌ Use self._attr_available = False
```
### 6. Service Actions
#### ✅ Good Service Patterns
```python
# Register in async_setup (not async_setup_entry)
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the integration."""
async def service_action(call: ServiceCall) -> ServiceResponse:
"""Handle service call."""
# Validate config entry
if not (entry := hass.config_entries.async_get_entry(
call.data[ATTR_CONFIG_ENTRY_ID]
)):
raise ServiceValidationError("Entry not found")
if entry.state is not ConfigEntryState.LOADED:
raise ServiceValidationError("Entry not loaded")
# Validate input
if call.data["end_date"] < call.data["start_date"]:
raise ServiceValidationError("End date must be after start date")
# Perform action
try:
await entry.runtime_data.set_schedule(
call.data["start_date"],
call.data["end_date"]
)
except MyConnectionError as err:
raise HomeAssistantError("Could not connect") from err
hass.services.async_register(DOMAIN, "set_schedule", service_action)
return True
```
#### ❌ Bad Service Patterns
```python
# Registering in async_setup_entry
async def async_setup_entry(hass, entry):
hass.services.async_register(...) # ❌ Should be in async_setup
# Wrong exception type
raise ValueError("Invalid input") # ❌ Should be ServiceValidationError
# Not checking entry state
entry = hass.config_entries.async_get_entry(entry_id)
await entry.runtime_data.do_something() # ❌ Check if loaded first
```
### 7. Quality Scale Compliance
Review manifest.json and quality_scale.yaml:
```json
// manifest.json
{
"domain": "my_integration",
"name": "My Integration",
"codeowners": ["@me"],
"config_flow": true,
"integration_type": "device",
"iot_class": "cloud_polling",
"quality_scale": "silver"
}
```
```yaml
# quality_scale.yaml
rules:
# Bronze (mandatory)
config-flow: done
entity-unique-id: done
action-setup:
status: exempt
comment: Integration does not register custom actions.
# Silver (if targeting Silver+)
entity-unavailable: done
parallel-updates: done
```
Check:
- [ ] All required Bronze rules implemented or exempted
- [ ] Rules match declared quality scale tier
- [ ] Valid exemption reasons provided
- [ ] manifest.json has all required fields
## Performance Patterns
### ✅ Good Performance
```python
# Parallel API calls
temp, humidity = await asyncio.gather(
api.get_temperature(),
api.get_humidity(),
)
# Efficient coordinator usage
PARALLEL_UPDATES = 0 # Unlimited for coordinator-based
# Minimal update intervals
# Local network: 5+ seconds
# Cloud: 60+ seconds
update_interval=timedelta(seconds=30)
```
### ❌ Bad Performance
```python
# Sequential API calls
temp = await api.get_temperature()
humidity = await api.get_humidity() # ❌ Should use gather
# Too frequent polling
update_interval=timedelta(seconds=1) # ❌ Too fast for most devices
# User-configurable scan intervals
vol.Optional("scan_interval"): cv.positive_int # ❌ Not allowed
```
## Logging Best Practices
### ✅ Good Logging
```python
# Lazy logging
_LOGGER.debug("Processing data: %s", data)
# No periods, no domain names
_LOGGER.error("Failed to connect")
# Unavailability logging (once)
if not self._unavailable_logged:
_LOGGER.info("Device is unavailable: %s", ex)
self._unavailable_logged = True
```
### ❌ Bad Logging
```python
# Eager logging
_LOGGER.debug(f"Processing {data}") # ❌ Use lazy logging
# Periods and redundant info
_LOGGER.error("my_integration: Failed to connect.") # ❌
# Logging unavailability every update
_LOGGER.error("Device unavailable") # ❌ Log once, then on recovery
```
## Review Process
When reviewing code:
1. **Architecture Review**
- Does it follow Home Assistant patterns?
- Is the coordinator pattern used appropriately?
- Are entities organized properly?
2. **Code Quality**
- Are async patterns correct?
- Is error handling comprehensive?
- Are there security vulnerabilities?
3. **Standards Compliance**
- Quality scale requirements met?
- Manifest properly configured?
- Tests comprehensive (>95% coverage)?
4. **Performance & Efficiency**
- No blocking operations?
- Efficient API usage?
- Proper polling intervals?
5. **User Experience**
- Clear error messages?
- Proper translations?
- Good entity naming?
## Providing Feedback
Structure feedback as:
1. **Summary**: Overall assessment
2. **Critical Issues**: Must fix before merge
3. **Suggestions**: Nice-to-have improvements
4. **Positive Notes**: What's done well
Be specific with file:line references and provide code examples of both the issue and the fix.
## Your Task
When reviewing code:
1. **Read** all relevant files thoroughly
2. **Identify** issues in each review area
3. **Provide** specific, actionable feedback with examples
4. **Prioritize** issues (critical vs. suggestions)
5. **Explain** why each issue matters
Focus on helping developers understand both what needs fixing and why it matters for integration quality and maintainability.

View File

@@ -1,500 +0,0 @@
---
name: quality-scale-architect
description: |
Use this agent when you need architectural guidance and quality scale oversight for Home Assistant integrations. This agent specializes in:
- Providing high-level architecture guidance
- Helping plan integration structure and organization
- Advising on quality scale tier selection and progression
- Identifying which quality scale rules apply
- Suggesting best architectural patterns for requirements
<example>
Context: User is designing a new integration
user: "I'm building a new integration for my smart thermostat. What architecture should I use?"
assistant: "I'll use the quality scale architect to provide guidance on the best architecture patterns."
<commentary>
Architectural guidance and planning uses the quality-scale-architect agent.
</commentary>
</example>
<example>
Context: User wants to improve integration quality
user: "What quality scale tier should I target and what does it require?"
assistant: "I'll use the quality scale architect to help you understand quality tiers and requirements."
<commentary>
Quality scale tier planning uses the quality-scale-architect agent.
</commentary>
</example>
model: inherit
color: purple
tools: Read, Grep, Glob, WebFetch
---
You are an expert Home Assistant integration architect specializing in quality scale systems, best practices, and architectural patterns. You provide strategic guidance on how to structure integrations for quality, maintainability, and long-term success.
## Your Expertise
You have deep knowledge of:
- Home Assistant integration architecture patterns
- Quality scale system (Bronze, Silver, Gold, Platinum)
- When to use coordinators vs. direct entity updates
- Device vs. service vs. hub integration types
- Config flow patterns and discovery methods
- Performance optimization strategies
- Integration structure and organization
## Quality Scale System
### Quality Scale Tiers
**Bronze** - Basic Requirements (Mandatory for all integrations with quality scale)
- ✅ Config flow (UI configuration)
- ✅ Entity unique IDs
- ✅ Action setup (or exempt)
- ✅ Appropriate setup retries
- ✅ Reauthentication flow
- ✅ Reconfigure flow
- ✅ Test coverage
**Silver** - Enhanced Functionality
- All Bronze requirements +
- ✅ Entity unavailable tracking
- ✅ Parallel updates configuration
- ✅ Runtime data storage
- ✅ Unique config entry titles
**Gold** - Advanced Features
- All Silver requirements +
- ✅ Device registry usage
- ✅ Integration diagnostics
- ✅ Device diagnostics
- ✅ Entity category
- ✅ Device class
- ✅ Disabled by default (for noisy entities)
- ✅ Entity translations
- ✅ Exception translations
- ✅ Icon translations
- ✅ Entity_registry_enabled_default
**Platinum** - Highest Quality Standards
- All Gold requirements +
- ✅ Strict typing (full type hints)
- ✅ Async dependencies (no sync-blocking libs)
- ✅ WebSession injection
- ✅ config_entry parameter in coordinator
### How Quality Scale Works
1. **Check manifest.json**: Look for `"quality_scale"` key
```json
{
"quality_scale": "silver"
}
```
2. **Bronze is Mandatory**: ALL Bronze rules must be followed
3. **Higher Tiers Are Additive**: Silver = Bronze + Silver rules
4. **Check quality_scale.yaml**: Shows rule implementation status
```yaml
rules:
config-flow: done
entity-unique-id: done
action-setup:
status: exempt
comment: Integration does not register custom actions.
```
## Architectural Patterns
### Pattern 1: Coordinator-Based Architecture
**Use when**: Polling multiple entities from the same API
```
Integration Structure:
├── __init__.py # Setup coordinator, platforms
├── coordinator.py # Data fetching logic
├── entity.py # Base entity class
├── sensor.py # Sensor entities using coordinator
├── binary_sensor.py # Binary sensor entities
└── config_flow.py # UI configuration
Benefits:
- Single API call updates all entities
- Efficient data sharing
- Built-in error handling
- Automatic availability tracking
```
**Implementation**:
```python
# coordinator.py
class MyCoordinator(DataUpdateCoordinator[MyData]):
def __init__(
self,
hass: HomeAssistant,
client: MyClient,
config_entry: ConfigEntry,
) -> None:
super().__init__(
hass,
logger=LOGGER,
name=DOMAIN,
update_interval=timedelta(minutes=5),
config_entry=config_entry, # ✅ Pass for Platinum
)
self.client = client
async def _async_update_data(self) -> MyData:
try:
return await self.client.fetch_data()
except ApiError as err:
raise UpdateFailed(f"Error: {err}") from err
# __init__.py
async def async_setup_entry(hass: HomeAssistant, entry: MyConfigEntry) -> bool:
coordinator = MyCoordinator(hass, client, entry)
await coordinator.async_config_entry_first_refresh()
entry.runtime_data = coordinator # ✅ Silver requirement
return True
```
### Pattern 2: Push-Based Architecture
**Use when**: Device pushes updates (webhooks, MQTT, WebSocket)
```
Integration Structure:
├── __init__.py # Setup event listeners
├── hub.py # Connection management
├── entity.py # Base entity with event handling
└── sensor.py # Push-updated sensors
Benefits:
- Instant updates
- No polling overhead
- Efficient for real-time data
```
**Implementation**:
```python
# entity.py
class MyEntity(SensorEntity):
async def async_added_to_hass(self) -> None:
"""Subscribe to events when added."""
self.async_on_remove(
self.hub.subscribe_updates(self._handle_update)
)
@callback
def _handle_update(self, data: dict) -> None:
"""Handle push update."""
self._attr_native_value = data["value"]
self.async_write_ha_state()
```
### Pattern 3: Hub with Discovery
**Use when**: Hub device with multiple discoverable endpoints
```
Integration Structure:
├── __init__.py # Hub setup, device discovery
├── coordinator.py # Per-device coordinators
├── hub.py # Hub communication
└── sensor.py # Device entities
Benefits:
- Automatic device addition
- Dynamic topology
- Per-device data updates
```
**Implementation**:
```python
# __init__.py - Dynamic device addition
async def async_setup_entry(hass: HomeAssistant, entry: MyConfigEntry) -> bool:
hub = MyHub(entry.data[CONF_HOST])
coordinator = MyCoordinator(hass, hub, entry)
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
known_devices = set()
@callback
def _check_new_devices() -> None:
"""Check for new devices."""
current = set(coordinator.data.devices.keys())
new = current - known_devices
if new:
known_devices.update(new)
# Notify platforms of new devices
async_dispatcher_send(hass, f"{DOMAIN}_new_device", new)
entry.async_on_unload(coordinator.async_add_listener(_check_new_devices))
return True
```
## Architectural Decision Guide
### Choosing Integration Type
**Device Integration** (`"integration_type": "device"`)
- Physical or virtual devices
- Example: Smart plugs, thermostats, cameras
**Hub Integration** (`"integration_type": "hub"`)
- Central hub controlling multiple devices
- Example: Philips Hue bridge, Z-Wave controller
**Service Integration** (`"integration_type": "service"`)
- Cloud services, APIs
- Example: Weather services, notification platforms
**Helper Integration** (`"integration_type": "helper"`)
- Utility integrations
- Example: Template, group, automation helpers
### Choosing IoT Class
```json
{
"iot_class": "cloud_polling", // API polling
"iot_class": "cloud_push", // Cloud webhooks/MQTT
"iot_class": "local_polling", // Local device polling
"iot_class": "local_push", // Local device push
"iot_class": "calculated" // No external data
}
```
### Discovery Methods
Add to manifest.json when applicable:
```json
{
"zeroconf": ["_mydevice._tcp.local."],
"dhcp": [{"hostname": "mydevice*"}],
"bluetooth": [{"service_uuid": "0000xxxx"}],
"ssdp": [{"st": "urn:schemas-upnp-org:device:MyDevice:1"}],
"usb": [{"vid": "1234", "pid": "5678"}]
}
```
## Quality Scale Progression Strategy
### Starting Bronze (Minimum Viable Integration)
**Essential Components**:
```
homeassistant/components/my_integration/
├── __init__.py # async_setup_entry, async_unload_entry
├── manifest.json # Required fields, quality_scale: "bronze"
├── const.py # DOMAIN constant
├── config_flow.py # UI configuration with reauth/reconfigure
├── sensor.py # Platform with unique IDs
├── strings.json # Translations
└── quality_scale.yaml # Rule tracking
tests/components/my_integration/
├── conftest.py # Test fixtures
├── test_config_flow.py # 100% coverage
└── test_sensor.py # Entity tests
```
**Bronze Checklist**:
- [ ] Config flow with UI setup
- [ ] Reauthentication flow
- [ ] Reconfigure flow
- [ ] All entities have unique IDs
- [ ] Proper setup error handling
- [ ] >95% test coverage
- [ ] 100% config flow coverage
### Progressing to Silver
**Add**:
- Entity unavailability tracking
- Runtime data storage (not hass.data)
- Parallel updates configuration
- Unique entry titles
**Changes**:
```python
# Store in runtime_data (Silver requirement)
entry.runtime_data = coordinator
# Entity availability (Silver requirement)
@property
def available(self) -> bool:
return super().available and self.device_id in self.coordinator.data
# Parallel updates (Silver requirement)
# In platform file
PARALLEL_UPDATES = 0 # For coordinator-based
```
### Progressing to Gold
**Add**:
- Device registry entries
- Integration & device diagnostics
- Entity categories, device classes
- Entity translations
- Exception translations
- Icon translations
**Changes**:
```python
# Device info (Gold requirement)
_attr_device_info = DeviceInfo(
identifiers={(DOMAIN, device.id)},
name=device.name,
manufacturer="Manufacturer",
model="Model",
)
# Diagnostics (Gold requirement)
# Create diagnostics.py
async def async_get_config_entry_diagnostics(
hass: HomeAssistant,
entry: MyConfigEntry,
) -> dict[str, Any]:
return {
"data": async_redact_data(entry.data, TO_REDACT),
"runtime": entry.runtime_data.to_dict(),
}
# Entity translations (Gold requirement)
_attr_translation_key = "temperature"
```
### Progressing to Platinum
**Add**:
- Comprehensive type hints (py.typed)
- Async-only dependencies
- WebSession injection support
**Changes**:
```python
# Type hints (Platinum requirement)
type MyIntegrationConfigEntry = ConfigEntry[MyClient]
async def async_setup_entry(
hass: HomeAssistant,
entry: MyIntegrationConfigEntry,
) -> bool:
"""Set up from config entry."""
# WebSession injection (Platinum requirement)
client = MyClient(
host=entry.data[CONF_HOST],
session=async_get_clientsession(hass),
)
# Pass config_entry to coordinator (Platinum requirement)
coordinator = MyCoordinator(hass, client, entry)
```
## Common Architectural Questions
### Q: Should I use a coordinator?
**Use coordinator when**:
- Polling API for multiple entities
- Want efficient data sharing
- Need coordinated updates
**Don't use coordinator when**:
- Push-based updates (use callbacks)
- Single entity integration
- Each entity has independent data source
### Q: How should I organize entity files?
**Small integrations** (<5 entities per platform):
- Single file per platform: `sensor.py`, `switch.py`
**Large integrations** (>5 entities per platform):
- Create entity definitions file: `entity_descriptions.py`
- Keep platform file simple
### Q: Where should I store runtime data?
```python
# ✅ GOOD - Use runtime_data (Silver+)
entry.runtime_data = coordinator
# ❌ BAD - Don't use hass.data
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator
```
### Q: How do I handle multiple API endpoints?
**Option 1**: Single coordinator with all data
```python
@dataclass
class MyData:
devices: dict[str, Device]
status: SystemStatus
settings: Settings
```
**Option 2**: Multiple coordinators
```python
device_coordinator = DeviceCoordinator(...)
status_coordinator = StatusCoordinator(...)
```
Choose based on:
- Update frequency requirements
- API rate limits
- Data independence
### Q: When should I create devices vs. just entities?
**Create devices when**:
- Representing physical/virtual devices
- Multiple entities belong to same device
- Want grouped device management
**Just entities when**:
- Service integration (no physical device)
- Single entity integration
- Calculated/helper entities
## Reference Files
For detailed implementation guidance, refer to these reference files:
- `diagnostics.md` - Implementing diagnostic data collection
- `sensor.md` - Sensor platform patterns
- `binary_sensor.md` - Binary sensor patterns
- `switch.md` - Switch platform patterns
- `number.md` - Number platform patterns
- `select.md` - Select platform patterns
- `button.md` - Button platform patterns
## Your Task
When providing architectural guidance:
1. **Understand Requirements**
- What is the integration type?
- What data needs to be exposed?
- Is it polling or push-based?
- What quality tier is appropriate?
2. **Recommend Architecture**
- Suggest appropriate patterns
- Identify required components
- Explain architectural decisions
3. **Quality Scale Guidance**
- Recommend starting quality tier
- Identify applicable rules
- Suggest progression path
4. **Implementation Plan**
- Outline file structure
- Identify key components
- Suggest implementation order
5. **Best Practices**
- Performance considerations
- Maintainability tips
- Common pitfalls to avoid
Focus on helping developers understand not just what to build, but why certain architectural choices make sense for their specific use case. Provide clear, actionable guidance that sets them up for long-term success.

View File

@@ -1,77 +0,0 @@
---
name: quality-scale-rule-verifier
description: |
Use this agent when you need to verify that a Home Assistant integration follows a specific quality scale rule. This includes checking if the integration implements required patterns, configurations, or code structures defined by the quality scale system.
<example>
Context: The user wants to verify if an integration follows a specific quality scale rule.
user: "Check if the peblar integration follows the config-flow rule"
assistant: "I'll use the quality scale rule verifier to check if the peblar integration properly implements the config-flow rule."
<commentary>
Since the user is asking to verify a quality scale rule implementation, use the quality-scale-rule-verifier agent.
</commentary>
</example>
<example>
Context: The user is reviewing if an integration reaches a specific quality scale level.
user: "Verify that this integration reaches the bronze quality scale"
assistant: "Let me use the quality scale rule verifier to check the bronze quality scale implementation."
<commentary>
The user wants to verify the integration has reached a certain quality level, so use multiple quality-scale-rule-verifier agents to verify each bronze rule.
</commentary>
</example>
model: inherit
color: yellow
tools: Read, Bash, Grep, Glob, WebFetch
---
You are an expert Home Assistant integration quality scale auditor specializing in verifying compliance with specific quality scale rules. You have deep knowledge of Home Assistant's architecture, best practices, and the quality scale system that ensures integration consistency and reliability.
You will verify if an integration follows a specific quality scale rule by:
1. **Fetching Rule Documentation**: Retrieve the official rule documentation from:
`https://raw.githubusercontent.com/home-assistant/developers.home-assistant/refs/heads/master/docs/core/integration-quality-scale/rules/{rule_name}.md`
where `{rule_name}` is the rule identifier (e.g., 'config-flow', 'entity-unique-id', 'parallel-updates')
2. **Understanding Rule Requirements**: Parse the rule documentation to identify:
- Core requirements and mandatory implementations
- Specific code patterns or configurations required
- Common violations and anti-patterns
- Exemption criteria (when a rule might not apply)
- The quality tier this rule belongs to (Bronze, Silver, Gold, Platinum)
3. **Analyzing Integration Code**: Examine the integration's codebase at `homeassistant/components/<integration domain>` focusing on:
- `manifest.json` for quality scale declaration and configuration
- `quality_scale.yaml` for rule status (done, todo, exempt)
- Relevant Python modules based on the rule requirements
- Configuration files and service definitions as needed
4. **Verification Process**:
- Check if the rule is marked as 'done', 'todo', or 'exempt' in quality_scale.yaml
- If marked 'exempt', verify the exemption reason is valid
- If marked 'done', verify the actual implementation matches requirements
- Identify specific files and code sections that demonstrate compliance or violations
- Consider the integration's declared quality tier when applying rules
- To fetch the integration docs, use WebFetch to fetch from `https://raw.githubusercontent.com/home-assistant/home-assistant.io/refs/heads/current/source/_integrations/<integration domain>.markdown`
- To fetch information about a PyPI package, use the URL `https://pypi.org/pypi/<package>/json`
5. **Reporting Findings**: Provide a comprehensive verification report that includes:
- **Rule Summary**: Brief description of what the rule requires
- **Compliance Status**: Clear pass/fail/exempt determination
- **Evidence**: Specific code examples showing compliance or violations
- **Issues Found**: Detailed list of any non-compliance issues with file locations
- **Recommendations**: Actionable steps to achieve compliance if needed
- **Exemption Analysis**: If applicable, whether the exemption is justified
When examining code, you will:
- Look for exact implementation patterns specified in the rule
- Verify all required components are present and properly configured
- Check for common mistakes and anti-patterns
- Consider edge cases and error handling requirements
- Validate that implementations follow Home Assistant conventions
You will be thorough but focused, examining only the aspects relevant to the specific rule being verified. You will provide clear, actionable feedback that helps developers understand both what needs to be fixed and why it matters for integration quality.
If you cannot access the rule documentation or find the integration code, clearly state what information is missing and what you would need to complete the verification.
Remember that quality scale rules are cumulative - Bronze rules apply to all integrations with a quality scale, Silver rules apply to Silver+ integrations, and so on. Always consider the integration's target quality level when determining which rules should be enforced.

View File

@@ -1,323 +0,0 @@
---
name: testing
description: |
Use this agent when you need to write, run, or fix tests for Home Assistant integrations. This agent specializes in:
- Writing comprehensive test coverage for integrations
- Running pytest with appropriate flags and coverage reports
- Fixing failing tests and updating test snapshots
- Following Home Assistant testing patterns and best practices
- Achieving >95% test coverage requirement
<example>
Context: User wants to write tests for a new integration
user: "Write tests for the new sensor platform"
assistant: "I'll use the testing agent to create comprehensive tests following Home Assistant patterns."
<commentary>
The user needs test implementation, so use the testing agent.
</commentary>
</example>
<example>
Context: Tests are failing after code changes
user: "The config flow tests are failing, can you fix them?"
assistant: "I'll use the testing agent to diagnose and fix the failing tests."
<commentary>
Test debugging and fixing is handled by the testing agent.
</commentary>
</example>
model: inherit
color: green
tools: Read, Write, Edit, Bash, Grep, Glob
---
You are an expert Home Assistant integration test engineer specializing in writing comprehensive, maintainable tests that follow Home Assistant conventions and best practices.
## Your Expertise
You have deep knowledge of:
- pytest framework and fixtures
- Home Assistant test utilities and patterns
- Snapshot testing for entity states
- Mocking external APIs and dependencies
- Config flow testing patterns
- Entity testing patterns
- Achieving high test coverage (>95%)
## Testing Standards
### Coverage Requirements
- **Minimum Coverage**: 95% for all modules
- **Config Flow**: 100% coverage required for all paths
- **Location**: Tests go in `tests/components/{domain}/`
### Test File Organization
```
tests/components/my_integration/
├── __init__.py
├── conftest.py # Fixtures and test setup
├── test_config_flow.py # Config flow tests (100% coverage)
├── test_sensor.py # Sensor platform tests
├── test_init.py # Integration setup tests
└── snapshots/ # Generated snapshot files
```
## Key Testing Patterns
### 1. Modern Fixture Setup Pattern
Always use this pattern for integration tests:
```python
from homeassistant.core import HomeAssistant
from homeassistant.const import Platform
from pytest_homeassistant_custom_component.common import MockConfigEntry
@pytest.fixture
def mock_config_entry() -> MockConfigEntry:
"""Return the default mocked config entry."""
return MockConfigEntry(
title="My Integration",
domain=DOMAIN,
data={CONF_HOST: "127.0.0.1", CONF_API_KEY: "test_key"},
unique_id="device_unique_id",
)
@pytest.fixture
def mock_device_api() -> Generator[MagicMock]:
"""Return a mocked device API."""
with patch("homeassistant.components.my_integration.MyDeviceAPI", autospec=True) as api_mock:
api = api_mock.return_value
api.get_data.return_value = MyDeviceData.from_json(
load_fixture("device_data.json", DOMAIN)
)
yield api
@pytest.fixture
def platforms() -> list[Platform]:
"""Fixture to specify platforms to test."""
return [Platform.SENSOR] # Specify only the platforms you want to test
@pytest.fixture
async def init_integration(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_device_api: MagicMock,
platforms: list[Platform],
) -> MockConfigEntry:
"""Set up the integration for testing."""
mock_config_entry.add_to_hass(hass)
with patch("homeassistant.components.my_integration.PLATFORMS", platforms):
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
return mock_config_entry
```
### 2. Entity Testing with Snapshots
Use snapshot testing for entity verification:
```python
from syrupy import SnapshotAssertion
from homeassistant.helpers import entity_registry as er, device_registry as dr
@pytest.mark.usefixtures("entity_registry_enabled_by_default", "init_integration")
async def test_entities(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
device_registry: dr.DeviceRegistry,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test the sensor entities."""
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
# Verify entities are assigned to device
device_entry = device_registry.async_get_device(
identifiers={(DOMAIN, "device_unique_id")}
)
assert device_entry
entity_entries = er.async_entries_for_config_entry(
entity_registry, mock_config_entry.entry_id
)
for entity_entry in entity_entries:
assert entity_entry.device_id == device_entry.id
```
### 3. Config Flow Testing (100% Coverage Required)
Test ALL paths in config flow:
```python
async def test_user_flow_success(hass, mock_api):
"""Test successful user flow."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["step_id"] == "user"
# Test form submission
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=TEST_USER_INPUT
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["title"] == "My Device"
assert result["data"] == TEST_USER_INPUT
async def test_flow_connection_error(hass, mock_api_error):
"""Test connection error handling."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=TEST_USER_INPUT
)
assert result["type"] == FlowResultType.FORM
assert result["errors"] == {"base": "cannot_connect"}
async def test_flow_duplicate_entry(hass, mock_config_entry, mock_api):
"""Test duplicate entry prevention."""
mock_config_entry.add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=TEST_USER_INPUT
)
assert result["type"] == FlowResultType.ABORT
assert result["reason"] == "already_configured"
```
### 4. Fixture Files
Store API response data in `tests/components/{domain}/fixtures/`:
```json
{
"device_id": "12345",
"name": "My Device",
"temperature": 22.5,
"humidity": 45
}
```
Load with:
```python
from tests.common import load_fixture
data = load_fixture("device_data.json", DOMAIN)
```
## Critical Testing Rules
### NEVER Do These Things
**Don't access `hass.data` directly in tests**
```python
# ❌ BAD
coordinator = hass.data[DOMAIN][entry.entry_id]
```
**Don't test entities in isolation without integration setup**
```python
# ❌ BAD
sensor = MySensor(coordinator, device_id)
sensor.update()
```
**Don't forget to mock external dependencies**
```python
# ❌ BAD - will make real API calls
await hass.config_entries.async_setup(entry.entry_id)
```
### ALWAYS Do These Things
**Use proper integration setup through fixtures**
```python
# ✅ GOOD
@pytest.mark.usefixtures("init_integration")
async def test_sensor(hass):
state = hass.states.get("sensor.my_device_temperature")
assert state.state == "22.5"
```
**Mock all external APIs**
```python
# ✅ GOOD
@pytest.fixture
def mock_api():
with patch("homeassistant.components.my_integration.MyAPI") as mock:
yield mock
```
**Test through the integration's public interface**
```python
# ✅ GOOD
await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
```
## Running Tests
### Integration-Specific Tests (Recommended)
```bash
pytest ./tests/components/<integration_domain> \
--cov=homeassistant.components.<integration_domain> \
--cov-report term-missing \
--durations-min=1 \
--durations=0 \
--numprocesses=auto
```
### Quick Test of Changed Files
```bash
pytest --timeout=10 --picked
```
### Update Test Snapshots
```bash
pytest ./tests/components/<integration_domain> --snapshot-update
```
**⚠️ IMPORTANT**: After using `--snapshot-update`:
1. Run tests again WITHOUT the flag to verify snapshots
2. Review the snapshot changes carefully
3. Don't commit snapshot updates without verification
## Debugging Test Failures
### Enable Debug Logging
```python
def test_something(caplog):
caplog.set_level(logging.DEBUG, logger="homeassistant.components.my_integration")
# Test code here
```
### Common Failure Patterns
1. **"Config entry not loaded"**: Check mock setup and async_block_till_done
2. **"Entity not found"**: Verify entity_registry_enabled_by_default fixture
3. **"Snapshot mismatch"**: Review changes, update if intentional
4. **"Coverage too low"**: Add tests for uncovered branches and error paths
## Test Organization Checklist
When writing tests for an integration, ensure:
- [ ] `conftest.py` with reusable fixtures
- [ ] `test_config_flow.py` with 100% coverage
- [ ] `test_init.py` for setup/unload
- [ ] Platform tests (`test_sensor.py`, etc.)
- [ ] Fixture files for API responses
- [ ] All external dependencies mocked
- [ ] Snapshot tests for entity states
- [ ] Error path coverage
- [ ] >95% total coverage
## Your Task
When testing an integration:
1. **Analyze** the integration code to understand what needs testing
2. **Create** comprehensive test fixtures following modern patterns
3. **Write** tests covering all code paths (>95% coverage)
4. **Run** tests and verify they pass
5. **Update** snapshots if needed (and re-verify)
6. **Report** coverage results and any gaps
Always follow Home Assistant conventions, use modern fixture patterns, and aim for clarity and maintainability in test code.

View File

@@ -1,470 +0,0 @@
# Binary Sensor Platform Reference
## Overview
Binary sensors are read-only entities that represent an on/off, true/false, or open/closed state. They are simpler than regular sensors and don't have units or numeric values.
## Basic Binary Sensor Implementation
```python
"""Binary sensor platform for my_integration."""
from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,
BinarySensorEntity,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import MyConfigEntry
from .coordinator import MyCoordinator
from .entity import MyEntity
async def async_setup_entry(
hass: HomeAssistant,
entry: MyConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up binary sensors."""
coordinator = entry.runtime_data
async_add_entities(
MyBinarySensor(coordinator, device_id)
for device_id in coordinator.data.devices
)
class MyBinarySensor(MyEntity, BinarySensorEntity):
"""Representation of a binary sensor."""
_attr_has_entity_name = True
_attr_translation_key = "motion"
_attr_device_class = BinarySensorDeviceClass.MOTION
def __init__(self, coordinator: MyCoordinator, device_id: str) -> None:
"""Initialize the binary sensor."""
super().__init__(coordinator, device_id)
self._attr_unique_id = f"{device_id}_motion"
@property
def is_on(self) -> bool | None:
"""Return true if motion is detected."""
if device := self.coordinator.data.devices.get(self.device_id):
return device.motion_detected
return None
```
## Binary Sensor State
The core property for binary sensors is `is_on`:
```python
@property
def is_on(self) -> bool | None:
"""Return true if the binary sensor is on."""
return self.device.is_active
# Alternatively, use attribute
_attr_is_on = True # or False, or None
```
**State Meaning**:
- `True` / `"on"` - Active/detected/open
- `False` / `"off"` - Inactive/not detected/closed
- `None` - Unknown (displays as "unavailable")
## Device Classes
Binary sensors should use device classes for proper representation:
```python
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
# Common device classes
_attr_device_class = BinarySensorDeviceClass.MOTION
_attr_device_class = BinarySensorDeviceClass.OCCUPANCY
_attr_device_class = BinarySensorDeviceClass.DOOR
_attr_device_class = BinarySensorDeviceClass.WINDOW
_attr_device_class = BinarySensorDeviceClass.OPENING
_attr_device_class = BinarySensorDeviceClass.CONNECTIVITY
_attr_device_class = BinarySensorDeviceClass.BATTERY
_attr_device_class = BinarySensorDeviceClass.BATTERY_CHARGING
_attr_device_class = BinarySensorDeviceClass.PROBLEM
_attr_device_class = BinarySensorDeviceClass.RUNNING
_attr_device_class = BinarySensorDeviceClass.SMOKE
_attr_device_class = BinarySensorDeviceClass.MOISTURE
_attr_device_class = BinarySensorDeviceClass.LOCK
_attr_device_class = BinarySensorDeviceClass.TAMPER
_attr_device_class = BinarySensorDeviceClass.PLUG
_attr_device_class = BinarySensorDeviceClass.POWER
```
### Device Class Selection Guide
**Detection Sensors**:
- Motion detector → `MOTION`
- Presence detector → `OCCUPANCY`
- Smoke detector → `SMOKE`
- Water leak detector → `MOISTURE`
**Contact Sensors**:
- Door sensor → `DOOR`
- Window sensor → `WINDOW`
- Generic contact → `OPENING`
**Status Sensors**:
- Network connection → `CONNECTIVITY`
- Device running → `RUNNING`
- Low battery → `BATTERY`
- Charging state → `BATTERY_CHARGING`
- Problem/fault → `PROBLEM`
- Tamper detection → `TAMPER`
**Power Sensors**:
- Outlet state → `PLUG`
- Power state → `POWER`
- Lock state → `LOCK`
## Entity Descriptions Pattern
For multiple similar binary sensors:
```python
from dataclasses import dataclass
from collections.abc import Callable
from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,
BinarySensorEntityDescription,
)
@dataclass(frozen=True, kw_only=True)
class MyBinarySensorDescription(BinarySensorEntityDescription):
"""Describes a binary sensor."""
is_on_fn: Callable[[MyData], bool | None]
BINARY_SENSORS: tuple[MyBinarySensorDescription, ...] = (
MyBinarySensorDescription(
key="motion",
translation_key="motion",
device_class=BinarySensorDeviceClass.MOTION,
is_on_fn=lambda data: data.motion_detected,
),
MyBinarySensorDescription(
key="door",
translation_key="door",
device_class=BinarySensorDeviceClass.DOOR,
is_on_fn=lambda data: data.door_open,
),
MyBinarySensorDescription(
key="battery_low",
translation_key="battery_low",
device_class=BinarySensorDeviceClass.BATTERY,
entity_category=EntityCategory.DIAGNOSTIC,
is_on_fn=lambda data: data.battery_level < 20,
),
)
async def async_setup_entry(
hass: HomeAssistant,
entry: MyConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up binary sensors."""
coordinator = entry.runtime_data
async_add_entities(
MyBinarySensor(coordinator, device_id, description)
for device_id in coordinator.data.devices
for description in BINARY_SENSORS
)
class MyBinarySensor(MyEntity, BinarySensorEntity):
"""Binary sensor using entity description."""
entity_description: MyBinarySensorDescription
def __init__(
self,
coordinator: MyCoordinator,
device_id: str,
description: MyBinarySensorDescription,
) -> None:
"""Initialize the binary sensor."""
super().__init__(coordinator, device_id)
self.entity_description = description
self._attr_unique_id = f"{device_id}_{description.key}"
@property
def is_on(self) -> bool | None:
"""Return true if the binary sensor is on."""
if device := self.coordinator.data.devices.get(self.device_id):
return self.entity_description.is_on_fn(device)
return None
```
## Entity Category
Mark diagnostic or configuration binary sensors:
```python
from homeassistant.helpers.entity import EntityCategory
# Diagnostic sensors
_attr_entity_category = EntityCategory.DIAGNOSTIC
# Examples: connectivity, update available, battery low
# Config sensors
_attr_entity_category = EntityCategory.CONFIG
# Examples: configuration status
```
## State Inversion
For some sensors, you may need to invert the logic:
```python
class MyBinarySensor(BinarySensorEntity):
"""Binary sensor with inverted state."""
@property
def is_on(self) -> bool | None:
"""Return true if sensor is on."""
if self.device.is_closed:
return False # Closed = off for door sensor
if self.device.is_open:
return True # Open = on for door sensor
return None
```
## Push-Updated Binary Sensor
For event-driven sensors:
```python
class MyPushBinarySensor(BinarySensorEntity):
"""Push-updated binary sensor."""
_attr_should_poll = False
async def async_added_to_hass(self) -> None:
"""Subscribe to updates when added."""
self.async_on_remove(
self.device.subscribe_state(self._handle_state_update)
)
@callback
def _handle_state_update(self, state: bool) -> None:
"""Handle state update from device."""
self._attr_is_on = state
self.async_write_ha_state()
```
## Testing Binary Sensors
### Snapshot Testing
```python
"""Test binary sensors."""
import pytest
from syrupy import SnapshotAssertion
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_binary_sensors(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
mock_config_entry: MockConfigEntry,
init_integration,
) -> None:
"""Test binary sensor entities."""
await snapshot_platform(
hass,
entity_registry,
snapshot,
mock_config_entry.entry_id,
)
```
### State Testing
```python
async def test_binary_sensor_states(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test binary sensor states."""
await init_integration(hass, mock_config_entry)
# Test on state
state = hass.states.get("binary_sensor.my_device_motion")
assert state
assert state.state == "on"
assert state.attributes["device_class"] == "motion"
# Test off state
state = hass.states.get("binary_sensor.my_device_door")
assert state
assert state.state == "off"
assert state.attributes["device_class"] == "door"
```
## Common Patterns
### Pattern 1: Coordinator-Based
```python
class MyBinarySensor(CoordinatorEntity[MyCoordinator], BinarySensorEntity):
"""Coordinator-based binary sensor."""
_attr_should_poll = False
@property
def is_on(self) -> bool | None:
"""Get state from coordinator data."""
if device := self.coordinator.data.devices.get(self.device_id):
return device.is_active
return None
@property
def available(self) -> bool:
"""Return if entity is available."""
return super().available and self.device_id in self.coordinator.data
```
### Pattern 2: Event-Driven
```python
class MyEventBinarySensor(BinarySensorEntity):
"""Event-driven binary sensor."""
_attr_should_poll = False
async def async_added_to_hass(self) -> None:
"""Subscribe to events."""
self.async_on_remove(
async_dispatcher_connect(
self.hass,
f"{DOMAIN}_event",
self._handle_event,
)
)
@callback
def _handle_event(self, event_type: str, active: bool) -> None:
"""Handle incoming event."""
if event_type == self.event_type:
self._attr_is_on = active
self.async_write_ha_state()
```
### Pattern 3: Calculated/Derived
```python
class MyCalculatedBinarySensor(BinarySensorEntity):
"""Binary sensor calculated from other sensors."""
_attr_should_poll = False
async def async_added_to_hass(self) -> None:
"""Subscribe to source sensors."""
self.async_on_remove(
async_track_state_change_event(
self.hass,
["sensor.temperature", "sensor.humidity"],
self._handle_source_update,
)
)
@callback
def _handle_source_update(self, event: Event) -> None:
"""Recalculate when sources change."""
temp = self.hass.states.get("sensor.temperature")
humidity = self.hass.states.get("sensor.humidity")
if temp and humidity:
# Example: high comfort if temp 20-25 and humidity 30-60
temp_ok = 20 <= float(temp.state) <= 25
humidity_ok = 30 <= float(humidity.state) <= 60
self._attr_is_on = temp_ok and humidity_ok
self.async_write_ha_state()
```
## Best Practices
### ✅ DO
- Use appropriate device classes
- Return `None` for unknown state
- Use `is_on` property (not state)
- Implement unique IDs
- Use entity descriptions for similar sensors
- Mark diagnostic sensors with entity_category
- Use translation keys for entity names
- Handle availability properly
### ❌ DON'T
- Return strings like "on"/"off" from is_on
- Use regular Sensor for binary states
- Hardcode entity names
- Create binary sensors without device classes (when available)
- Use unavailable/unknown as state values
- Block the event loop
- Poll unnecessarily (use coordinator or events)
## Disabled by Default
For less important binary sensors:
```python
class MyConnectivitySensor(BinarySensorEntity):
"""Connectivity sensor - diagnostic."""
_attr_entity_registry_enabled_default = False
_attr_entity_category = EntityCategory.DIAGNOSTIC
_attr_device_class = BinarySensorDeviceClass.CONNECTIVITY
```
## Troubleshooting
### Binary Sensor Not Appearing
Check:
- [ ] Unique ID is set
- [ ] Platform is in PLATFORMS list
- [ ] Entity is added with async_add_entities
- [ ] is_on returns bool or None (not string)
### State Not Updating
Check:
- [ ] Coordinator is updating (if used)
- [ ] Event subscriptions are working
- [ ] is_on returns correct value
- [ ] async_write_ha_state() is called (push updates)
### Wrong Icon
Check:
- [ ] Device class is set correctly
- [ ] Device class matches sensor purpose
- [ ] Icon translations if using Gold tier
## Quality Scale Considerations
- **Bronze**: Unique ID required
- **Gold**: Entity translations, device class, entity category
- **Platinum**: Full type hints
## References
- [Binary Sensor Documentation](https://developers.home-assistant.io/docs/core/entity/binary-sensor)
- [Device Classes](https://www.home-assistant.io/integrations/binary_sensor/#device-class)

View File

@@ -1,459 +0,0 @@
# Button Platform Reference
## Overview
Buttons are entities that trigger an action when pressed. They don't have a state (on/off) and are used for one-time actions like rebooting a device, triggering an update, or running a routine.
## Basic Button Implementation
```python
"""Button platform for my_integration."""
from homeassistant.components.button import ButtonEntity
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import MyConfigEntry
from .coordinator import MyCoordinator
from .entity import MyEntity
async def async_setup_entry(
hass: HomeAssistant,
entry: MyConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up buttons."""
coordinator = entry.runtime_data
async_add_entities(
MyButton(coordinator, device_id)
for device_id in coordinator.data.devices
)
class MyButton(MyEntity, ButtonEntity):
"""Representation of a button."""
_attr_has_entity_name = True
_attr_translation_key = "reboot"
def __init__(self, coordinator: MyCoordinator, device_id: str) -> None:
"""Initialize the button."""
super().__init__(coordinator, device_id)
self._attr_unique_id = f"{device_id}_reboot"
async def async_press(self) -> None:
"""Handle the button press."""
await self.coordinator.client.reboot(self.device_id)
```
## Button Method
The only required method for buttons:
```python
async def async_press(self) -> None:
"""Handle the button press."""
await self.device.trigger_action()
```
**Note**: Buttons don't have state. They only perform an action when pressed.
## Device Class
Buttons can have device classes to indicate their purpose:
```python
from homeassistant.components.button import ButtonDeviceClass
_attr_device_class = ButtonDeviceClass.RESTART
_attr_device_class = ButtonDeviceClass.UPDATE
_attr_device_class = ButtonDeviceClass.IDENTIFY
```
Device classes:
- `RESTART` - Reboot/restart device
- `UPDATE` - Trigger update check or installation
- `IDENTIFY` - Make device identify itself (blink LED, beep, etc.)
## Entity Category
Most buttons are configuration actions:
```python
from homeassistant.helpers.entity import EntityCategory
# Config buttons (device settings/actions)
_attr_entity_category = EntityCategory.CONFIG
# Examples: reboot, reset, identify
# Diagnostic buttons (troubleshooting)
_attr_entity_category = EntityCategory.DIAGNOSTIC
# Examples: test connection, refresh diagnostics
```
## Entity Descriptions Pattern
For multiple buttons:
```python
from dataclasses import dataclass
from collections.abc import Awaitable, Callable
from homeassistant.components.button import ButtonEntityDescription, ButtonDeviceClass
@dataclass(frozen=True, kw_only=True)
class MyButtonDescription(ButtonEntityDescription):
"""Describes a button."""
press_fn: Callable[[MyClient, str], Awaitable[None]]
BUTTONS: tuple[MyButtonDescription, ...] = (
MyButtonDescription(
key="reboot",
translation_key="reboot",
device_class=ButtonDeviceClass.RESTART,
entity_category=EntityCategory.CONFIG,
press_fn=lambda client, device_id: client.reboot(device_id),
),
MyButtonDescription(
key="identify",
translation_key="identify",
device_class=ButtonDeviceClass.IDENTIFY,
entity_category=EntityCategory.CONFIG,
press_fn=lambda client, device_id: client.identify(device_id),
),
MyButtonDescription(
key="check_update",
translation_key="check_update",
device_class=ButtonDeviceClass.UPDATE,
entity_category=EntityCategory.CONFIG,
press_fn=lambda client, device_id: client.check_updates(device_id),
),
)
async def async_setup_entry(
hass: HomeAssistant,
entry: MyConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up buttons."""
coordinator = entry.runtime_data
async_add_entities(
MyButton(coordinator, device_id, description)
for device_id in coordinator.data.devices
for description in BUTTONS
)
class MyButton(MyEntity, ButtonEntity):
"""Button using entity description."""
entity_description: MyButtonDescription
def __init__(
self,
coordinator: MyCoordinator,
device_id: str,
description: MyButtonDescription,
) -> None:
"""Initialize the button."""
super().__init__(coordinator, device_id)
self.entity_description = description
self._attr_unique_id = f"{device_id}_{description.key}"
async def async_press(self) -> None:
"""Handle the button press."""
await self.entity_description.press_fn(
self.coordinator.client,
self.device_id,
)
```
## Common Button Types
### Restart Button
```python
class RestartButton(ButtonEntity):
"""Restart device button."""
_attr_device_class = ButtonDeviceClass.RESTART
_attr_entity_category = EntityCategory.CONFIG
_attr_translation_key = "restart"
async def async_press(self) -> None:
"""Restart the device."""
await self.device.restart()
```
### Update Button
```python
class UpdateButton(ButtonEntity):
"""Trigger update check button."""
_attr_device_class = ButtonDeviceClass.UPDATE
_attr_entity_category = EntityCategory.CONFIG
_attr_translation_key = "check_update"
async def async_press(self) -> None:
"""Check for updates."""
await self.device.check_for_updates()
```
### Identify Button
```python
class IdentifyButton(ButtonEntity):
"""Make device identify itself."""
_attr_device_class = ButtonDeviceClass.IDENTIFY
_attr_entity_category = EntityCategory.CONFIG
_attr_translation_key = "identify"
async def async_press(self) -> None:
"""Trigger device identification."""
await self.device.identify()
```
### Custom Action Button
```python
class CustomButton(ButtonEntity):
"""Custom action button."""
_attr_entity_category = EntityCategory.CONFIG
_attr_translation_key = "run_cycle"
async def async_press(self) -> None:
"""Run cleaning cycle."""
await self.device.start_cleaning_cycle()
```
## State Updates After Press
Buttons trigger coordinator refresh if needed:
```python
async def async_press(self) -> None:
"""Handle press with refresh."""
await self.coordinator.client.reboot(self.device_id)
# Refresh coordinator to update related entities
await self.coordinator.async_request_refresh()
```
## Error Handling
Handle errors appropriately:
```python
from homeassistant.exceptions import HomeAssistantError
async def async_press(self) -> None:
"""Handle press with error handling."""
try:
await self.device.reboot()
except DeviceOfflineError as err:
raise HomeAssistantError(f"Device is offline: {err}") from err
except DeviceError as err:
raise HomeAssistantError(f"Failed to reboot: {err}") from err
```
## Testing Buttons
### Snapshot Testing
```python
"""Test buttons."""
import pytest
from syrupy import SnapshotAssertion
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_buttons(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
mock_config_entry: MockConfigEntry,
init_integration,
) -> None:
"""Test button entities."""
await snapshot_platform(
hass,
entity_registry,
snapshot,
mock_config_entry.entry_id,
)
```
### Press Testing
```python
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS
async def test_button_press(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_device,
) -> None:
"""Test button press."""
await init_integration(hass, mock_config_entry)
# Press button
await hass.services.async_call(
BUTTON_DOMAIN,
SERVICE_PRESS,
{ATTR_ENTITY_ID: "button.my_device_reboot"},
blocking=True,
)
# Verify action was called
mock_device.reboot.assert_called_once()
```
### Error Testing
```python
async def test_button_press_error(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_device,
) -> None:
"""Test button press with error."""
await init_integration(hass, mock_config_entry)
mock_device.reboot.side_effect = DeviceError("Connection failed")
# Press button should raise error
with pytest.raises(HomeAssistantError):
await hass.services.async_call(
BUTTON_DOMAIN,
SERVICE_PRESS,
{ATTR_ENTITY_ID: "button.my_device_reboot"},
blocking=True,
)
```
## Common Patterns
### Pattern 1: Simple Action Button
```python
class SimpleButton(ButtonEntity):
"""Simple button that triggers action."""
async def async_press(self) -> None:
"""Trigger action."""
await self.device.do_something()
```
### Pattern 2: Button with Coordinator Refresh
```python
class RefreshingButton(CoordinatorEntity[MyCoordinator], ButtonEntity):
"""Button that refreshes coordinator."""
async def async_press(self) -> None:
"""Trigger action and refresh."""
await self.coordinator.client.action(self.device_id)
await self.coordinator.async_request_refresh()
```
### Pattern 3: Button with Validation
```python
class ValidatingButton(ButtonEntity):
"""Button with pre-action validation."""
async def async_press(self) -> None:
"""Validate then trigger action."""
if not self.device.is_ready:
raise HomeAssistantError("Device not ready")
await self.device.trigger_action()
```
## Best Practices
### ✅ DO
- Use appropriate device class
- Set entity category (usually CONFIG)
- Handle errors with HomeAssistantError
- Implement unique IDs
- Use translation keys
- Refresh coordinator if state changes
- Provide clear button names/translations
### ❌ DON'T
- Create buttons that track state (use switch instead)
- Poll buttons (they have no state)
- Block the event loop
- Ignore errors silently
- Create buttons without entity category
- Hardcode entity names
- Use buttons for binary controls (use switch)
## Button vs. Switch vs. Service
**Use Button when**:
- One-time action with no state
- Trigger command (reboot, identify)
- User initiates action
**Use Switch when**:
- Binary control (on/off)
- State matters
- Can be turned on and off
**Use Service when**:
- Complex parameters needed
- Multiple related actions
- Integration-wide operations
## Troubleshooting
### Button Not Appearing
Check:
- [ ] Unique ID is set
- [ ] Platform is in PLATFORMS list
- [ ] Entity is added with async_add_entities
- [ ] async_press is implemented
### Button Press Not Working
Check:
- [ ] async_press is async def
- [ ] Not blocking the event loop
- [ ] API client is working
- [ ] Errors are being raised properly
### Button Not in Expected Category
Check:
- [ ] entity_category is set
- [ ] Using correct EntityCategory value
- [ ] Device class is appropriate
## Quality Scale Considerations
- **Bronze**: Unique ID required
- **Gold**: Entity translations, device class, entity category
- **Platinum**: Full type hints
## References
- [Button Documentation](https://developers.home-assistant.io/docs/core/entity/button)
- [Button Integration](https://www.home-assistant.io/integrations/button/)

View File

@@ -1,420 +0,0 @@
# Diagnostics Reference
## Overview
Diagnostics provide a way to collect and export integration data for troubleshooting purposes. This is a **Gold tier** quality scale requirement that helps users and developers debug issues.
## When to Implement Diagnostics
Diagnostics are required for:
- ✅ Gold tier and above integrations
- ✅ Any integration where users might need support
- ✅ Integrations with complex configuration or state
## Diagnostics Types
Home Assistant supports two types of diagnostics:
### 1. Config Entry Diagnostics
Provides data about a specific configuration entry.
**File**: `diagnostics.py` in your integration folder
```python
"""Diagnostics support for My Integration."""
from typing import Any
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr, entity_registry as er
from .const import DOMAIN
TO_REDACT = {
"api_key",
"access_token",
"refresh_token",
"password",
"username",
"email",
"latitude",
"longitude",
}
async def async_get_config_entry_diagnostics(
hass: HomeAssistant,
entry: ConfigEntry,
) -> dict[str, Any]:
"""Return diagnostics for a config entry."""
coordinator = entry.runtime_data
return {
"entry": {
"title": entry.title,
"data": async_redact_data(entry.data, TO_REDACT),
"options": async_redact_data(entry.options, TO_REDACT),
},
"coordinator_data": coordinator.data.to_dict(),
"last_update_success": coordinator.last_update_success,
"last_update": coordinator.last_update_success_time.isoformat()
if coordinator.last_update_success_time
else None,
}
```
### 2. Device Diagnostics
Provides data about a specific device.
```python
async def async_get_device_diagnostics(
hass: HomeAssistant,
entry: ConfigEntry,
device: dr.DeviceEntry,
) -> dict[str, Any]:
"""Return diagnostics for a device."""
coordinator = entry.runtime_data
# Find device identifier
device_id = None
for identifier in device.identifiers:
if identifier[0] == DOMAIN:
device_id = identifier[1]
break
if device_id is None:
return {}
device_data = coordinator.data.devices.get(device_id)
if device_data is None:
return {}
return {
"device_info": {
"id": device_id,
"name": device_data.name,
"model": device_data.model,
"firmware": device_data.firmware_version,
},
"device_data": device_data.to_dict(),
"entities": [
{
"entity_id": entity.entity_id,
"name": entity.name,
"state": hass.states.get(entity.entity_id).state
if (state := hass.states.get(entity.entity_id))
else None,
}
for entity in er.async_entries_for_device(
er.async_get(hass), device.id, include_disabled_entities=True
)
],
}
```
## Data Redaction
**CRITICAL**: Always redact sensitive information!
### What to Redact
Always redact:
- API keys, tokens, secrets
- Passwords, credentials
- Email addresses, usernames
- Precise GPS coordinates (latitude, longitude)
- MAC addresses (sometimes)
- Serial numbers (if sensitive)
- Personal information
### Using async_redact_data
```python
from homeassistant.helpers import async_redact_data
# Basic redaction
data = async_redact_data(entry.data, TO_REDACT)
# With nested redaction
TO_REDACT = {
"api_key",
"auth.password", # Nested key
"user.email", # Nested key
}
# Redacting from multiple sources
diagnostics = {
"config": async_redact_data(entry.data, TO_REDACT),
"options": async_redact_data(entry.options, TO_REDACT),
"coordinator": async_redact_data(coordinator.data, TO_REDACT),
}
```
### Custom Redaction
For complex data structures:
```python
def redact_device_data(data: dict[str, Any]) -> dict[str, Any]:
"""Redact sensitive device data."""
redacted = data.copy()
# Redact specific fields
if "serial_number" in redacted:
redacted["serial_number"] = "**REDACTED**"
# Redact nested structures
if "location" in redacted:
redacted["location"] = {
"city": redacted["location"].get("city"),
# Don't include exact coordinates
}
return redacted
```
## What to Include
### Good Diagnostic Data
Include information helpful for troubleshooting:
- ✅ Integration version/state
- ✅ Configuration (redacted)
- ✅ Coordinator/connection status
- ✅ Device information (model, firmware)
- ✅ API response examples (redacted)
- ✅ Error states
- ✅ Entity states
- ✅ Feature flags/capabilities
### Example Comprehensive Diagnostics
```python
async def async_get_config_entry_diagnostics(
hass: HomeAssistant,
entry: ConfigEntry,
) -> dict[str, Any]:
"""Return diagnostics for a config entry."""
coordinator = entry.runtime_data
return {
# Integration state
"integration": {
"version": coordinator.version,
"entry_id": entry.entry_id,
"title": entry.title,
"state": entry.state,
},
# Configuration (redacted)
"configuration": {
"data": async_redact_data(entry.data, TO_REDACT),
"options": async_redact_data(entry.options, TO_REDACT),
},
# Connection/Coordinator status
"coordinator": {
"last_update_success": coordinator.last_update_success,
"last_update": coordinator.last_update_success_time.isoformat()
if coordinator.last_update_success_time
else None,
"update_interval": coordinator.update_interval.total_seconds(),
"last_exception": str(coordinator.last_exception)
if coordinator.last_exception
else None,
},
# Device/System information
"devices": {
device_id: {
"name": device.name,
"model": device.model,
"firmware": device.firmware,
"features": device.supported_features,
"state": device.state,
}
for device_id, device in coordinator.data.devices.items()
},
# API information (redacted)
"api": {
"endpoint": coordinator.client.endpoint,
"authenticated": coordinator.client.is_authenticated,
"rate_limit_remaining": coordinator.client.rate_limit_remaining,
},
}
```
## Testing Diagnostics
### Test File Structure
```python
"""Test diagnostics."""
from homeassistant.core import HomeAssistant
from pytest_homeassistant_custom_component.common import MockConfigEntry
from tests.components.my_integration import setup_integration
async def test_entry_diagnostics(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_api,
) -> None:
"""Test config entry diagnostics."""
await setup_integration(hass, mock_config_entry)
diagnostics = await get_diagnostics_for_config_entry(
hass, hass_client, mock_config_entry
)
# Verify structure
assert "entry" in diagnostics
assert "coordinator_data" in diagnostics
# Verify redaction
assert "api_key" not in str(diagnostics)
assert "password" not in str(diagnostics)
# Verify useful data is present
assert diagnostics["entry"]["title"] == "My Device"
assert diagnostics["coordinator_data"]["devices"]
async def test_device_diagnostics(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
device_registry: dr.DeviceRegistry,
) -> None:
"""Test device diagnostics."""
await setup_integration(hass, mock_config_entry)
device = device_registry.async_get_device(
identifiers={(DOMAIN, "device_id")}
)
assert device
diagnostics = await get_diagnostics_for_device(
hass, hass_client, mock_config_entry, device
)
# Verify device-specific data
assert diagnostics["device_info"]["id"] == "device_id"
assert "entities" in diagnostics
```
## Common Patterns
### Pattern 1: Coordinator-Based Integration
```python
async def async_get_config_entry_diagnostics(
hass: HomeAssistant,
entry: ConfigEntry,
) -> dict[str, Any]:
"""Return diagnostics for a config entry."""
coordinator = entry.runtime_data
return {
"coordinator": {
"last_update_success": coordinator.last_update_success,
"data": coordinator.data.to_dict(),
}
}
```
### Pattern 2: Multiple Coordinators
```python
async def async_get_config_entry_diagnostics(
hass: HomeAssistant,
entry: ConfigEntry,
) -> dict[str, Any]:
"""Return diagnostics for a config entry."""
data = entry.runtime_data
return {
"device_coordinator": data.device_coordinator.data.to_dict(),
"status_coordinator": data.status_coordinator.data.to_dict(),
}
```
### Pattern 3: Hub with Multiple Devices
```python
async def async_get_config_entry_diagnostics(
hass: HomeAssistant,
entry: ConfigEntry,
) -> dict[str, Any]:
"""Return diagnostics for a config entry."""
hub = entry.runtime_data
return {
"hub": {
"connected": hub.connected,
"version": hub.version,
},
"devices": {
device_id: device.to_dict()
for device_id, device in hub.devices.items()
},
}
```
## Best Practices
### ✅ DO
- Redact all sensitive information
- Include coordinator state and update times
- Provide device/system information
- Include error messages (if present)
- Make data easily readable
- Test that redaction works
- Include API/connection status
### ❌ DON'T
- Include raw passwords, tokens, or API keys
- Include precise GPS coordinates
- Include personal information (emails, names)
- Make diagnostics too large (>1MB)
- Include binary data
- Assume all fields are present (use .get())
- Include sensitive serial numbers
## Troubleshooting
### Diagnostics Not Appearing
Check:
1. File named `diagnostics.py` in integration folder
2. Function named exactly `async_get_config_entry_diagnostics`
3. Proper import of `ConfigEntry` and `HomeAssistant`
4. Integration is loaded successfully
### Redaction Not Working
Check:
1. Using `async_redact_data` from `homeassistant.helpers`
2. Field names match exactly (case-sensitive)
3. Nested fields use dot notation: `"auth.password"`
4. TO_REDACT is a set, not a list
### Device Diagnostics Not Working
Check:
1. Device has proper identifiers
2. Function named exactly `async_get_device_diagnostics`
3. Device parameter is `dr.DeviceEntry`
4. Proper device lookup logic
## Quality Scale Considerations
Diagnostics are required for **Gold tier** integrations:
- Must implement config entry diagnostics
- Should implement device diagnostics (if applicable)
- Must redact all sensitive information
- Should provide comprehensive troubleshooting data
## References
- Quality Scale Rule: `diagnostics`
- Home Assistant Docs: [Integration Diagnostics](https://developers.home-assistant.io/docs/integration_fetching_data)
- Helper Functions: `homeassistant.helpers.redact`

View File

@@ -1,508 +0,0 @@
# Number Platform Reference
## Overview
Number entities allow users to control numeric values within a defined range. They're used for settings like volume, brightness, temperature setpoints, or any numeric configuration parameter.
## Basic Number Implementation
```python
"""Number platform for my_integration."""
from homeassistant.components.number import NumberEntity, NumberMode
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import MyConfigEntry
from .coordinator import MyCoordinator
from .entity import MyEntity
async def async_setup_entry(
hass: HomeAssistant,
entry: MyConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up numbers."""
coordinator = entry.runtime_data
async_add_entities(
MyNumber(coordinator, device_id)
for device_id in coordinator.data.devices
)
class MyNumber(MyEntity, NumberEntity):
"""Representation of a number."""
_attr_has_entity_name = True
_attr_translation_key = "volume"
_attr_native_min_value = 0
_attr_native_max_value = 100
_attr_native_step = 1
def __init__(self, coordinator: MyCoordinator, device_id: str) -> None:
"""Initialize the number."""
super().__init__(coordinator, device_id)
self._attr_unique_id = f"{device_id}_volume"
@property
def native_value(self) -> float | None:
"""Return the current value."""
if device := self.coordinator.data.devices.get(self.device_id):
return device.volume
return None
async def async_set_native_value(self, value: float) -> None:
"""Set new value."""
await self.coordinator.client.set_volume(self.device_id, int(value))
await self.coordinator.async_request_refresh()
```
## Number Properties
### Core Properties
```python
class MyNumber(NumberEntity):
"""Number with all common properties."""
# Basic identification
_attr_has_entity_name = True
_attr_translation_key = "brightness"
_attr_unique_id = "device_123_brightness"
# Value range and step
_attr_native_min_value = 0
_attr_native_max_value = 255
_attr_native_step = 1 # or 0.1 for decimals
# Unit of measurement
_attr_native_unit_of_measurement = PERCENTAGE # or other units
# Display mode
_attr_mode = NumberMode.SLIDER # or NumberMode.BOX, NumberMode.AUTO
# Entity category
_attr_entity_category = EntityCategory.CONFIG
@property
def native_value(self) -> float | None:
"""Return current value."""
return self.device.brightness
async def async_set_native_value(self, value: float) -> None:
"""Set new value."""
await self.device.set_brightness(int(value))
```
### Required Properties
```python
# Minimum value
_attr_native_min_value = 0
# Maximum value
_attr_native_max_value = 100
# Step size (precision)
_attr_native_step = 1 # Integers
_attr_native_step = 0.1 # One decimal place
_attr_native_step = 0.01 # Two decimal places
```
### Current Value
```python
@property
def native_value(self) -> float | None:
"""Return the current value."""
return self.device.current_value
# Or use attribute
_attr_native_value = 50.0
```
### Set Value Method
```python
async def async_set_native_value(self, value: float) -> None:
"""Update to new value."""
await self.device.set_value(value)
# Update state
self._attr_native_value = value
self.async_write_ha_state()
```
## Display Mode
Control how the number is displayed in the UI:
```python
from homeassistant.components.number import NumberMode
# Slider (default for ranges)
_attr_mode = NumberMode.SLIDER
# Input box (better for precise values or large ranges)
_attr_mode = NumberMode.BOX
# Auto (let HA decide based on range)
_attr_mode = NumberMode.AUTO
```
**When to use each**:
- `SLIDER`: Small ranges (0-100), settings like volume/brightness
- `BOX`: Large ranges, precise values, IDs or codes
- `AUTO`: Let Home Assistant decide (default)
## Device Class
Use device classes for proper representation:
```python
from homeassistant.components.number import NumberDeviceClass
# Common device classes
_attr_device_class = NumberDeviceClass.TEMPERATURE
_attr_device_class = NumberDeviceClass.HUMIDITY
_attr_device_class = NumberDeviceClass.VOLTAGE
_attr_device_class = NumberDeviceClass.CURRENT
_attr_device_class = NumberDeviceClass.POWER
_attr_device_class = NumberDeviceClass.BATTERY
_attr_device_class = NumberDeviceClass.DISTANCE
_attr_device_class = NumberDeviceClass.DURATION
```
## Units of Measurement
```python
from homeassistant.const import (
PERCENTAGE,
UnitOfTemperature,
UnitOfTime,
)
# Percentage (0-100)
_attr_native_unit_of_measurement = PERCENTAGE
# Temperature
_attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS
# Time
_attr_native_unit_of_measurement = UnitOfTime.SECONDS
# Custom units
_attr_native_unit_of_measurement = "dB" # Decibels
```
## Entity Descriptions Pattern
For multiple number entities:
```python
from dataclasses import dataclass
from collections.abc import Awaitable, Callable
from homeassistant.components.number import NumberEntityDescription, NumberMode
@dataclass(frozen=True, kw_only=True)
class MyNumberDescription(NumberEntityDescription):
"""Describes a number."""
value_fn: Callable[[MyData], float | None]
set_fn: Callable[[MyClient, str, float], Awaitable[None]]
NUMBERS: tuple[MyNumberDescription, ...] = (
MyNumberDescription(
key="volume",
translation_key="volume",
native_min_value=0,
native_max_value=100,
native_step=1,
native_unit_of_measurement=PERCENTAGE,
mode=NumberMode.SLIDER,
entity_category=EntityCategory.CONFIG,
value_fn=lambda data: data.volume,
set_fn=lambda client, device_id, value: client.set_volume(device_id, int(value)),
),
MyNumberDescription(
key="temperature_setpoint",
translation_key="temperature_setpoint",
device_class=NumberDeviceClass.TEMPERATURE,
native_min_value=16,
native_max_value=30,
native_step=0.5,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
mode=NumberMode.SLIDER,
value_fn=lambda data: data.target_temperature,
set_fn=lambda client, device_id, value: client.set_temperature(device_id, value),
),
)
class MyNumber(MyEntity, NumberEntity):
"""Number using entity description."""
entity_description: MyNumberDescription
def __init__(
self,
coordinator: MyCoordinator,
device_id: str,
description: MyNumberDescription,
) -> None:
"""Initialize the number."""
super().__init__(coordinator, device_id)
self.entity_description = description
self._attr_unique_id = f"{device_id}_{description.key}"
@property
def native_value(self) -> float | None:
"""Return current value."""
if device := self.coordinator.data.devices.get(self.device_id):
return self.entity_description.value_fn(device)
return None
async def async_set_native_value(self, value: float) -> None:
"""Set new value."""
await self.entity_description.set_fn(
self.coordinator.client,
self.device_id,
value,
)
await self.coordinator.async_request_refresh()
```
## Value Validation
Home Assistant validates against min/max/step, but you can add custom validation:
```python
async def async_set_native_value(self, value: float) -> None:
"""Set value with custom validation."""
# Custom validation
if value % 5 != 0:
raise ValueError("Value must be multiple of 5")
await self.device.set_value(value)
await self.coordinator.async_request_refresh()
```
## State Update Patterns
### Pattern 1: Optimistic Update
```python
async def async_set_native_value(self, value: float) -> None:
"""Set value with optimistic update."""
# Update immediately
self._attr_native_value = value
self.async_write_ha_state()
try:
await self.device.set_value(value)
except DeviceError:
# Revert on error
await self.coordinator.async_request_refresh()
raise
```
### Pattern 2: Coordinator Refresh
```python
async def async_set_native_value(self, value: float) -> None:
"""Set value and refresh."""
await self.device.set_value(value)
# Get actual value from device
await self.coordinator.async_request_refresh()
```
### Pattern 3: Direct State Update
```python
async def async_set_native_value(self, value: float) -> None:
"""Set value with direct state update."""
new_value = await self.device.set_value(value)
# Device returns actual value
self._attr_native_value = new_value
self.async_write_ha_state()
```
## Testing Numbers
### Snapshot Testing
```python
"""Test numbers."""
import pytest
from syrupy import SnapshotAssertion
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_numbers(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
mock_config_entry: MockConfigEntry,
init_integration,
) -> None:
"""Test number entities."""
await snapshot_platform(
hass,
entity_registry,
snapshot,
mock_config_entry.entry_id,
)
```
### Value Testing
```python
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.components.number import (
ATTR_VALUE,
DOMAIN as NUMBER_DOMAIN,
SERVICE_SET_VALUE,
)
async def test_set_value(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_device,
) -> None:
"""Test setting number value."""
await init_integration(hass, mock_config_entry)
# Check initial value
state = hass.states.get("number.my_device_volume")
assert state
assert state.state == "50"
assert state.attributes["min"] == 0
assert state.attributes["max"] == 100
assert state.attributes["step"] == 1
# Set new value
await hass.services.async_call(
NUMBER_DOMAIN,
SERVICE_SET_VALUE,
{
ATTR_ENTITY_ID: "number.my_device_volume",
ATTR_VALUE: 75,
},
blocking=True,
)
mock_device.set_volume.assert_called_once_with(75)
# Verify state updated
state = hass.states.get("number.my_device_volume")
assert state.state == "75"
```
## Common Number Types
### Volume Control
```python
class VolumeNumber(NumberEntity):
"""Volume control."""
_attr_native_min_value = 0
_attr_native_max_value = 100
_attr_native_step = 1
_attr_native_unit_of_measurement = PERCENTAGE
_attr_mode = NumberMode.SLIDER
```
### Temperature Setpoint
```python
class TemperatureNumber(NumberEntity):
"""Temperature setpoint."""
_attr_device_class = NumberDeviceClass.TEMPERATURE
_attr_native_min_value = 16.0
_attr_native_max_value = 30.0
_attr_native_step = 0.5
_attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS
_attr_mode = NumberMode.SLIDER
```
### Duration Setting
```python
class DurationNumber(NumberEntity):
"""Duration setting."""
_attr_device_class = NumberDeviceClass.DURATION
_attr_native_min_value = 0
_attr_native_max_value = 3600
_attr_native_step = 60 # 1 minute steps
_attr_native_unit_of_measurement = UnitOfTime.SECONDS
_attr_mode = NumberMode.BOX
```
## Best Practices
### ✅ DO
- Set appropriate min/max/step values
- Use device class when available
- Use standard units
- Set display mode appropriately
- Implement unique IDs
- Use translation keys
- Mark config numbers with entity_category
- Handle value updates properly
### ❌ DON'T
- Allow invalid ranges (min > max)
- Use zero or negative step
- Block the event loop
- Ignore validation errors
- Create numbers without min/max/step
- Hardcode entity names
- Use for binary values (use switch)
- Use for selection from list (use select)
## Troubleshooting
### Number Not Appearing
Check:
- [ ] Unique ID is set
- [ ] Platform is in PLATFORMS list
- [ ] min/max/step are all set
- [ ] Entity is added with async_add_entities
### Value Not Updating
Check:
- [ ] async_set_native_value is called
- [ ] Coordinator refresh is working
- [ ] native_value returns correct value
- [ ] Value is within min/max range
### UI Shows Wrong Control Type
Check:
- [ ] mode is set correctly
- [ ] Range is appropriate for mode
- [ ] Step size is reasonable
## Quality Scale Considerations
- **Bronze**: Unique ID required
- **Gold**: Entity translations, device class, entity category
- **Platinum**: Full type hints
## References
- [Number Documentation](https://developers.home-assistant.io/docs/core/entity/number)
- [Number Integration](https://www.home-assistant.io/integrations/number/)

View File

@@ -1,520 +0,0 @@
# Select Platform Reference
## Overview
Select entities allow users to choose from a predefined list of options. They're used for settings like operation modes, presets, input sources, or any configuration with a fixed set of choices.
## Basic Select Implementation
```python
"""Select platform for my_integration."""
from homeassistant.components.select import SelectEntity
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import MyConfigEntry
from .coordinator import MyCoordinator
from .entity import MyEntity
async def async_setup_entry(
hass: HomeAssistant,
entry: MyConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up selects."""
coordinator = entry.runtime_data
async_add_entities(
MySelect(coordinator, device_id)
for device_id in coordinator.data.devices
)
class MySelect(MyEntity, SelectEntity):
"""Representation of a select."""
_attr_has_entity_name = True
_attr_translation_key = "operation_mode"
_attr_options = ["auto", "cool", "heat", "fan"]
def __init__(self, coordinator: MyCoordinator, device_id: str) -> None:
"""Initialize the select."""
super().__init__(coordinator, device_id)
self._attr_unique_id = f"{device_id}_mode"
@property
def current_option(self) -> str | None:
"""Return the current selected option."""
if device := self.coordinator.data.devices.get(self.device_id):
return device.mode
return None
async def async_select_option(self, option: str) -> None:
"""Change the selected option."""
await self.coordinator.client.set_mode(self.device_id, option)
await self.coordinator.async_request_refresh()
```
## Select Properties
### Core Properties
```python
class MySelect(SelectEntity):
"""Select with all common properties."""
# Basic identification
_attr_has_entity_name = True
_attr_translation_key = "preset"
_attr_unique_id = "device_123_preset"
# Available options (required)
_attr_options = ["comfort", "eco", "away", "sleep"]
# Entity category
_attr_entity_category = EntityCategory.CONFIG
@property
def current_option(self) -> str | None:
"""Return current selected option."""
return self.device.preset
async def async_select_option(self, option: str) -> None:
"""Set the selected option."""
await self.device.set_preset(option)
```
### Required Properties and Methods
```python
# List of available options
_attr_options = ["option1", "option2", "option3"]
# Current selected option
@property
def current_option(self) -> str | None:
"""Return the selected option."""
return self.device.current_mode
# Or use attribute
_attr_current_option = "option1"
# Method to change option
async def async_select_option(self, option: str) -> None:
"""Change the selected option."""
await self.device.set_option(option)
```
## Using Enums for Options
Recommended pattern for type safety:
```python
from enum import StrEnum
class OperationMode(StrEnum):
"""Operation modes."""
AUTO = "auto"
COOL = "cool"
HEAT = "heat"
FAN = "fan"
class MySelect(SelectEntity):
"""Select using enum."""
_attr_options = [mode.value for mode in OperationMode]
@property
def current_option(self) -> str | None:
"""Return current mode."""
if device := self.coordinator.data.devices.get(self.device_id):
return device.mode
return None
async def async_select_option(self, option: str) -> None:
"""Set mode."""
# Validate option is in enum
mode = OperationMode(option)
await self.coordinator.client.set_mode(self.device_id, mode)
await self.coordinator.async_request_refresh()
```
## Entity Descriptions Pattern
For multiple select entities:
```python
from dataclasses import dataclass
from collections.abc import Awaitable, Callable
from homeassistant.components.select import SelectEntityDescription
@dataclass(frozen=True, kw_only=True)
class MySelectDescription(SelectEntityDescription):
"""Describes a select."""
current_fn: Callable[[MyData], str | None]
select_fn: Callable[[MyClient, str, str], Awaitable[None]]
SELECTS: tuple[MySelectDescription, ...] = (
MySelectDescription(
key="mode",
translation_key="operation_mode",
options=["auto", "cool", "heat", "fan"],
entity_category=EntityCategory.CONFIG,
current_fn=lambda data: data.mode,
select_fn=lambda client, device_id, option: client.set_mode(device_id, option),
),
MySelectDescription(
key="preset",
translation_key="preset",
options=["comfort", "eco", "away", "sleep"],
entity_category=EntityCategory.CONFIG,
current_fn=lambda data: data.preset,
select_fn=lambda client, device_id, option: client.set_preset(device_id, option),
),
)
async def async_setup_entry(
hass: HomeAssistant,
entry: MyConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up selects."""
coordinator = entry.runtime_data
async_add_entities(
MySelect(coordinator, device_id, description)
for device_id in coordinator.data.devices
for description in SELECTS
)
class MySelect(MyEntity, SelectEntity):
"""Select using entity description."""
entity_description: MySelectDescription
def __init__(
self,
coordinator: MyCoordinator,
device_id: str,
description: MySelectDescription,
) -> None:
"""Initialize the select."""
super().__init__(coordinator, device_id)
self.entity_description = description
self._attr_unique_id = f"{device_id}_{description.key}"
@property
def current_option(self) -> str | None:
"""Return current option."""
if device := self.coordinator.data.devices.get(self.device_id):
return self.entity_description.current_fn(device)
return None
async def async_select_option(self, option: str) -> None:
"""Select option."""
await self.entity_description.select_fn(
self.coordinator.client,
self.device_id,
option,
)
await self.coordinator.async_request_refresh()
```
## Dynamic Options
If options change based on device state:
```python
class MyDynamicSelect(SelectEntity):
"""Select with dynamic options."""
@property
def options(self) -> list[str]:
"""Return available options based on device state."""
if device := self.coordinator.data.devices.get(self.device_id):
return device.available_modes
return []
@property
def current_option(self) -> str | None:
"""Return current option."""
if device := self.coordinator.data.devices.get(self.device_id):
return device.current_mode
return None
async def async_select_option(self, option: str) -> None:
"""Select option."""
await self.device.set_mode(option)
await self.coordinator.async_request_refresh()
```
## Option Translation
Use translation keys for user-friendly option labels:
```json
// strings.json
{
"entity": {
"select": {
"operation_mode": {
"name": "Operation mode",
"state": {
"auto": "Automatic",
"cool": "Cooling",
"heat": "Heating",
"fan": "Fan only"
}
}
}
}
}
```
```python
class MySelect(SelectEntity):
"""Select with translated options."""
_attr_translation_key = "operation_mode"
_attr_options = ["auto", "cool", "heat", "fan"]
```
## State Update Patterns
### Pattern 1: Optimistic Update
```python
async def async_select_option(self, option: str) -> None:
"""Select option with optimistic update."""
# Update immediately
self._attr_current_option = option
self.async_write_ha_state()
try:
await self.device.set_option(option)
except DeviceError:
# Revert on error
await self.coordinator.async_request_refresh()
raise
```
### Pattern 2: Coordinator Refresh
```python
async def async_select_option(self, option: str) -> None:
"""Select option and refresh."""
await self.device.set_option(option)
# Get actual option from device
await self.coordinator.async_request_refresh()
```
### Pattern 3: Direct State Update
```python
async def async_select_option(self, option: str) -> None:
"""Select option with direct state update."""
actual_option = await self.device.set_option(option)
# Device returns actual option
self._attr_current_option = actual_option
self.async_write_ha_state()
```
## Testing Selects
### Snapshot Testing
```python
"""Test selects."""
import pytest
from syrupy import SnapshotAssertion
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_selects(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
mock_config_entry: MockConfigEntry,
init_integration,
) -> None:
"""Test select entities."""
await snapshot_platform(
hass,
entity_registry,
snapshot,
mock_config_entry.entry_id,
)
```
### Option Selection Testing
```python
from homeassistant.const import ATTR_ENTITY_ID, ATTR_OPTION
from homeassistant.components.select import DOMAIN as SELECT_DOMAIN, SERVICE_SELECT_OPTION
async def test_select_option(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_device,
) -> None:
"""Test selecting an option."""
await init_integration(hass, mock_config_entry)
# Check initial state
state = hass.states.get("select.my_device_mode")
assert state
assert state.state == "auto"
assert state.attributes["options"] == ["auto", "cool", "heat", "fan"]
# Select new option
await hass.services.async_call(
SELECT_DOMAIN,
SERVICE_SELECT_OPTION,
{
ATTR_ENTITY_ID: "select.my_device_mode",
ATTR_OPTION: "cool",
},
blocking=True,
)
mock_device.set_mode.assert_called_once_with("cool")
# Verify state updated
state = hass.states.get("select.my_device_mode")
assert state.state == "cool"
```
## Common Select Types
### Operation Mode
```python
class ModeSelect(SelectEntity):
"""Operation mode select."""
_attr_translation_key = "operation_mode"
_attr_options = ["auto", "cool", "heat", "fan", "dry"]
_attr_entity_category = EntityCategory.CONFIG
```
### Preset
```python
class PresetSelect(SelectEntity):
"""Preset select."""
_attr_translation_key = "preset"
_attr_options = ["comfort", "eco", "away", "sleep", "boost"]
_attr_entity_category = EntityCategory.CONFIG
```
### Input Source
```python
class InputSourceSelect(SelectEntity):
"""Input source select."""
_attr_translation_key = "source"
_attr_options = ["hdmi1", "hdmi2", "usb", "bluetooth", "optical"]
```
### Effect/Scene
```python
class EffectSelect(SelectEntity):
"""Light effect select."""
_attr_translation_key = "effect"
_attr_options = ["none", "rainbow", "pulse", "strobe", "breathe"]
```
## Best Practices
### ✅ DO
- Use enums for type safety
- Provide translation keys for options
- Validate selected options
- Implement unique IDs
- Use entity_category for config selects
- Keep option lists reasonable (<20 items)
- Use consistent option naming (lowercase, underscores)
- Provide clear option translations
### ❌ DON'T
- Accept options not in the list
- Have too many options (use input_select helper instead)
- Block the event loop
- Hardcode entity names
- Change options list arbitrarily
- Use for numeric values (use number entity)
- Use for binary choices (use switch)
- Have empty options list
## Select vs. Other Entities
**Use Select when**:
- Fixed list of text options
- Modes, presets, or settings
- 2-20 options
**Use Switch when**:
- Binary on/off control
- Only 2 states
**Use Number when**:
- Numeric range
- Continuous values
**Use Input Select when**:
- User-defined options
- Need dynamic option list
- Helper/template integration
## Troubleshooting
### Select Not Appearing
Check:
- [ ] Unique ID is set
- [ ] Platform is in PLATFORMS list
- [ ] options list is not empty
- [ ] Entity is added with async_add_entities
### Option Not Accepted
Check:
- [ ] Option is in options list (case-sensitive)
- [ ] Options list is properly formatted
- [ ] async_select_option handles the option
### Options Not Translating
Check:
- [ ] translation_key is set
- [ ] strings.json has state translations
- [ ] Option keys match exactly
## Quality Scale Considerations
- **Bronze**: Unique ID required
- **Gold**: Entity translations, entity category
- **Platinum**: Full type hints, use StrEnum for options
## References
- [Select Documentation](https://developers.home-assistant.io/docs/core/entity/select)
- [Select Integration](https://www.home-assistant.io/integrations/select/)

View File

@@ -1,560 +0,0 @@
# Sensor Platform Reference
## Overview
Sensors are read-only entities that represent measurements, states, or information from devices and services. They display numeric values, strings, timestamps, or other data types.
## Basic Sensor Implementation
### Minimal Sensor
```python
"""Sensor platform for my_integration."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import MyConfigEntry
from .const import DOMAIN
from .coordinator import MyCoordinator
from .entity import MyEntity
async def async_setup_entry(
hass: HomeAssistant,
entry: MyConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up sensors."""
coordinator = entry.runtime_data
async_add_entities(
MySensor(coordinator, device_id)
for device_id in coordinator.data.devices
)
class MySensor(MyEntity, SensorEntity):
"""Representation of a sensor."""
def __init__(self, coordinator: MyCoordinator, device_id: str) -> None:
"""Initialize the sensor."""
super().__init__(coordinator, device_id)
self._attr_unique_id = f"{device_id}_temperature"
self._attr_translation_key = "temperature"
@property
def native_value(self) -> float | None:
"""Return the sensor value."""
if device := self.coordinator.data.devices.get(self.device_id):
return device.temperature
return None
```
## Sensor Properties
### Core Properties
```python
class MySensor(SensorEntity):
"""Sensor with all common properties."""
# Basic identification
_attr_has_entity_name = True # Required
_attr_translation_key = "temperature" # For translations
_attr_unique_id = "device_123_temp" # Required
# Device class and units
_attr_device_class = SensorDeviceClass.TEMPERATURE
_attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS
_attr_suggested_display_precision = 1 # Decimal places
# State class for statistics
_attr_state_class = SensorStateClass.MEASUREMENT
# Entity category
_attr_entity_category = EntityCategory.DIAGNOSTIC # If diagnostic
# Availability
_attr_entity_registry_enabled_default = False # If noisy/less important
@property
def native_value(self) -> float | None:
"""Return sensor value."""
return self.device.temperature
@property
def available(self) -> bool:
"""Return if entity is available."""
return super().available and self.device_id in self.coordinator.data
```
## Device Classes
Use device classes for proper representation:
```python
from homeassistant.components.sensor import SensorDeviceClass
# Common device classes
_attr_device_class = SensorDeviceClass.TEMPERATURE
_attr_device_class = SensorDeviceClass.HUMIDITY
_attr_device_class = SensorDeviceClass.PRESSURE
_attr_device_class = SensorDeviceClass.BATTERY
_attr_device_class = SensorDeviceClass.ENERGY
_attr_device_class = SensorDeviceClass.POWER
_attr_device_class = SensorDeviceClass.VOLTAGE
_attr_device_class = SensorDeviceClass.CURRENT
_attr_device_class = SensorDeviceClass.TIMESTAMP
_attr_device_class = SensorDeviceClass.MONETARY
```
Benefits:
- Automatic unit conversion
- Proper UI representation
- Voice assistant integration
- Historical statistics
## State Classes
For long-term statistics support:
```python
from homeassistant.components.sensor import SensorStateClass
# Measurement - value at a point in time
_attr_state_class = SensorStateClass.MEASUREMENT
# Examples: temperature, humidity, power
# Total - cumulative value that can increase/decrease
_attr_state_class = SensorStateClass.TOTAL
# Examples: energy consumed, data transferred
# Use with last_reset for resettable totals
# Total increasing - cumulative value that only increases
_attr_state_class = SensorStateClass.TOTAL_INCREASING
# Examples: lifetime energy, odometer
```
### When to Use State Classes
**Use MEASUREMENT for**:
- Temperature, humidity, pressure
- Current power usage
- Instantaneous values
**Use TOTAL for**:
- Daily/monthly energy consumption (resets)
- Periodic counters
**Use TOTAL_INCREASING for**:
- Lifetime energy consumption
- Monotonically increasing counters
**Don't use state class for**:
- Text/string sensors
- Status sensors (enum values)
- Non-numeric sensors
## Unit of Measurement
### Using Standard Units
```python
from homeassistant.const import (
UnitOfTemperature,
UnitOfPower,
UnitOfEnergy,
PERCENTAGE,
)
# Temperature
_attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS
# Auto-converts to user's preference (°F/°C/K)
# Power
_attr_native_unit_of_measurement = UnitOfPower.WATT
# Energy
_attr_native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR
# Percentage
_attr_native_unit_of_measurement = PERCENTAGE
```
### Custom Units
```python
# For non-standard units
_attr_native_unit_of_measurement = "AQI" # Air Quality Index
_attr_native_unit_of_measurement = "ppm" # Parts per million
```
## Entity Descriptions Pattern
For multiple similar sensors, use SensorEntityDescription:
```python
from dataclasses import dataclass
from homeassistant.components.sensor import SensorEntityDescription
from homeassistant.helpers.typing import StateType
@dataclass(frozen=True, kw_only=True)
class MySensorDescription(SensorEntityDescription):
"""Describes a sensor."""
value_fn: Callable[[MyData], StateType]
SENSORS: tuple[MySensorDescription, ...] = (
MySensorDescription(
key="temperature",
translation_key="temperature",
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda data: data.temperature,
),
MySensorDescription(
key="humidity",
translation_key="humidity",
device_class=SensorDeviceClass.HUMIDITY,
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda data: data.humidity,
),
)
class MySensor(MyEntity, SensorEntity):
"""Sensor using entity description."""
entity_description: MySensorDescription
def __init__(
self,
coordinator: MyCoordinator,
description: MySensorDescription,
device_id: str,
) -> None:
"""Initialize the sensor."""
super().__init__(coordinator, device_id)
self.entity_description = description
self._attr_unique_id = f"{device_id}_{description.key}"
@property
def native_value(self) -> StateType:
"""Return the sensor value."""
if device := self.coordinator.data.devices.get(self.device_id):
return self.entity_description.value_fn(device)
return None
```
### Lambda Functions in EntityDescription
When lambdas get long, use proper formatting:
```python
# ❌ Bad - too long
SensorEntityDescription(
key="temperature",
value_fn=lambda data: round(data["temp_value"] * 1.8 + 32, 1) if data.get("temp_value") is not None else None,
)
# ✅ Good - wrapped properly
SensorEntityDescription(
key="temperature",
value_fn=lambda data: (
round(data["temp_value"] * 1.8 + 32, 1)
if data.get("temp_value") is not None
else None
),
)
```
## Timestamp Sensors
For datetime values:
```python
from datetime import datetime
from homeassistant.components.sensor import SensorDeviceClass
class MyTimestampSensor(SensorEntity):
"""Timestamp sensor."""
_attr_device_class = SensorDeviceClass.TIMESTAMP
@property
def native_value(self) -> datetime | None:
"""Return timestamp."""
return self.device.last_update
```
## Enum Sensors
For sensors with fixed set of possible values:
```python
from enum import StrEnum
from homeassistant.components.sensor import SensorEntity
class OperationMode(StrEnum):
"""Operation modes."""
AUTO = "auto"
MANUAL = "manual"
ECO = "eco"
class MyModeSensor(SensorEntity):
"""Mode sensor."""
_attr_device_class = SensorDeviceClass.ENUM
_attr_options = [mode.value for mode in OperationMode]
@property
def native_value(self) -> str | None:
"""Return current mode."""
return self.device.mode
```
## Entity Category
Mark diagnostic or configuration sensors:
```python
from homeassistant.helpers.entity import EntityCategory
# Diagnostic sensors (technical info)
_attr_entity_category = EntityCategory.DIAGNOSTIC
# Examples: signal strength, uptime, IP address
# Config sensors (device settings)
_attr_entity_category = EntityCategory.CONFIG
# Examples: current mode setting, configuration values
```
## Disabled by Default
For noisy or less important sensors:
```python
class MySignalStrengthSensor(SensorEntity):
"""Signal strength sensor - noisy."""
_attr_entity_registry_enabled_default = False
```
## Dynamic Sensor Addition
For devices that appear after setup:
```python
async def async_setup_entry(
hass: HomeAssistant,
entry: MyConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up sensors with dynamic addition."""
coordinator = entry.runtime_data
known_devices: set[str] = set()
@callback
def _add_new_devices() -> None:
"""Add newly discovered devices."""
current_devices = set(coordinator.data.devices.keys())
new_devices = current_devices - known_devices
if new_devices:
known_devices.update(new_devices)
async_add_entities(
MySensor(coordinator, device_id)
for device_id in new_devices
)
# Initial setup
_add_new_devices()
# Listen for new devices
entry.async_on_unload(coordinator.async_add_listener(_add_new_devices))
```
## Testing Sensors
### Test with Snapshots
```python
"""Test sensors."""
import pytest
from syrupy import SnapshotAssertion
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from tests.common import MockConfigEntry
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensors(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
mock_config_entry: MockConfigEntry,
init_integration,
) -> None:
"""Test sensor entities."""
await snapshot_platform(
hass,
entity_registry,
snapshot,
mock_config_entry.entry_id,
)
```
### Test Sensor Values
```python
async def test_sensor_values(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test sensor values are correct."""
await init_integration(hass, mock_config_entry)
state = hass.states.get("sensor.my_device_temperature")
assert state
assert state.state == "22.5"
assert state.attributes["unit_of_measurement"] == "°C"
assert state.attributes["device_class"] == "temperature"
```
## Best Practices
### ✅ DO
- Use device classes when available
- Set state classes for statistics
- Use standard units of measurement
- Implement unique IDs
- Use entity descriptions for similar sensors
- Mark diagnostic sensors with entity_category
- Disable noisy sensors by default
- Return None for unknown values
- Use translation keys for entity names
### ❌ DON'T
- Hardcode entity names
- Use string "unavailable" or "unknown" as state
- Mix units (always use native_unit_of_measurement)
- Create sensors without unique IDs
- Poll in sensor update if using coordinator
- Block the event loop
- Use state class for non-numeric sensors
## Common Patterns
### Pattern 1: Coordinator-Based Sensor
```python
class MySensor(CoordinatorEntity[MyCoordinator], SensorEntity):
"""Coordinator-based sensor."""
_attr_should_poll = False # Coordinator handles updates
@property
def native_value(self) -> StateType:
"""Get value from coordinator data."""
return self.coordinator.data.get(self.key)
```
### Pattern 2: Push-Updated Sensor
```python
class MyPushSensor(SensorEntity):
"""Push-updated sensor."""
_attr_should_poll = False
async def async_added_to_hass(self) -> None:
"""Subscribe to updates."""
self.async_on_remove(
self.device.subscribe(self._handle_update)
)
@callback
def _handle_update(self, value: float) -> None:
"""Handle push update."""
self._attr_native_value = value
self.async_write_ha_state()
```
### Pattern 3: Calculated Sensor
```python
class MyCalculatedSensor(SensorEntity):
"""Calculated from other sensors."""
_attr_should_poll = False
async def async_added_to_hass(self) -> None:
"""Subscribe to source sensors."""
self.async_on_remove(
async_track_state_change_event(
self.hass,
["sensor.source1", "sensor.source2"],
self._handle_update,
)
)
@callback
def _handle_update(self, event: Event) -> None:
"""Recalculate when sources change."""
# Calculate new value
self._attr_native_value = self._calculate()
self.async_write_ha_state()
```
## Troubleshooting
### Sensor Not Appearing
Check:
- [ ] Unique ID is set
- [ ] Platform is in PLATFORMS list
- [ ] async_setup_entry is called
- [ ] Entity is added with async_add_entities
### Values Not Updating
Check:
- [ ] Coordinator is updating
- [ ] Entity is available
- [ ] native_value returns correct data
- [ ] should_poll is False for coordinator
### Units Not Converting
Check:
- [ ] Using standard unit constants
- [ ] Device class is set correctly
- [ ] Unit matches device class
### Statistics Not Working
Check:
- [ ] State class is set
- [ ] Values are numeric
- [ ] Device class is appropriate
- [ ] Units are consistent
## Quality Scale Considerations
- **Bronze**: Unique ID required
- **Gold**: Entity translations, device class, entity category
- **Platinum**: Full type hints
## References
- [Sensor Documentation](https://developers.home-assistant.io/docs/core/entity/sensor)
- [Device Classes](https://www.home-assistant.io/integrations/sensor/#device-class)
- [State Classes](https://developers.home-assistant.io/docs/core/entity/sensor/#available-state-classes)

View File

@@ -1,505 +0,0 @@
# Switch Platform Reference
## Overview
Switches are entities that can be turned on or off. They represent controllable devices like smart plugs, relays, or any binary control. Unlike binary sensors, switches can be controlled by the user.
## Basic Switch Implementation
```python
"""Switch platform for my_integration."""
from typing import Any
from homeassistant.components.switch import SwitchEntity
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import MyConfigEntry
from .coordinator import MyCoordinator
from .entity import MyEntity
async def async_setup_entry(
hass: HomeAssistant,
entry: MyConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up switches."""
coordinator = entry.runtime_data
async_add_entities(
MySwitch(coordinator, device_id)
for device_id in coordinator.data.devices
)
class MySwitch(MyEntity, SwitchEntity):
"""Representation of a switch."""
_attr_has_entity_name = True
_attr_translation_key = "outlet"
def __init__(self, coordinator: MyCoordinator, device_id: str) -> None:
"""Initialize the switch."""
super().__init__(coordinator, device_id)
self._attr_unique_id = f"{device_id}_switch"
@property
def is_on(self) -> bool | None:
"""Return true if switch is on."""
if device := self.coordinator.data.devices.get(self.device_id):
return device.is_on
return None
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the switch on."""
await self.coordinator.client.turn_on(self.device_id)
await self.coordinator.async_request_refresh()
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the switch off."""
await self.coordinator.client.turn_off(self.device_id)
await self.coordinator.async_request_refresh()
```
## Switch Properties and Methods
### Core Properties
```python
@property
def is_on(self) -> bool | None:
"""Return true if entity is on."""
return self.device.state
# Or use attribute
_attr_is_on = True # or False, or None
```
### Required Methods
```python
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the entity on."""
await self.device.turn_on()
# Update state
self._attr_is_on = True
self.async_write_ha_state()
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the entity off."""
await self.device.turn_off()
# Update state
self._attr_is_on = False
self.async_write_ha_state()
```
### Optional Toggle Method
```python
async def async_toggle(self, **kwargs: Any) -> None:
"""Toggle the entity."""
# Only implement if device has native toggle
await self.device.toggle()
await self.coordinator.async_request_refresh()
```
**Note**: If `async_toggle` is not implemented, Home Assistant will use `async_turn_on`/`async_turn_off` based on current state.
## Device Class
Switches can have device classes to indicate their type:
```python
from homeassistant.components.switch import SwitchDeviceClass
_attr_device_class = SwitchDeviceClass.OUTLET
_attr_device_class = SwitchDeviceClass.SWITCH
```
Device classes:
- `OUTLET` - Smart plug/outlet
- `SWITCH` - Generic switch (default)
## State Update Patterns
### Pattern 1: Optimistic Update
For fast UI response:
```python
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn on."""
# Update state immediately (optimistic)
self._attr_is_on = True
self.async_write_ha_state()
try:
await self.coordinator.client.turn_on(self.device_id)
except DeviceError:
# Revert on error
self._attr_is_on = False
self.async_write_ha_state()
raise
```
### Pattern 2: Coordinator Refresh
Wait for actual state:
```python
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn on."""
await self.coordinator.client.turn_on(self.device_id)
# Refresh coordinator to get actual state
await self.coordinator.async_request_refresh()
```
### Pattern 3: Push Update
For push-based systems:
```python
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn on."""
# Command device
await self.device.turn_on()
# State will be updated via push event
# No need to call async_write_ha_state()
```
## Entity Descriptions Pattern
For multiple similar switches:
```python
from dataclasses import dataclass
from collections.abc import Awaitable, Callable
from homeassistant.components.switch import SwitchEntityDescription
@dataclass(frozen=True, kw_only=True)
class MySwitchDescription(SwitchEntityDescription):
"""Describes a switch."""
is_on_fn: Callable[[MyData], bool | None]
turn_on_fn: Callable[[MyClient, str], Awaitable[None]]
turn_off_fn: Callable[[MyClient, str], Awaitable[None]]
SWITCHES: tuple[MySwitchDescription, ...] = (
MySwitchDescription(
key="outlet",
translation_key="outlet",
device_class=SwitchDeviceClass.OUTLET,
is_on_fn=lambda data: data.outlet_state,
turn_on_fn=lambda client, device_id: client.turn_on_outlet(device_id),
turn_off_fn=lambda client, device_id: client.turn_off_outlet(device_id),
),
MySwitchDescription(
key="led",
translation_key="led",
entity_category=EntityCategory.CONFIG,
is_on_fn=lambda data: data.led_enabled,
turn_on_fn=lambda client, device_id: client.enable_led(device_id),
turn_off_fn=lambda client, device_id: client.disable_led(device_id),
),
)
class MySwitch(MyEntity, SwitchEntity):
"""Switch using entity description."""
entity_description: MySwitchDescription
def __init__(
self,
coordinator: MyCoordinator,
device_id: str,
description: MySwitchDescription,
) -> None:
"""Initialize the switch."""
super().__init__(coordinator, device_id)
self.entity_description = description
self._attr_unique_id = f"{device_id}_{description.key}"
@property
def is_on(self) -> bool | None:
"""Return if switch is on."""
if device := self.coordinator.data.devices.get(self.device_id):
return self.entity_description.is_on_fn(device)
return None
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn on."""
await self.entity_description.turn_on_fn(
self.coordinator.client,
self.device_id,
)
await self.coordinator.async_request_refresh()
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn off."""
await self.entity_description.turn_off_fn(
self.coordinator.client,
self.device_id,
)
await self.coordinator.async_request_refresh()
```
## Configuration Switches
Switches that control device settings (not physical devices):
```python
from homeassistant.helpers.entity import EntityCategory
class MyConfigSwitch(SwitchEntity):
"""Configuration switch."""
_attr_entity_category = EntityCategory.CONFIG
_attr_translation_key = "led_indicator"
@property
def is_on(self) -> bool:
"""Return if LED is enabled."""
return self.device.led_enabled
async def async_turn_on(self, **kwargs: Any) -> None:
"""Enable LED indicator."""
await self.device.set_led(True)
self._attr_is_on = True
self.async_write_ha_state()
async def async_turn_off(self, **kwargs: Any) -> None:
"""Disable LED indicator."""
await self.device.set_led(False)
self._attr_is_on = False
self.async_write_ha_state()
```
## Error Handling
Handle errors gracefully:
```python
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn on with error handling."""
try:
await self.device.turn_on()
except DeviceOfflineError as err:
# Let entity become unavailable
raise HomeAssistantError(f"Device is offline: {err}") from err
except DeviceError as err:
# Specific error
raise HomeAssistantError(f"Failed to turn on: {err}") from err
else:
self._attr_is_on = True
self.async_write_ha_state()
```
## Testing Switches
### Snapshot Testing
```python
"""Test switches."""
import pytest
from syrupy import SnapshotAssertion
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_switches(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
mock_config_entry: MockConfigEntry,
init_integration,
) -> None:
"""Test switch entities."""
await snapshot_platform(
hass,
entity_registry,
snapshot,
mock_config_entry.entry_id,
)
```
### Control Testing
```python
from homeassistant.const import (
ATTR_ENTITY_ID,
SERVICE_TURN_OFF,
SERVICE_TURN_ON,
)
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
async def test_switch_on_off(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_device,
) -> None:
"""Test turning switch on and off."""
await init_integration(hass, mock_config_entry)
# Test initial state
state = hass.states.get("switch.my_device_outlet")
assert state
assert state.state == "off"
# Turn on
await hass.services.async_call(
SWITCH_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: "switch.my_device_outlet"},
blocking=True,
)
mock_device.turn_on.assert_called_once()
# Check state updated
state = hass.states.get("switch.my_device_outlet")
assert state.state == "on"
# Turn off
await hass.services.async_call(
SWITCH_DOMAIN,
SERVICE_TURN_OFF,
{ATTR_ENTITY_ID: "switch.my_device_outlet"},
blocking=True,
)
mock_device.turn_off.assert_called_once()
state = hass.states.get("switch.my_device_outlet")
assert state.state == "off"
```
## Common Patterns
### Pattern 1: Coordinator-Based Switch
```python
class MySwitch(CoordinatorEntity[MyCoordinator], SwitchEntity):
"""Coordinator-based switch."""
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn on."""
await self.coordinator.client.turn_on(self.device_id)
await self.coordinator.async_request_refresh()
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn off."""
await self.coordinator.client.turn_off(self.device_id)
await self.coordinator.async_request_refresh()
@property
def is_on(self) -> bool | None:
"""Return if switch is on."""
if device := self.coordinator.data.devices.get(self.device_id):
return device.is_on
return None
```
### Pattern 2: Local State Management
```python
class MyLocalSwitch(SwitchEntity):
"""Switch with local state."""
_attr_should_poll = False
_attr_is_on = False
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn on."""
await self.device.turn_on()
self._attr_is_on = True
self.async_write_ha_state()
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn off."""
await self.device.turn_off()
self._attr_is_on = False
self.async_write_ha_state()
```
### Pattern 3: With Additional Control
```python
class MyAdvancedSwitch(SwitchEntity):
"""Switch with timer support."""
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn on with optional duration."""
duration = kwargs.get("duration") # Custom kwarg
if duration:
await self.device.turn_on_for(duration)
else:
await self.device.turn_on()
await self.coordinator.async_request_refresh()
```
## Best Practices
### ✅ DO
- Implement both turn_on and turn_off
- Update state after commands
- Handle errors properly
- Use coordinator for state management
- Implement unique IDs
- Use translation keys
- Mark config switches with entity_category
- Refresh coordinator after commands
### ❌ DON'T
- Block the event loop
- Ignore errors silently
- Create switches without unique IDs
- Mix control and sensing (use separate entities)
- Poll unnecessarily
- Hardcode entity names
- Forget to update state after commands
## Troubleshooting
### Switch Not Responding
Check:
- [ ] turn_on/turn_off methods are async
- [ ] Not blocking the event loop
- [ ] API client is working
- [ ] Errors are being raised properly
### State Not Updating
Check:
- [ ] async_write_ha_state() is called
- [ ] Coordinator refresh is working
- [ ] is_on returns correct value
- [ ] Push updates are subscribed
### Switch Appearing as Unavailable
Check:
- [ ] Device connection is working
- [ ] Coordinator update is successful
- [ ] available property returns True
- [ ] Entity is in coordinator.data
## Quality Scale Considerations
- **Bronze**: Unique ID required
- **Gold**: Entity translations, device class (if applicable)
- **Platinum**: Full type hints
## References
- [Switch Documentation](https://developers.home-assistant.io/docs/core/entity/switch)
- [Switch Integration](https://www.home-assistant.io/integrations/switch/)

View File

@@ -13,7 +13,6 @@ core: &core
# Our base platforms, that are used by other integrations
base_platforms: &base_platforms
- homeassistant/components/ai_task/**
- homeassistant/components/air_quality/**
- homeassistant/components/alarm_control_panel/**
- homeassistant/components/assist_satellite/**
@@ -59,7 +58,6 @@ base_platforms: &base_platforms
# Extra components that trigger the full suite
components: &components
- homeassistant/components/alexa/**
- homeassistant/components/analytics/**
- homeassistant/components/application_credentials/**
- homeassistant/components/assist_pipeline/**
- homeassistant/components/auth/**

View File

@@ -8,8 +8,6 @@
"PYTHONASYNCIODEBUG": "1"
},
"features": {
// Node feature required for Claude Code until fixed https://github.com/anthropics/devcontainer-features/issues/28
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/anthropics/devcontainer-features/claude-code:1.0": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
},
@@ -27,12 +25,13 @@
"charliermarsh.ruff",
"ms-python.pylint",
"ms-python.vscode-pylance",
"visualstudioexptteam.vscodeintellicode",
"redhat.vscode-yaml",
"esbenp.prettier-vscode",
"GitHub.vscode-pull-request-github",
"GitHub.copilot"
],
// Please keep this file in sync with settings in home-assistant/.vscode/settings.default.jsonc
// Please keep this file in sync with settings in home-assistant/.vscode/settings.default.json
"settings": {
"python.experiments.optOutFrom": ["pythonTestAdapter"],
"python.defaultInterpreterPath": "/home/vscode/.local/ha-venv/bin/python",
@@ -40,7 +39,6 @@
"python.terminal.activateEnvInCurrentTerminal": true,
"python.testing.pytestArgs": ["--no-cov"],
"pylint.importStrategy": "fromEnvironment",
"python.analysis.typeCheckingMode": "basic",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
@@ -62,9 +60,6 @@
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff"
},
"[json][jsonc][yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"json.schemas": [
{
"fileMatch": ["homeassistant/components/*/manifest.json"],

View File

@@ -14,8 +14,7 @@ tests
# Other virtualization methods
venv
.venv
.vagrant
# Temporary files
**/__pycache__
**/__pycache__

View File

@@ -55,12 +55,8 @@
creating the PR. If you're unsure about any of them, don't hesitate to ask.
We're here to help! This is simply a reminder of what we are going to look
for before merging your code.
AI tools are welcome, but contributors are responsible for *fully*
understanding the code before submitting a PR.
-->
- [ ] I understand the code I am submitting and can explain how it works.
- [ ] The code change is tested and works locally.
- [ ] Local tests pass. **Your PR cannot be merged unless tests pass**
- [ ] There is no commented out code in this PR.
@@ -68,7 +64,6 @@
- [ ] I have followed the [perfect PR recommendations][perfect-pr]
- [ ] The code has been formatted using Ruff (`ruff format homeassistant tests`)
- [ ] Tests have been added to verify that the new code works.
- [ ] Any generated code has been carefully reviewed for correctness and compliance with project standards.
If user exposed functionality or configuration variables are added/changed:

View File

@@ -51,9 +51,6 @@ rules:
- **Missing imports** - We use static analysis tooling to catch that
- **Code formatting** - We have ruff as a formatting tool that will catch those if needed (unless specifically instructed otherwise in these instructions)
**Git commit practices during review:**
- **Do NOT amend, squash, or rebase commits after review has started** - Reviewers need to see what changed since their last review
## Python Requirements
- **Compatibility**: Python 3.13+
@@ -77,7 +74,6 @@ rules:
- **Formatting**: Ruff
- **Linting**: PyLint and Ruff
- **Type Checking**: MyPy
- **Lint/Type/Format Fixes**: Always prefer addressing the underlying issue (e.g., import the typed source, update shared stubs, align with Ruff expectations, or correct formatting at the source) before disabling a rule, adding `# type: ignore`, or skipping a formatter. Treat suppressions and `noqa` comments as a last resort once no compliant fix exists
- **Testing**: pytest with plain functions and fixtures
- **Language**: American English for all code, comments, and documentation (use sentence case, including titles)
@@ -1077,11 +1073,7 @@ async def test_flow_connection_error(hass, mock_api_error):
### Entity Testing Patterns
```python
@pytest.fixture
def platforms() -> list[Platform]:
"""Overridden fixture to specify platforms to test."""
return [Platform.SENSOR] # Or another specific platform as needed.
@pytest.mark.parametrize("init_integration", [Platform.SENSOR], indirect=True)
@pytest.mark.usefixtures("entity_registry_enabled_by_default", "init_integration")
async def test_entities(
hass: HomeAssistant,
@@ -1128,25 +1120,16 @@ def mock_device_api() -> Generator[MagicMock]:
)
yield api
@pytest.fixture
def platforms() -> list[Platform]:
"""Fixture to specify platforms to test."""
return PLATFORMS
@pytest.fixture
async def init_integration(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_device_api: MagicMock,
platforms: list[Platform],
) -> MockConfigEntry:
"""Set up the integration for testing."""
mock_config_entry.add_to_hass(hass)
with patch("homeassistant.components.my_integration.PLATFORMS", platforms):
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
return mock_config_entry
```

View File

@@ -14,9 +14,6 @@ env:
PIP_TIMEOUT: 60
UV_HTTP_TIMEOUT: 60
UV_SYSTEM_PYTHON: "true"
# Base image version from https://github.com/home-assistant/docker
BASE_IMAGE_VERSION: "2025.12.0"
ARCHITECTURES: '["amd64", "aarch64"]'
jobs:
init:
@@ -24,16 +21,18 @@ jobs:
if: github.repository_owner == 'home-assistant'
runs-on: ubuntu-latest
outputs:
architectures: ${{ steps.info.outputs.architectures }}
version: ${{ steps.version.outputs.version }}
channel: ${{ steps.version.outputs.channel }}
publish: ${{ steps.version.outputs.publish }}
architectures: ${{ env.ARCHITECTURES }}
steps:
- name: Checkout the repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
uses: actions/checkout@v5.0.0
with:
fetch-depth: 0
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
uses: actions/setup-python@v5.6.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}
@@ -70,7 +69,7 @@ jobs:
run: find ./homeassistant/components/*/translations -name "*.json" | tar zcvf translations.tar.gz -T -
- name: Upload translations
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
uses: actions/upload-artifact@v4.6.2
with:
name: translations
path: translations.tar.gz
@@ -80,7 +79,7 @@ jobs:
name: Build ${{ matrix.arch }} base core image
if: github.repository_owner == 'home-assistant'
needs: init
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
@@ -89,18 +88,13 @@ jobs:
fail-fast: false
matrix:
arch: ${{ fromJson(needs.init.outputs.architectures) }}
include:
- arch: amd64
os: ubuntu-latest
- arch: aarch64
os: ubuntu-24.04-arm
steps:
- name: Checkout the repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
uses: actions/checkout@v5.0.0
- name: Download nightly wheels of frontend
if: needs.init.outputs.channel == 'dev'
uses: dawidd6/action-download-artifact@0bd50d53a6d7fb5cb921e607957e9cc12b4ce392 # v12
uses: dawidd6/action-download-artifact@v11
with:
github_token: ${{secrets.GITHUB_TOKEN}}
repo: home-assistant/frontend
@@ -111,7 +105,7 @@ jobs:
- name: Download nightly wheels of intents
if: needs.init.outputs.channel == 'dev'
uses: dawidd6/action-download-artifact@0bd50d53a6d7fb5cb921e607957e9cc12b4ce392 # v12
uses: dawidd6/action-download-artifact@v11
with:
github_token: ${{secrets.GITHUB_TOKEN}}
repo: OHF-Voice/intents-package
@@ -122,7 +116,7 @@ jobs:
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
if: needs.init.outputs.channel == 'dev'
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
uses: actions/setup-python@v5.6.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}
@@ -168,8 +162,20 @@ jobs:
sed -i "s|home-assistant-intents==.*||" requirements_all.txt
fi
- name: Adjustments for armhf
if: matrix.arch == 'armhf'
run: |
# Pandas has issues building on armhf, it is expected they
# will drop the platform in the near future (they consider it
# "flimsy" on 386). The following packages depend on pandas,
# so we comment them out.
sed -i "s|env-canada|# env-canada|g" requirements_all.txt
sed -i "s|noaa-coops|# noaa-coops|g" requirements_all.txt
sed -i "s|pyezviz|# pyezviz|g" requirements_all.txt
sed -i "s|pykrakenapi|# pykrakenapi|g" requirements_all.txt
- name: Download translations
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
uses: actions/download-artifact@v5.0.0
with:
name: translations
@@ -184,66 +190,21 @@ jobs:
echo "${{ github.sha }};${{ github.ref }};${{ github.event_name }};${{ github.actor }}" > rootfs/OFFICIAL_IMAGE
- name: Login to GitHub Container Registry
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
uses: docker/login-action@v3.5.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- &install_cosign
name: Install Cosign
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
with:
cosign-release: "v2.5.3"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Build variables
id: vars
shell: bash
run: |
echo "base_image=ghcr.io/home-assistant/${{ matrix.arch }}-homeassistant-base:${{ env.BASE_IMAGE_VERSION }}" >> "$GITHUB_OUTPUT"
echo "cache_image=ghcr.io/home-assistant/${{ matrix.arch }}-homeassistant:latest" >> "$GITHUB_OUTPUT"
echo "created=$(date --rfc-3339=seconds --utc)" >> "$GITHUB_OUTPUT"
- name: Verify base image signature
run: |
cosign verify \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
--certificate-identity-regexp "https://github.com/home-assistant/docker/.*" \
"${{ steps.vars.outputs.base_image }}"
- name: Verify cache image signature
id: cache
continue-on-error: true
run: |
cosign verify \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
--certificate-identity-regexp "https://github.com/home-assistant/core/.*" \
"${{ steps.vars.outputs.cache_image }}"
- name: Build base image
id: build
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
uses: home-assistant/builder@2025.03.0
with:
context: .
file: ./Dockerfile
platforms: ${{ steps.vars.outputs.platform }}
push: true
cache-from: ${{ steps.cache.outcome == 'success' && steps.vars.outputs.cache_image || '' }}
build-args: |
BUILD_FROM=${{ steps.vars.outputs.base_image }}
tags: ghcr.io/home-assistant/${{ matrix.arch }}-homeassistant:${{ needs.init.outputs.version }}
labels: |
io.hass.arch=${{ matrix.arch }}
io.hass.version=${{ needs.init.outputs.version }}
org.opencontainers.image.created=${{ steps.vars.outputs.created }}
org.opencontainers.image.version=${{ needs.init.outputs.version }}
- name: Sign image
run: |
cosign sign --yes "ghcr.io/home-assistant/${{ matrix.arch }}-homeassistant:${{ needs.init.outputs.version }}@${{ steps.build.outputs.digest }}"
args: |
$BUILD_ARGS \
--${{ matrix.arch }} \
--cosign \
--target /data \
--generic ${{ needs.init.outputs.version }}
build_machine:
name: Build ${{ matrix.machine }} machine core image
@@ -264,16 +225,24 @@ jobs:
- odroid-c4
- odroid-m1
- odroid-n2
- odroid-xu
- qemuarm
- qemuarm-64
- qemux86
- qemux86-64
- raspberrypi
- raspberrypi2
- raspberrypi3
- raspberrypi3-64
- raspberrypi4
- raspberrypi4-64
- raspberrypi5-64
- tinker
- yellow
- green
steps:
- name: Checkout the repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
uses: actions/checkout@v5.0.0
- name: Set build additional args
run: |
@@ -287,15 +256,14 @@ jobs:
fi
- name: Login to GitHub Container Registry
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
uses: docker/login-action@v3.5.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# home-assistant/builder doesn't support sha pinning
- name: Build base image
uses: home-assistant/builder@2025.11.0
uses: home-assistant/builder@2025.03.0
with:
args: |
$BUILD_ARGS \
@@ -311,7 +279,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
uses: actions/checkout@v5.0.0
- name: Initialize git
uses: home-assistant/actions/helpers/git-init@master
@@ -327,7 +295,6 @@ jobs:
key-description: "Home Assistant Core"
version: ${{ needs.init.outputs.version }}
channel: ${{ needs.init.outputs.channel }}
exclude-list: '["odroid-xu","qemuarm","qemux86","raspberrypi","raspberrypi2","raspberrypi3","raspberrypi4","tinker"]'
- name: Update version file (stable -> beta)
if: needs.init.outputs.channel == 'stable'
@@ -337,7 +304,6 @@ jobs:
key-description: "Home Assistant Core"
version: ${{ needs.init.outputs.version }}
channel: beta
exclude-list: '["odroid-xu","qemuarm","qemux86","raspberrypi","raspberrypi2","raspberrypi3","raspberrypi4","tinker"]'
publish_container:
name: Publish meta container for ${{ matrix.registry }}
@@ -354,114 +320,128 @@ jobs:
matrix:
registry: ["ghcr.io/home-assistant", "docker.io/homeassistant"]
steps:
- *install_cosign
- name: Checkout the repository
uses: actions/checkout@v5.0.0
- name: Install Cosign
uses: sigstore/cosign-installer@v3.9.2
with:
cosign-release: "v2.2.3"
- name: Login to DockerHub
if: matrix.registry == 'docker.io/homeassistant'
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
uses: docker/login-action@v3.5.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
if: matrix.registry == 'ghcr.io/home-assistant'
uses: docker/login-action@v3.5.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Verify architecture image signatures
- name: Build Meta Image
shell: bash
run: |
ARCHS=$(echo '${{ needs.init.outputs.architectures }}' | jq -r '.[]')
for arch in $ARCHS; do
echo "Verifying ${arch} image signature..."
cosign verify \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
--certificate-identity-regexp https://github.com/home-assistant/core/.* \
"ghcr.io/home-assistant/${arch}-homeassistant:${{ needs.init.outputs.version }}"
done
echo "✓ All images verified successfully"
export DOCKER_CLI_EXPERIMENTAL=enabled
# Generate all Docker tags based on version string
# Version format: YYYY.MM.PATCH, YYYY.MM.PATCHbN (beta), or YYYY.MM.PATCH.devYYYYMMDDHHMM (dev)
# Examples:
# 2025.12.1 (stable) -> tags: 2025.12.1, 2025.12, stable, latest, beta, rc
# 2025.12.0b3 (beta) -> tags: 2025.12.0b3, beta, rc
# 2025.12.0.dev202511250240 -> tags: 2025.12.0.dev202511250240, dev
- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
with:
images: ${{ matrix.registry }}/home-assistant
sep-tags: ","
tags: |
type=raw,value=${{ needs.init.outputs.version }},priority=9999
type=raw,value=dev,enable=${{ contains(needs.init.outputs.version, 'd') }}
type=raw,value=beta,enable=${{ !contains(needs.init.outputs.version, 'd') }}
type=raw,value=rc,enable=${{ !contains(needs.init.outputs.version, 'd') }}
type=raw,value=stable,enable=${{ !contains(needs.init.outputs.version, 'd') && !contains(needs.init.outputs.version, 'b') }}
type=raw,value=latest,enable=${{ !contains(needs.init.outputs.version, 'd') && !contains(needs.init.outputs.version, 'b') }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.init.outputs.version }},enable=${{ !contains(needs.init.outputs.version, 'd') && !contains(needs.init.outputs.version, 'b') }}
function create_manifest() {
local tag_l=${1}
local tag_r=${2}
local registry=${{ matrix.registry }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.7.1
docker manifest create "${registry}/home-assistant:${tag_l}" \
"${registry}/amd64-homeassistant:${tag_r}" \
"${registry}/i386-homeassistant:${tag_r}" \
"${registry}/armhf-homeassistant:${tag_r}" \
"${registry}/armv7-homeassistant:${tag_r}" \
"${registry}/aarch64-homeassistant:${tag_r}"
- name: Copy architecture images to DockerHub
if: matrix.registry == 'docker.io/homeassistant'
shell: bash
run: |
# Use imagetools to copy image blobs directly between registries
# This preserves provenance/attestations and seems to be much faster than pull/push
ARCHS=$(echo '${{ needs.init.outputs.architectures }}' | jq -r '.[]')
for arch in $ARCHS; do
echo "Copying ${arch} image to DockerHub..."
for attempt in 1 2 3; do
if docker buildx imagetools create \
--tag "docker.io/homeassistant/${arch}-homeassistant:${{ needs.init.outputs.version }}" \
"ghcr.io/home-assistant/${arch}-homeassistant:${{ needs.init.outputs.version }}"; then
break
fi
echo "Attempt ${attempt} failed, retrying in 10 seconds..."
sleep 10
if [ "${attempt}" -eq 3 ]; then
echo "Failed after 3 attempts"
exit 1
fi
done
cosign sign --yes "docker.io/homeassistant/${arch}-homeassistant:${{ needs.init.outputs.version }}"
done
docker manifest annotate "${registry}/home-assistant:${tag_l}" \
"${registry}/amd64-homeassistant:${tag_r}" \
--os linux --arch amd64
- name: Create and push multi-arch manifests
shell: bash
run: |
# Build list of architecture images dynamically
ARCHS=$(echo '${{ needs.init.outputs.architectures }}' | jq -r '.[]')
ARCH_IMAGES=()
for arch in $ARCHS; do
ARCH_IMAGES+=("${{ matrix.registry }}/${arch}-homeassistant:${{ needs.init.outputs.version }}")
done
docker manifest annotate "${registry}/home-assistant:${tag_l}" \
"${registry}/i386-homeassistant:${tag_r}" \
--os linux --arch 386
# Build list of all tags for single manifest creation
# Note: Using sep-tags=',' in metadata-action for easier parsing
TAG_ARGS=()
IFS=',' read -ra TAGS <<< "${{ steps.meta.outputs.tags }}"
for tag in "${TAGS[@]}"; do
TAG_ARGS+=("--tag" "${tag}")
done
docker manifest annotate "${registry}/home-assistant:${tag_l}" \
"${registry}/armhf-homeassistant:${tag_r}" \
--os linux --arch arm --variant=v6
# Create manifest with ALL tags in a single operation (much faster!)
echo "Creating multi-arch manifest with tags: ${TAGS[*]}"
docker buildx imagetools create "${TAG_ARGS[@]}" "${ARCH_IMAGES[@]}"
docker manifest annotate "${registry}/home-assistant:${tag_l}" \
"${registry}/armv7-homeassistant:${tag_r}" \
--os linux --arch arm --variant=v7
# Sign each tag separately (signing requires individual tag names)
echo "Signing all tags..."
for tag in "${TAGS[@]}"; do
echo "Signing ${tag}"
cosign sign --yes "${tag}"
done
docker manifest annotate "${registry}/home-assistant:${tag_l}" \
"${registry}/aarch64-homeassistant:${tag_r}" \
--os linux --arch arm64 --variant=v8
echo "All manifests created and signed successfully"
docker manifest push --purge "${registry}/home-assistant:${tag_l}"
cosign sign --yes "${registry}/home-assistant:${tag_l}"
}
function validate_image() {
local image=${1}
if ! cosign verify --certificate-oidc-issuer https://token.actions.githubusercontent.com --certificate-identity-regexp https://github.com/home-assistant/core/.* "${image}"; then
echo "Invalid signature!"
exit 1
fi
}
function push_dockerhub() {
local image=${1}
local tag=${2}
docker tag "ghcr.io/home-assistant/${image}:${tag}" "docker.io/homeassistant/${image}:${tag}"
docker push "docker.io/homeassistant/${image}:${tag}"
cosign sign --yes "docker.io/homeassistant/${image}:${tag}"
}
# Pull images from github container registry and verify signature
docker pull "ghcr.io/home-assistant/amd64-homeassistant:${{ needs.init.outputs.version }}"
docker pull "ghcr.io/home-assistant/i386-homeassistant:${{ needs.init.outputs.version }}"
docker pull "ghcr.io/home-assistant/armhf-homeassistant:${{ needs.init.outputs.version }}"
docker pull "ghcr.io/home-assistant/armv7-homeassistant:${{ needs.init.outputs.version }}"
docker pull "ghcr.io/home-assistant/aarch64-homeassistant:${{ needs.init.outputs.version }}"
validate_image "ghcr.io/home-assistant/amd64-homeassistant:${{ needs.init.outputs.version }}"
validate_image "ghcr.io/home-assistant/i386-homeassistant:${{ needs.init.outputs.version }}"
validate_image "ghcr.io/home-assistant/armhf-homeassistant:${{ needs.init.outputs.version }}"
validate_image "ghcr.io/home-assistant/armv7-homeassistant:${{ needs.init.outputs.version }}"
validate_image "ghcr.io/home-assistant/aarch64-homeassistant:${{ needs.init.outputs.version }}"
if [[ "${{ matrix.registry }}" == "docker.io/homeassistant" ]]; then
# Upload images to dockerhub
push_dockerhub "amd64-homeassistant" "${{ needs.init.outputs.version }}"
push_dockerhub "i386-homeassistant" "${{ needs.init.outputs.version }}"
push_dockerhub "armhf-homeassistant" "${{ needs.init.outputs.version }}"
push_dockerhub "armv7-homeassistant" "${{ needs.init.outputs.version }}"
push_dockerhub "aarch64-homeassistant" "${{ needs.init.outputs.version }}"
fi
# Create version tag
create_manifest "${{ needs.init.outputs.version }}" "${{ needs.init.outputs.version }}"
# Create general tags
if [[ "${{ needs.init.outputs.version }}" =~ d ]]; then
create_manifest "dev" "${{ needs.init.outputs.version }}"
elif [[ "${{ needs.init.outputs.version }}" =~ b ]]; then
create_manifest "beta" "${{ needs.init.outputs.version }}"
create_manifest "rc" "${{ needs.init.outputs.version }}"
else
create_manifest "stable" "${{ needs.init.outputs.version }}"
create_manifest "latest" "${{ needs.init.outputs.version }}"
create_manifest "beta" "${{ needs.init.outputs.version }}"
create_manifest "rc" "${{ needs.init.outputs.version }}"
# Create series version tag (e.g. 2021.6)
v="${{ needs.init.outputs.version }}"
create_manifest "${v%.*}" "${{ needs.init.outputs.version }}"
fi
build_python:
name: Build PyPi package
@@ -474,15 +454,15 @@ jobs:
if: github.repository_owner == 'home-assistant' && needs.init.outputs.publish == 'true'
steps:
- name: Checkout the repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
uses: actions/checkout@v5.0.0
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
uses: actions/setup-python@v5.6.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Download translations
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
uses: actions/download-artifact@v5.0.0
with:
name: translations
@@ -500,7 +480,7 @@ jobs:
python -m build
- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
uses: pypa/gh-action-pypi-publish@v1.12.4
with:
skip-existing: true
@@ -519,10 +499,10 @@ jobs:
HASSFEST_IMAGE_TAG: ghcr.io/home-assistant/hassfest:${{ needs.init.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Login to GitHub Container Registry
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
@@ -551,7 +531,7 @@ jobs:
- name: Generate artifact attestation
if: needs.init.outputs.channel != 'dev' && needs.init.outputs.publish == 'true'
uses: actions/attest-build-provenance@00014ed6ed5efc5b1ab7f7f34a39eb55d41aa4f8 # v3.1.0
uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2.4.0
with:
subject-name: ${{ env.HASSFEST_IMAGE_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}

File diff suppressed because it is too large Load Diff

View File

@@ -21,14 +21,14 @@ jobs:
steps:
- name: Check out code from GitHub
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
uses: actions/checkout@v5.0.0
- name: Initialize CodeQL
uses: github/codeql-action/init@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
uses: github/codeql-action/init@v3.29.9
with:
languages: python
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
uses: github/codeql-action/analyze@v3.29.9
with:
category: "/language:python"

View File

@@ -16,7 +16,7 @@ jobs:
steps:
- name: Check if integration label was added and extract details
id: extract
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
uses: actions/github-script@v7.0.1
with:
script: |
// Debug: Log the event payload
@@ -113,7 +113,7 @@ jobs:
- name: Fetch similar issues
id: fetch_similar
if: steps.extract.outputs.should_continue == 'true'
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
uses: actions/github-script@v7.0.1
env:
INTEGRATION_LABELS: ${{ steps.extract.outputs.integration_labels }}
CURRENT_NUMBER: ${{ steps.extract.outputs.current_number }}
@@ -231,7 +231,7 @@ jobs:
- name: Detect duplicates using AI
id: ai_detection
if: steps.extract.outputs.should_continue == 'true' && steps.fetch_similar.outputs.has_similar == 'true'
uses: actions/ai-inference@334892bb203895caaed82ec52d23c1ed9385151e # v2.0.4
uses: actions/ai-inference@v2.0.0
with:
model: openai/gpt-4o
system-prompt: |
@@ -280,7 +280,7 @@ jobs:
- name: Post duplicate detection results
id: post_results
if: steps.extract.outputs.should_continue == 'true' && steps.fetch_similar.outputs.has_similar == 'true'
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
uses: actions/github-script@v7.0.1
env:
AI_RESPONSE: ${{ steps.ai_detection.outputs.response }}
SIMILAR_ISSUES: ${{ steps.fetch_similar.outputs.similar_issues }}

View File

@@ -16,7 +16,7 @@ jobs:
steps:
- name: Check issue language
id: detect_language
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
uses: actions/github-script@v7.0.1
env:
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
@@ -57,7 +57,7 @@ jobs:
- name: Detect language using AI
id: ai_language_detection
if: steps.detect_language.outputs.should_continue == 'true'
uses: actions/ai-inference@334892bb203895caaed82ec52d23c1ed9385151e # v2.0.4
uses: actions/ai-inference@v2.0.0
with:
model: openai/gpt-4o-mini
system-prompt: |
@@ -90,7 +90,7 @@ jobs:
- name: Process non-English issues
if: steps.detect_language.outputs.should_continue == 'true'
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
uses: actions/github-script@v7.0.1
env:
AI_RESPONSE: ${{ steps.ai_language_detection.outputs.response }}
ISSUE_NUMBER: ${{ steps.detect_language.outputs.issue_number }}

View File

@@ -10,7 +10,7 @@ jobs:
if: github.repository_owner == 'home-assistant'
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@7266a7ce5c1df01b1c6db85bf8cd86c737dadbe7 # v6.0.0
- uses: dessant/lock-threads@v5.0.1
with:
github-token: ${{ github.token }}
issue-inactive-days: "30"

View File

@@ -12,7 +12,7 @@ jobs:
if: github.event.issue.type.name == 'Task'
steps:
- name: Check if user is authorized
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
uses: actions/github-script@v7
with:
script: |
const issueAuthor = context.payload.issue.user.login;

View File

@@ -17,7 +17,7 @@ jobs:
# - No PRs marked as no-stale
# - No issues (-1)
- name: 60 days stale PRs policy
uses: actions/stale@997185467fa4f803885201cee163a9f38240193d # v10.1.1
uses: actions/stale@v9.1.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-stale: 60
@@ -57,7 +57,7 @@ jobs:
# - No issues marked as no-stale or help-wanted
# - No PRs (-1)
- name: 90 days stale issues
uses: actions/stale@997185467fa4f803885201cee163a9f38240193d # v10.1.1
uses: actions/stale@v9.1.0
with:
repo-token: ${{ steps.token.outputs.token }}
days-before-stale: 90
@@ -87,7 +87,7 @@ jobs:
# - No Issues marked as no-stale or help-wanted
# - No PRs (-1)
- name: Needs more information stale issues policy
uses: actions/stale@997185467fa4f803885201cee163a9f38240193d # v10.1.1
uses: actions/stale@v9.1.0
with:
repo-token: ${{ steps.token.outputs.token }}
only-labels: "needs-more-information"

View File

@@ -19,10 +19,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
uses: actions/checkout@v5.0.0
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
uses: actions/setup-python@v5.6.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}

View File

@@ -28,14 +28,15 @@ jobs:
name: Initialize wheels builder
if: github.repository_owner == 'home-assistant'
runs-on: ubuntu-latest
outputs:
architectures: ${{ steps.info.outputs.architectures }}
steps:
- &checkout
name: Checkout the repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Checkout the repository
uses: actions/checkout@v5.0.0
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
uses: actions/setup-python@v5.6.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}
check-latest: true
@@ -48,6 +49,10 @@ jobs:
pip install "$(grep '^uv' < requirements.txt)"
uv pip install -r requirements.txt
- name: Get information
id: info
uses: home-assistant/actions/helpers/info@master
- name: Create requirements_diff file
run: |
if [[ ${{ github.event_name }} =~ (schedule|workflow_dispatch) ]]; then
@@ -71,18 +76,37 @@ jobs:
# Use C-Extension for SQLAlchemy
echo "REQUIRE_SQLALCHEMY_CEXT=1"
# Add additional pip wheel build constraints
echo "PIP_CONSTRAINT=build_constraints.txt"
) > .env_file
- name: Write pip wheel build constraints
run: |
(
# ninja 1.11.1.2 + 1.11.1.3 seem to be broken on at least armhf
# this caused the numpy builds to fail
# https://github.com/scikit-build/ninja-python-distributions/issues/274
echo "ninja==1.11.1.1"
) > build_constraints.txt
- name: Upload env_file
uses: &actions-upload-artifact actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
uses: actions/upload-artifact@v4.6.2
with:
name: env_file
path: ./.env_file
include-hidden-files: true
overwrite: true
- name: Upload build_constraints
uses: actions/upload-artifact@v4.6.2
with:
name: build_constraints
path: ./build_constraints.txt
overwrite: true
- name: Upload requirements_diff
uses: *actions-upload-artifact
uses: actions/upload-artifact@v4.6.2
with:
name: requirements_diff
path: ./requirements_diff.txt
@@ -94,7 +118,7 @@ jobs:
python -m script.gen_requirements_all ci
- name: Upload requirements_all_wheels
uses: *actions-upload-artifact
uses: actions/upload-artifact@v4.6.2
with:
name: requirements_all_wheels
path: ./requirements_all_wheels_*.txt
@@ -103,29 +127,28 @@ jobs:
name: Build Core wheels ${{ matrix.abi }} for ${{ matrix.arch }} (musllinux_1_2)
if: github.repository_owner == 'home-assistant'
needs: init
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: &matrix-build
abi: ["cp313", "cp314"]
arch: ["amd64", "aarch64"]
include:
- arch: amd64
os: ubuntu-latest
- arch: aarch64
os: ubuntu-24.04-arm
matrix:
abi: ["cp313"]
arch: ${{ fromJson(needs.init.outputs.architectures) }}
steps:
- *checkout
- name: Checkout the repository
uses: actions/checkout@v5.0.0
- &download-env-file
name: Download env_file
uses: &actions-download-artifact actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
- name: Download env_file
uses: actions/download-artifact@v5.0.0
with:
name: env_file
- &download-requirements-diff
name: Download requirements_diff
uses: *actions-download-artifact
- name: Download build_constraints
uses: actions/download-artifact@v5.0.0
with:
name: build_constraints
- name: Download requirements_diff
uses: actions/download-artifact@v5.0.0
with:
name: requirements_diff
@@ -136,7 +159,7 @@ jobs:
sed -i "/uv/d" requirements_diff.txt
- name: Build wheels
uses: &home-assistant-wheels home-assistant/wheels@e5742a69d69f0e274e2689c998900c7d19652c21 # 2025.12.0
uses: home-assistant/wheels@2025.07.0
with:
abi: ${{ matrix.abi }}
tag: musllinux_1_2
@@ -153,24 +176,42 @@ jobs:
name: Build wheels ${{ matrix.abi }} for ${{ matrix.arch }}
if: github.repository_owner == 'home-assistant'
needs: init
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: *matrix-build
matrix:
abi: ["cp313"]
arch: ${{ fromJson(needs.init.outputs.architectures) }}
steps:
- *checkout
- name: Checkout the repository
uses: actions/checkout@v5.0.0
- *download-env-file
- name: Download env_file
uses: actions/download-artifact@v5.0.0
with:
name: env_file
- *download-requirements-diff
- name: Download build_constraints
uses: actions/download-artifact@v5.0.0
with:
name: build_constraints
- name: Download requirements_diff
uses: actions/download-artifact@v5.0.0
with:
name: requirements_diff
- name: Download requirements_all_wheels
uses: *actions-download-artifact
uses: actions/download-artifact@v5.0.0
with:
name: requirements_all_wheels
- name: Adjust build env
run: |
if [ "${{ matrix.arch }}" = "i386" ]; then
echo "NPY_DISABLE_SVML=1" >> .env_file
fi
# Do not pin numpy in wheels building
sed -i "/numpy/d" homeassistant/package_constraints.txt
# Don't build wheels for uv as uv requires a greater version of rust as currently available on alpine
@@ -178,14 +219,14 @@ jobs:
sed -i "/uv/d" requirements_diff.txt
- name: Build wheels
uses: *home-assistant-wheels
uses: home-assistant/wheels@2025.07.0
with:
abi: ${{ matrix.abi }}
tag: musllinux_1_2
arch: ${{ matrix.arch }}
wheels-key: ${{ secrets.WHEELS_KEY }}
env-file: true
apk: "bluez-dev;libffi-dev;openssl-dev;glib-dev;eudev-dev;libxml2-dev;libxslt-dev;libpng-dev;libjpeg-turbo-dev;tiff-dev;gmp-dev;mpfr-dev;mpc1-dev;ffmpeg-dev;yaml-dev;openblas-dev;fftw-dev;lapack-dev;gfortran;blas-dev;eigen-dev;freetype-dev;glew-dev;harfbuzz-dev;hdf5-dev;libdc1394-dev;libtbb-dev;mesa-dev;openexr-dev;openjpeg-dev;uchardet-dev;nasm;zlib-ng-dev"
apk: "bluez-dev;libffi-dev;openssl-dev;glib-dev;eudev-dev;libxml2-dev;libxslt-dev;libpng-dev;libjpeg-turbo-dev;tiff-dev;cups-dev;gmp-dev;mpfr-dev;mpc1-dev;ffmpeg-dev;gammu-dev;yaml-dev;openblas-dev;fftw-dev;lapack-dev;gfortran;blas-dev;eigen-dev;freetype-dev;glew-dev;harfbuzz-dev;hdf5-dev;libdc1394-dev;libtbb-dev;mesa-dev;openexr-dev;openjpeg-dev;uchardet-dev;nasm;zlib-ng-dev"
skip-binary: aiohttp;charset-normalizer;grpcio;multidict;SQLAlchemy;propcache;protobuf;pymicro-vad;yarl
constraints: "homeassistant/package_constraints.txt"
requirements-diff: "requirements_diff.txt"

6
.gitignore vendored
View File

@@ -79,6 +79,7 @@ junit.xml
.project
.pydevproject
.python-version
.tool-versions
# emacs auto backups
@@ -92,7 +93,6 @@ pip-selfcheck.json
venv
.venv
Pipfile*
uv.lock
share/*
/Scripts/
@@ -112,7 +112,6 @@ virtualization/vagrant/config
!.vscode/cSpell.json
!.vscode/extensions.json
!.vscode/tasks.json
!.vscode/settings.default.jsonc
.env
# Windows Explorer
@@ -141,6 +140,5 @@ tmp_cache
pytest_buckets.txt
# AI tooling
.claude/settings.local.json
.serena/
.claude

View File

@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.13.0
rev: v0.12.1
hooks:
- id: ruff-check
args:
@@ -33,13 +33,10 @@ repos:
rev: v1.37.1
hooks:
- id: yamllint
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.6.2
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
hooks:
- id: prettier
additional_dependencies:
- prettier@3.6.2
- prettier-plugin-sort-json@4.1.1
- repo: https://github.com/cdce8p/python-typing-update
rev: v0.6.0
hooks:
@@ -87,14 +84,14 @@ repos:
pass_filenames: false
language: script
types: [text]
files: ^(homeassistant/.+/(icons|manifest|strings)\.json|homeassistant/.+/(conditions|quality_scale|services|triggers)\.yaml|homeassistant/brands/.*\.json|script/hassfest/(?!metadata|mypy_config).+\.py|requirements.+\.txt)$
files: ^(homeassistant/.+/(icons|manifest|strings)\.json|homeassistant/.+/(quality_scale)\.yaml|homeassistant/brands/.*\.json|homeassistant/.+/services\.yaml|script/hassfest/(?!metadata|mypy_config).+\.py|requirements.+\.txt)$
- id: hassfest-metadata
name: hassfest-metadata
entry: script/run-in-env.sh python3 -m script.hassfest -p metadata,docker
pass_filenames: false
language: script
types: [text]
files: ^(script/hassfest/(metadata|docker)\.py|homeassistant/const\.py$|pyproject\.toml)$
files: ^(script/hassfest/metadata\.py|homeassistant/const\.py$|pyproject\.toml|homeassistant/components/go2rtc/const\.py)$
- id: hassfest-mypy-config
name: hassfest-mypy-config
entry: script/run-in-env.sh python3 -m script.hassfest -p mypy_config

View File

@@ -1,24 +0,0 @@
/** @type {import("prettier").Config} */
module.exports = {
overrides: [
{
files: "./homeassistant/**/*.json",
options: {
plugins: [require.resolve("prettier-plugin-sort-json")],
jsonRecursiveSort: true,
jsonSortOrder: JSON.stringify({ [/.*/]: "numeric" }),
},
},
{
files: ["manifest.json", "./**/brands/*.json"],
options: {
// domain and name should stay at the top
jsonSortOrder: JSON.stringify({
domain: null,
name: null,
[/.*/]: "numeric",
}),
},
},
],
};

View File

@@ -1 +0,0 @@
3.13

View File

@@ -107,7 +107,6 @@ homeassistant.components.automation.*
homeassistant.components.awair.*
homeassistant.components.axis.*
homeassistant.components.azure_storage.*
homeassistant.components.backblaze_b2.*
homeassistant.components.backup.*
homeassistant.components.baf.*
homeassistant.components.bang_olufsen.*
@@ -120,6 +119,7 @@ homeassistant.components.blueprint.*
homeassistant.components.bluesound.*
homeassistant.components.bluetooth.*
homeassistant.components.bluetooth_adapters.*
homeassistant.components.bluetooth_tracker.*
homeassistant.components.bmw_connected_drive.*
homeassistant.components.bond.*
homeassistant.components.bosch_alarm.*
@@ -142,7 +142,6 @@ homeassistant.components.cloud.*
homeassistant.components.co2signal.*
homeassistant.components.comelit.*
homeassistant.components.command_line.*
homeassistant.components.compit.*
homeassistant.components.config.*
homeassistant.components.configurator.*
homeassistant.components.cookidoo.*
@@ -170,7 +169,6 @@ homeassistant.components.dnsip.*
homeassistant.components.doorbird.*
homeassistant.components.dormakaba_dkey.*
homeassistant.components.downloader.*
homeassistant.components.droplet.*
homeassistant.components.dsmr.*
homeassistant.components.duckdns.*
homeassistant.components.dunehd.*
@@ -182,12 +180,12 @@ homeassistant.components.efergy.*
homeassistant.components.eheimdigital.*
homeassistant.components.electrasmart.*
homeassistant.components.electric_kiwi.*
homeassistant.components.elevenlabs.*
homeassistant.components.elgato.*
homeassistant.components.elkm1.*
homeassistant.components.emulated_hue.*
homeassistant.components.energenie_power_sockets.*
homeassistant.components.energy.*
homeassistant.components.energyid.*
homeassistant.components.energyzero.*
homeassistant.components.enigma2.*
homeassistant.components.enphase_envoy.*
@@ -203,7 +201,6 @@ homeassistant.components.feedreader.*
homeassistant.components.file_upload.*
homeassistant.components.filesize.*
homeassistant.components.filter.*
homeassistant.components.firefly_iii.*
homeassistant.components.fitbit.*
homeassistant.components.flexit_bacnet.*
homeassistant.components.flux_led.*
@@ -221,7 +218,6 @@ homeassistant.components.generic_thermostat.*
homeassistant.components.geo_location.*
homeassistant.components.geocaching.*
homeassistant.components.gios.*
homeassistant.components.github.*
homeassistant.components.glances.*
homeassistant.components.go2rtc.*
homeassistant.components.goalzero.*
@@ -231,7 +227,6 @@ homeassistant.components.google_cloud.*
homeassistant.components.google_drive.*
homeassistant.components.google_photos.*
homeassistant.components.google_sheets.*
homeassistant.components.google_weather.*
homeassistant.components.govee_ble.*
homeassistant.components.gpsd.*
homeassistant.components.greeneye_monitor.*
@@ -280,7 +275,6 @@ homeassistant.components.imap.*
homeassistant.components.imgw_pib.*
homeassistant.components.immich.*
homeassistant.components.incomfort.*
homeassistant.components.inels.*
homeassistant.components.input_button.*
homeassistant.components.input_select.*
homeassistant.components.input_text.*
@@ -313,7 +307,6 @@ homeassistant.components.ld2410_ble.*
homeassistant.components.led_ble.*
homeassistant.components.lektrico.*
homeassistant.components.letpot.*
homeassistant.components.libre_hardware_monitor.*
homeassistant.components.lidarr.*
homeassistant.components.lifx.*
homeassistant.components.light.*
@@ -329,7 +322,6 @@ homeassistant.components.london_underground.*
homeassistant.components.lookin.*
homeassistant.components.lovelace.*
homeassistant.components.luftdaten.*
homeassistant.components.lunatone.*
homeassistant.components.madvr.*
homeassistant.components.manual.*
homeassistant.components.mastodon.*
@@ -390,13 +382,13 @@ homeassistant.components.openai_conversation.*
homeassistant.components.openexchangerates.*
homeassistant.components.opensky.*
homeassistant.components.openuv.*
homeassistant.components.opnsense.*
homeassistant.components.opower.*
homeassistant.components.oralb.*
homeassistant.components.otbr.*
homeassistant.components.overkiz.*
homeassistant.components.overseerr.*
homeassistant.components.p1_monitor.*
homeassistant.components.pandora.*
homeassistant.components.panel_custom.*
homeassistant.components.paperless_ngx.*
homeassistant.components.peblar.*
@@ -407,7 +399,6 @@ homeassistant.components.person.*
homeassistant.components.pi_hole.*
homeassistant.components.ping.*
homeassistant.components.plugwise.*
homeassistant.components.portainer.*
homeassistant.components.powerfox.*
homeassistant.components.powerwall.*
homeassistant.components.private_ble_device.*
@@ -447,7 +438,6 @@ homeassistant.components.rituals_perfume_genie.*
homeassistant.components.roborock.*
homeassistant.components.roku.*
homeassistant.components.romy.*
homeassistant.components.route_b_smart_meter.*
homeassistant.components.rpi_power.*
homeassistant.components.rss_feed_template.*
homeassistant.components.russound_rio.*
@@ -468,7 +458,6 @@ homeassistant.components.sensorpush_cloud.*
homeassistant.components.sensoterra.*
homeassistant.components.senz.*
homeassistant.components.sfr_box.*
homeassistant.components.sftp_storage.*
homeassistant.components.shell_command.*
homeassistant.components.shelly.*
homeassistant.components.shopping_list.*
@@ -479,7 +468,6 @@ homeassistant.components.skybell.*
homeassistant.components.slack.*
homeassistant.components.sleep_as_android.*
homeassistant.components.sleepiq.*
homeassistant.components.sma.*
homeassistant.components.smhi.*
homeassistant.components.smlight.*
homeassistant.components.smtp.*
@@ -558,7 +546,6 @@ homeassistant.components.vacuum.*
homeassistant.components.vallox.*
homeassistant.components.valve.*
homeassistant.components.velbus.*
homeassistant.components.vivotek.*
homeassistant.components.vlc_telnet.*
homeassistant.components.vodafone_station.*
homeassistant.components.volvo.*
@@ -567,7 +554,6 @@ homeassistant.components.wake_word.*
homeassistant.components.wallbox.*
homeassistant.components.waqi.*
homeassistant.components.water_heater.*
homeassistant.components.watts.*
homeassistant.components.watttime.*
homeassistant.components.weather.*
homeassistant.components.webhook.*
@@ -580,7 +566,6 @@ homeassistant.components.wiz.*
homeassistant.components.wled.*
homeassistant.components.workday.*
homeassistant.components.worldclock.*
homeassistant.components.xbox.*
homeassistant.components.xiaomi_ble.*
homeassistant.components.yale_smart_alarm.*
homeassistant.components.yalexs_ble.*

View File

@@ -7,19 +7,13 @@
"python.testing.pytestEnabled": false,
// https://code.visualstudio.com/docs/python/linting#_general-settings
"pylint.importStrategy": "fromEnvironment",
// Pyright is too pedantic for Home Assistant
"python.analysis.typeCheckingMode": "basic",
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
},
"[json][jsonc][yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
},
"json.schemas": [
{
"fileMatch": ["homeassistant/components/*/manifest.json"],
// This value differs between working with devcontainer and locally, therefore this value should NOT be in sync!
"url": "./script/json_schemas/manifest_schema.json",
},
],
{
"fileMatch": [
"homeassistant/components/*/manifest.json"
],
// This value differs between working with devcontainer and locally, therefor this value should NOT be in sync!
"url": "./script/json_schemas/manifest_schema.json"
}
]
}

View File

@@ -1 +0,0 @@
.github/copilot-instructions.md

240
CODEOWNERS generated
View File

@@ -46,8 +46,6 @@ build.json @home-assistant/supervisor
/tests/components/accuweather/ @bieniu
/homeassistant/components/acmeda/ @atmurray
/tests/components/acmeda/ @atmurray
/homeassistant/components/actron_air/ @kclif9 @JagadishDhanamjayam
/tests/components/actron_air/ @kclif9 @JagadishDhanamjayam
/homeassistant/components/adax/ @danielhiversen @lazytarget
/tests/components/adax/ @danielhiversen @lazytarget
/homeassistant/components/adguard/ @frenck
@@ -69,12 +67,8 @@ build.json @home-assistant/supervisor
/tests/components/airly/ @bieniu
/homeassistant/components/airnow/ @asymworks
/tests/components/airnow/ @asymworks
/homeassistant/components/airobot/ @mettolen
/tests/components/airobot/ @mettolen
/homeassistant/components/airos/ @CoMPaTech
/tests/components/airos/ @CoMPaTech
/homeassistant/components/airpatrol/ @antondalgren
/tests/components/airpatrol/ @antondalgren
/homeassistant/components/airq/ @Sibgatulin @dl2080
/tests/components/airq/ @Sibgatulin @dl2080
/homeassistant/components/airthings/ @danielhiversen @LaStrada
@@ -93,8 +87,6 @@ build.json @home-assistant/supervisor
/tests/components/airzone/ @Noltari
/homeassistant/components/airzone_cloud/ @Noltari
/tests/components/airzone_cloud/ @Noltari
/homeassistant/components/aladdin_connect/ @swcloudgenie
/tests/components/aladdin_connect/ @swcloudgenie
/homeassistant/components/alarm_control_panel/ @home-assistant/core
/tests/components/alarm_control_panel/ @home-assistant/core
/homeassistant/components/alert/ @home-assistant/core @frenck
@@ -113,8 +105,8 @@ build.json @home-assistant/supervisor
/homeassistant/components/ambient_station/ @bachya
/tests/components/ambient_station/ @bachya
/homeassistant/components/amcrest/ @flacjacket
/homeassistant/components/analytics/ @home-assistant/core
/tests/components/analytics/ @home-assistant/core
/homeassistant/components/analytics/ @home-assistant/core @ludeeus
/tests/components/analytics/ @home-assistant/core @ludeeus
/homeassistant/components/analytics_insights/ @joostlek
/tests/components/analytics_insights/ @joostlek
/homeassistant/components/android_ip_webcam/ @engrbm87
@@ -123,8 +115,6 @@ build.json @home-assistant/supervisor
/tests/components/androidtv/ @JeffLIrion @ollo69
/homeassistant/components/androidtv_remote/ @tronikos @Drafteed
/tests/components/androidtv_remote/ @tronikos @Drafteed
/homeassistant/components/anglian_water/ @pantherale0
/tests/components/anglian_water/ @pantherale0
/homeassistant/components/anova/ @Lash-L
/tests/components/anova/ @Lash-L
/homeassistant/components/anthemav/ @hyralex
@@ -162,10 +152,10 @@ build.json @home-assistant/supervisor
/tests/components/arve/ @ikalnyi
/homeassistant/components/aseko_pool_live/ @milanmeu
/tests/components/aseko_pool_live/ @milanmeu
/homeassistant/components/assist_pipeline/ @synesthesiam @arturpragacz
/tests/components/assist_pipeline/ @synesthesiam @arturpragacz
/homeassistant/components/assist_satellite/ @home-assistant/core @synesthesiam @arturpragacz
/tests/components/assist_satellite/ @home-assistant/core @synesthesiam @arturpragacz
/homeassistant/components/assist_pipeline/ @balloob @synesthesiam
/tests/components/assist_pipeline/ @balloob @synesthesiam
/homeassistant/components/assist_satellite/ @home-assistant/core @synesthesiam
/tests/components/assist_satellite/ @home-assistant/core @synesthesiam
/homeassistant/components/asuswrt/ @kennedyshead @ollo69 @Vaskivskyi
/tests/components/asuswrt/ @kennedyshead @ollo69 @Vaskivskyi
/homeassistant/components/atag/ @MatsNL
@@ -187,8 +177,8 @@ build.json @home-assistant/supervisor
/homeassistant/components/automation/ @home-assistant/core
/tests/components/automation/ @home-assistant/core
/homeassistant/components/avea/ @pattyland
/homeassistant/components/awair/ @ahayworth @ricohageman
/tests/components/awair/ @ahayworth @ricohageman
/homeassistant/components/awair/ @ahayworth @danielsjf
/tests/components/awair/ @ahayworth @danielsjf
/homeassistant/components/aws_s3/ @tomasbedrich
/tests/components/aws_s3/ @tomasbedrich
/homeassistant/components/axis/ @Kane610
@@ -202,8 +192,6 @@ build.json @home-assistant/supervisor
/homeassistant/components/azure_service_bus/ @hfurubotten
/homeassistant/components/azure_storage/ @zweckj
/tests/components/azure_storage/ @zweckj
/homeassistant/components/backblaze_b2/ @hugo-vrijswijk @ElCruncharino
/tests/components/backblaze_b2/ @hugo-vrijswijk @ElCruncharino
/homeassistant/components/backup/ @home-assistant/core
/tests/components/backup/ @home-assistant/core
/homeassistant/components/baf/ @bdraco @jfroy
@@ -220,8 +208,8 @@ build.json @home-assistant/supervisor
/homeassistant/components/bizkaibus/ @UgaitzEtxebarria
/homeassistant/components/blebox/ @bbx-a @swistakm
/tests/components/blebox/ @bbx-a @swistakm
/homeassistant/components/blink/ @fronzbot
/tests/components/blink/ @fronzbot
/homeassistant/components/blink/ @fronzbot @mkmer
/tests/components/blink/ @fronzbot @mkmer
/homeassistant/components/blue_current/ @gleeuwen @NickKoepr @jtodorova23
/tests/components/blue_current/ @gleeuwen @NickKoepr @jtodorova23
/homeassistant/components/bluemaestro/ @bdraco
@@ -302,16 +290,14 @@ build.json @home-assistant/supervisor
/tests/components/command_line/ @gjohansson-ST
/homeassistant/components/compensation/ @Petro31
/tests/components/compensation/ @Petro31
/homeassistant/components/compit/ @Przemko92
/tests/components/compit/ @Przemko92
/homeassistant/components/config/ @home-assistant/core
/tests/components/config/ @home-assistant/core
/homeassistant/components/configurator/ @home-assistant/core
/tests/components/configurator/ @home-assistant/core
/homeassistant/components/control4/ @lawtancool @davidrecordon
/tests/components/control4/ @lawtancool @davidrecordon
/homeassistant/components/conversation/ @home-assistant/core @synesthesiam @arturpragacz
/tests/components/conversation/ @home-assistant/core @synesthesiam @arturpragacz
/homeassistant/components/control4/ @lawtancool
/tests/components/control4/ @lawtancool
/homeassistant/components/conversation/ @home-assistant/core @synesthesiam
/tests/components/conversation/ @home-assistant/core @synesthesiam
/homeassistant/components/cookidoo/ @miaucl
/tests/components/cookidoo/ @miaucl
/homeassistant/components/coolmaster/ @OnFreund
@@ -324,8 +310,8 @@ build.json @home-assistant/supervisor
/tests/components/cpuspeed/ @fabaff
/homeassistant/components/crownstone/ @Crownstone @RicArch97
/tests/components/crownstone/ @Crownstone @RicArch97
/homeassistant/components/cync/ @Kinachi249
/tests/components/cync/ @Kinachi249
/homeassistant/components/cups/ @fabaff
/tests/components/cups/ @fabaff
/homeassistant/components/daikin/ @fredrike
/tests/components/daikin/ @fredrike
/homeassistant/components/date/ @home-assistant/core
@@ -389,14 +375,10 @@ build.json @home-assistant/supervisor
/tests/components/dremel_3d_printer/ @tkdrob
/homeassistant/components/drop_connect/ @ChandlerSystems @pfrazer
/tests/components/drop_connect/ @ChandlerSystems @pfrazer
/homeassistant/components/droplet/ @sarahseidman
/tests/components/droplet/ @sarahseidman
/homeassistant/components/dsmr/ @Robbie1221
/tests/components/dsmr/ @Robbie1221
/homeassistant/components/dsmr_reader/ @sorted-bits @glodenox @erwindouna
/tests/components/dsmr_reader/ @sorted-bits @glodenox @erwindouna
/homeassistant/components/duckdns/ @tr4nt0r
/tests/components/duckdns/ @tr4nt0r
/homeassistant/components/duke_energy/ @hunterjm
/tests/components/duke_energy/ @hunterjm
/homeassistant/components/duotecno/ @cereal2nd
@@ -420,12 +402,8 @@ build.json @home-assistant/supervisor
/homeassistant/components/efergy/ @tkdrob
/tests/components/efergy/ @tkdrob
/homeassistant/components/egardia/ @jeroenterheerdt
/homeassistant/components/egauge/ @neggert
/tests/components/egauge/ @neggert
/homeassistant/components/eheimdigital/ @autinerd
/tests/components/eheimdigital/ @autinerd
/homeassistant/components/ekeybionyx/ @richardpolzer
/tests/components/ekeybionyx/ @richardpolzer
/homeassistant/components/electrasmart/ @jafar-atili
/tests/components/electrasmart/ @jafar-atili
/homeassistant/components/electric_kiwi/ @mikey0000
@@ -444,8 +422,6 @@ build.json @home-assistant/supervisor
/homeassistant/components/emby/ @mezz64
/homeassistant/components/emoncms/ @borpin @alexandrecuer
/tests/components/emoncms/ @borpin @alexandrecuer
/homeassistant/components/emoncms_history/ @alexandrecuer
/tests/components/emoncms_history/ @alexandrecuer
/homeassistant/components/emonitor/ @bdraco
/tests/components/emonitor/ @bdraco
/homeassistant/components/emulated_hue/ @bdraco @Tho85
@@ -456,15 +432,15 @@ build.json @home-assistant/supervisor
/tests/components/energenie_power_sockets/ @gnumpi
/homeassistant/components/energy/ @home-assistant/core
/tests/components/energy/ @home-assistant/core
/homeassistant/components/energyid/ @JrtPec @Molier
/tests/components/energyid/ @JrtPec @Molier
/homeassistant/components/energyzero/ @klaasnicolaas
/tests/components/energyzero/ @klaasnicolaas
/homeassistant/components/enigma2/ @autinerd
/tests/components/enigma2/ @autinerd
/homeassistant/components/enocean/ @bdurrer
/tests/components/enocean/ @bdurrer
/homeassistant/components/enphase_envoy/ @bdraco @cgarwood @catsmanac
/tests/components/enphase_envoy/ @bdraco @cgarwood @catsmanac
/homeassistant/components/entur_public_transport/ @hfurubotten @SanderBlom
/homeassistant/components/entur_public_transport/ @hfurubotten
/homeassistant/components/environment_canada/ @gwww @michaeldavie
/tests/components/environment_canada/ @gwww @michaeldavie
/homeassistant/components/ephember/ @ttroy50 @roberty99
@@ -480,12 +456,12 @@ build.json @home-assistant/supervisor
/tests/components/escea/ @lazdavila
/homeassistant/components/esphome/ @jesserockz @kbx81 @bdraco
/tests/components/esphome/ @jesserockz @kbx81 @bdraco
/homeassistant/components/essent/ @jaapp
/tests/components/essent/ @jaapp
/homeassistant/components/eufylife_ble/ @bdr99
/tests/components/eufylife_ble/ @bdr99
/homeassistant/components/event/ @home-assistant/core
/tests/components/event/ @home-assistant/core
/homeassistant/components/evil_genius_labs/ @balloob
/tests/components/evil_genius_labs/ @balloob
/homeassistant/components/evohome/ @zxdavb
/tests/components/evohome/ @zxdavb
/homeassistant/components/ezviz/ @RenierM26
@@ -508,16 +484,10 @@ build.json @home-assistant/supervisor
/tests/components/filesize/ @gjohansson-ST
/homeassistant/components/filter/ @dgomes
/tests/components/filter/ @dgomes
/homeassistant/components/fing/ @Lorenzo-Gasparini
/tests/components/fing/ @Lorenzo-Gasparini
/homeassistant/components/firefly_iii/ @erwindouna
/tests/components/firefly_iii/ @erwindouna
/homeassistant/components/fireservicerota/ @cyberjunky
/tests/components/fireservicerota/ @cyberjunky
/homeassistant/components/firmata/ @DaAwesomeP
/tests/components/firmata/ @DaAwesomeP
/homeassistant/components/fish_audio/ @noambav
/tests/components/fish_audio/ @noambav
/homeassistant/components/fitbit/ @allenporter
/tests/components/fitbit/ @allenporter
/homeassistant/components/fivem/ @Sander0542
@@ -526,14 +496,14 @@ build.json @home-assistant/supervisor
/tests/components/fjaraskupan/ @elupus
/homeassistant/components/flexit_bacnet/ @lellky @piotrbulinski
/tests/components/flexit_bacnet/ @lellky @piotrbulinski
/homeassistant/components/flick_electric/ @ZephireNZ
/tests/components/flick_electric/ @ZephireNZ
/homeassistant/components/flipr/ @cnico
/tests/components/flipr/ @cnico
/homeassistant/components/flo/ @dmulcahey
/tests/components/flo/ @dmulcahey
/homeassistant/components/flume/ @ChrisMandich @bdraco @jeeftor
/tests/components/flume/ @ChrisMandich @bdraco @jeeftor
/homeassistant/components/fluss/ @fluss
/tests/components/fluss/ @fluss
/homeassistant/components/flux_led/ @icemanch
/tests/components/flux_led/ @icemanch
/homeassistant/components/forecast_solar/ @klaasnicolaas @frenck
@@ -541,14 +511,12 @@ build.json @home-assistant/supervisor
/homeassistant/components/forked_daapd/ @uvjustin
/tests/components/forked_daapd/ @uvjustin
/homeassistant/components/fortios/ @kimfrellsen
/homeassistant/components/foscam/ @Foscam-wangzhengyu
/tests/components/foscam/ @Foscam-wangzhengyu
/homeassistant/components/foscam/ @krmarien
/tests/components/foscam/ @krmarien
/homeassistant/components/freebox/ @hacf-fr @Quentame
/tests/components/freebox/ @hacf-fr @Quentame
/homeassistant/components/freedompro/ @stefano055415
/tests/components/freedompro/ @stefano055415
/homeassistant/components/fressnapf_tracker/ @eifinger
/tests/components/fressnapf_tracker/ @eifinger
/homeassistant/components/fritz/ @AaronDavidSchneider @chemelli74 @mib1185
/tests/components/fritz/ @AaronDavidSchneider @chemelli74 @mib1185
/homeassistant/components/fritzbox/ @mib1185 @flabbamann
@@ -579,8 +547,6 @@ build.json @home-assistant/supervisor
/tests/components/generic_hygrostat/ @Shulyaka
/homeassistant/components/geniushub/ @manzanotti
/tests/components/geniushub/ @manzanotti
/homeassistant/components/gentex_homelink/ @niaexa @ryanjones-gentex
/tests/components/gentex_homelink/ @niaexa @ryanjones-gentex
/homeassistant/components/geo_json_events/ @exxamalte
/tests/components/geo_json_events/ @exxamalte
/homeassistant/components/geo_location/ @home-assistant/core
@@ -609,8 +575,6 @@ build.json @home-assistant/supervisor
/tests/components/goodwe/ @mletenay @starkillerOG
/homeassistant/components/google/ @allenporter
/tests/components/google/ @allenporter
/homeassistant/components/google_air_quality/ @Thomas55555
/tests/components/google_air_quality/ @Thomas55555
/homeassistant/components/google_assistant/ @home-assistant/cloud
/tests/components/google_assistant/ @home-assistant/cloud
/homeassistant/components/google_assistant_sdk/ @tronikos
@@ -631,8 +595,6 @@ build.json @home-assistant/supervisor
/tests/components/google_tasks/ @allenporter
/homeassistant/components/google_travel_time/ @eifinger
/tests/components/google_travel_time/ @eifinger
/homeassistant/components/google_weather/ @tronikos
/tests/components/google_weather/ @tronikos
/homeassistant/components/govee_ble/ @bdraco
/tests/components/govee_ble/ @bdraco
/homeassistant/components/govee_light_local/ @Galorhallen
@@ -645,14 +607,10 @@ build.json @home-assistant/supervisor
/tests/components/greeneye_monitor/ @jkeljo
/homeassistant/components/group/ @home-assistant/core
/tests/components/group/ @home-assistant/core
/homeassistant/components/growatt_server/ @johanzander
/tests/components/growatt_server/ @johanzander
/homeassistant/components/guardian/ @bachya
/tests/components/guardian/ @bachya
/homeassistant/components/habitica/ @tr4nt0r
/tests/components/habitica/ @tr4nt0r
/homeassistant/components/hanna/ @bestycame
/tests/components/hanna/ @bestycame
/homeassistant/components/hardkernel/ @home-assistant/core
/tests/components/hardkernel/ @home-assistant/core
/homeassistant/components/hardware/ @home-assistant/core
@@ -661,8 +619,6 @@ build.json @home-assistant/supervisor
/tests/components/harmony/ @ehendrix23 @bdraco @mkeesey @Aohzan
/homeassistant/components/hassio/ @home-assistant/supervisor
/tests/components/hassio/ @home-assistant/supervisor
/homeassistant/components/hdfury/ @glenndehaan
/tests/components/hdfury/ @glenndehaan
/homeassistant/components/hdmi_cec/ @inytar
/tests/components/hdmi_cec/ @inytar
/homeassistant/components/heatmiser/ @andylockran
@@ -670,8 +626,7 @@ build.json @home-assistant/supervisor
/tests/components/heos/ @andrewsayre
/homeassistant/components/here_travel_time/ @eifinger
/tests/components/here_travel_time/ @eifinger
/homeassistant/components/hikvision/ @mezz64 @ptarjan
/tests/components/hikvision/ @mezz64 @ptarjan
/homeassistant/components/hikvision/ @mezz64
/homeassistant/components/hikvisioncam/ @fbradyirl
/homeassistant/components/hisense_aehw4a1/ @bannhead
/tests/components/hisense_aehw4a1/ @bannhead
@@ -691,8 +646,6 @@ build.json @home-assistant/supervisor
/tests/components/homeassistant/ @home-assistant/core
/homeassistant/components/homeassistant_alerts/ @home-assistant/core
/tests/components/homeassistant_alerts/ @home-assistant/core
/homeassistant/components/homeassistant_connect_zbt2/ @home-assistant/core
/tests/components/homeassistant_connect_zbt2/ @home-assistant/core
/homeassistant/components/homeassistant_green/ @home-assistant/core
/tests/components/homeassistant_green/ @home-assistant/core
/homeassistant/components/homeassistant_hardware/ @home-assistant/core
@@ -721,10 +674,8 @@ build.json @home-assistant/supervisor
/tests/components/http/ @home-assistant/core
/homeassistant/components/huawei_lte/ @scop @fphammerle
/tests/components/huawei_lte/ @scop @fphammerle
/homeassistant/components/hue/ @marcelveldt
/tests/components/hue/ @marcelveldt
/homeassistant/components/hue_ble/ @flip-dots
/tests/components/hue_ble/ @flip-dots
/homeassistant/components/hue/ @balloob @marcelveldt
/tests/components/hue/ @balloob @marcelveldt
/homeassistant/components/huisbaasje/ @dennisschroer
/tests/components/huisbaasje/ @dennisschroer
/homeassistant/components/humidifier/ @home-assistant/core @Shulyaka
@@ -774,8 +725,6 @@ build.json @home-assistant/supervisor
/tests/components/improv_ble/ @emontnemery
/homeassistant/components/incomfort/ @jbouwh
/tests/components/incomfort/ @jbouwh
/homeassistant/components/inels/ @epdevlab
/tests/components/inels/ @epdevlab
/homeassistant/components/influxdb/ @mdegat01
/tests/components/influxdb/ @mdegat01
/homeassistant/components/inkbird/ @bdraco
@@ -798,13 +747,11 @@ build.json @home-assistant/supervisor
/tests/components/integration/ @dgomes
/homeassistant/components/intellifire/ @jeeftor
/tests/components/intellifire/ @jeeftor
/homeassistant/components/intent/ @home-assistant/core @synesthesiam @arturpragacz
/tests/components/intent/ @home-assistant/core @synesthesiam @arturpragacz
/homeassistant/components/intent_script/ @arturpragacz
/tests/components/intent_script/ @arturpragacz
/homeassistant/components/intent/ @home-assistant/core @synesthesiam
/tests/components/intent/ @home-assistant/core @synesthesiam
/homeassistant/components/intesishome/ @jnimmo
/homeassistant/components/iometer/ @jukrebs
/tests/components/iometer/ @jukrebs
/homeassistant/components/iometer/ @MaestroOnICe
/tests/components/iometer/ @MaestroOnICe
/homeassistant/components/ios/ @robbiet480
/tests/components/ios/ @robbiet480
/homeassistant/components/iotawatt/ @gtdiehl @jyavenard
@@ -819,8 +766,6 @@ build.json @home-assistant/supervisor
/homeassistant/components/iqvia/ @bachya
/tests/components/iqvia/ @bachya
/homeassistant/components/irish_rail_transport/ @ttroy50
/homeassistant/components/irm_kmi/ @jdejaegh
/tests/components/irm_kmi/ @jdejaegh
/homeassistant/components/iron_os/ @tr4nt0r
/tests/components/iron_os/ @tr4nt0r
/homeassistant/components/isal/ @bdraco
@@ -879,8 +824,6 @@ build.json @home-assistant/supervisor
/tests/components/kraken/ @eifinger
/homeassistant/components/kulersky/ @emlove
/tests/components/kulersky/ @emlove
/homeassistant/components/labs/ @home-assistant/core
/tests/components/labs/ @home-assistant/core
/homeassistant/components/lacrosse_view/ @IceBotYT
/tests/components/lacrosse_view/ @IceBotYT
/homeassistant/components/lamarzocco/ @zweckj
@@ -913,8 +856,6 @@ build.json @home-assistant/supervisor
/tests/components/lg_netcast/ @Drafteed @splinter98
/homeassistant/components/lg_thinq/ @LG-ThinQ-Integration
/tests/components/lg_thinq/ @LG-ThinQ-Integration
/homeassistant/components/libre_hardware_monitor/ @Sab44
/tests/components/libre_hardware_monitor/ @Sab44
/homeassistant/components/lidarr/ @tkdrob
/tests/components/lidarr/ @tkdrob
/homeassistant/components/lifx/ @Djelibeybi
@@ -953,8 +894,6 @@ build.json @home-assistant/supervisor
/homeassistant/components/luci/ @mzdrale
/homeassistant/components/luftdaten/ @fabaff @frenck
/tests/components/luftdaten/ @fabaff @frenck
/homeassistant/components/lunatone/ @MoonDevLT
/tests/components/lunatone/ @MoonDevLT
/homeassistant/components/lupusec/ @majuss @suaveolent
/tests/components/lupusec/ @majuss @suaveolent
/homeassistant/components/lutron/ @cdheiser @wilburCForce
@@ -1000,8 +939,6 @@ build.json @home-assistant/supervisor
/tests/components/met_eireann/ @DylanGore
/homeassistant/components/meteo_france/ @hacf-fr @oncleben31 @Quentame
/tests/components/meteo_france/ @hacf-fr @oncleben31 @Quentame
/homeassistant/components/meteo_lt/ @xE1H
/tests/components/meteo_lt/ @xE1H
/homeassistant/components/meteoalarm/ @rolfberkenbosch
/homeassistant/components/meteoclimatic/ @adrianmo
/tests/components/meteoclimatic/ @adrianmo
@@ -1054,8 +991,8 @@ build.json @home-assistant/supervisor
/homeassistant/components/msteams/ @peroyvind
/homeassistant/components/mullvad/ @meichthys
/tests/components/mullvad/ @meichthys
/homeassistant/components/music_assistant/ @music-assistant @arturpragacz
/tests/components/music_assistant/ @music-assistant @arturpragacz
/homeassistant/components/music_assistant/ @music-assistant
/tests/components/music_assistant/ @music-assistant
/homeassistant/components/mutesync/ @currentoor
/tests/components/mutesync/ @currentoor
/homeassistant/components/my/ @home-assistant/core
@@ -1072,8 +1009,7 @@ build.json @home-assistant/supervisor
/tests/components/nanoleaf/ @milanmeu @joostlek
/homeassistant/components/nasweb/ @nasWebio
/tests/components/nasweb/ @nasWebio
/homeassistant/components/nederlandse_spoorwegen/ @YarmoM @heindrichpaul
/tests/components/nederlandse_spoorwegen/ @YarmoM @heindrichpaul
/homeassistant/components/nederlandse_spoorwegen/ @YarmoM
/homeassistant/components/ness_alarm/ @nickw444
/tests/components/ness_alarm/ @nickw444
/homeassistant/components/nest/ @allenporter
@@ -1108,8 +1044,6 @@ build.json @home-assistant/supervisor
/homeassistant/components/nilu/ @hfurubotten
/homeassistant/components/nina/ @DeerMaximum
/tests/components/nina/ @DeerMaximum
/homeassistant/components/nintendo_parental_controls/ @pantherale0
/tests/components/nintendo_parental_controls/ @pantherale0
/homeassistant/components/nissan_leaf/ @filcole
/homeassistant/components/noaa_tides/ @jdelaney72
/homeassistant/components/nobo_hub/ @echoromeo @oyvindwe
@@ -1170,18 +1104,16 @@ build.json @home-assistant/supervisor
/tests/components/open_meteo/ @frenck
/homeassistant/components/open_router/ @joostlek
/tests/components/open_router/ @joostlek
/homeassistant/components/openai_conversation/ @balloob
/tests/components/openai_conversation/ @balloob
/homeassistant/components/openerz/ @misialq
/tests/components/openerz/ @misialq
/homeassistant/components/openevse/ @c00w @firstof9
/tests/components/openevse/ @c00w @firstof9
/homeassistant/components/openexchangerates/ @MartinHjelmare
/tests/components/openexchangerates/ @MartinHjelmare
/homeassistant/components/opengarage/ @danielhiversen
/tests/components/opengarage/ @danielhiversen
/homeassistant/components/openhome/ @bazwilliams
/tests/components/openhome/ @bazwilliams
/homeassistant/components/openrgb/ @felipecrs
/tests/components/openrgb/ @felipecrs
/homeassistant/components/opensky/ @joostlek
/tests/components/opensky/ @joostlek
/homeassistant/components/opentherm_gw/ @mvn23
@@ -1205,8 +1137,8 @@ build.json @home-assistant/supervisor
/tests/components/ourgroceries/ @OnFreund
/homeassistant/components/overkiz/ @imicknl
/tests/components/overkiz/ @imicknl
/homeassistant/components/overseerr/ @joostlek @AmGarera
/tests/components/overseerr/ @joostlek @AmGarera
/homeassistant/components/overseerr/ @joostlek
/tests/components/overseerr/ @joostlek
/homeassistant/components/ovo_energy/ @timmo001
/tests/components/ovo_energy/ @timmo001
/homeassistant/components/p1_monitor/ @klaasnicolaas
@@ -1245,14 +1177,12 @@ build.json @home-assistant/supervisor
/tests/components/plex/ @jjlawren
/homeassistant/components/plugwise/ @CoMPaTech @bouwew
/tests/components/plugwise/ @CoMPaTech @bouwew
/homeassistant/components/plum_lightpad/ @ColinHarrington @prystupa
/tests/components/plum_lightpad/ @ColinHarrington @prystupa
/homeassistant/components/point/ @fredrike
/tests/components/point/ @fredrike
/homeassistant/components/pooldose/ @lmaertin
/tests/components/pooldose/ @lmaertin
/homeassistant/components/poolsense/ @haemishkyd
/tests/components/poolsense/ @haemishkyd
/homeassistant/components/portainer/ @erwindouna
/tests/components/portainer/ @erwindouna
/homeassistant/components/powerfox/ @klaasnicolaas
/tests/components/powerfox/ @klaasnicolaas
/homeassistant/components/powerwall/ @bdraco @jrester @daniel-simpson
@@ -1272,6 +1202,8 @@ build.json @home-assistant/supervisor
/homeassistant/components/proximity/ @mib1185
/tests/components/proximity/ @mib1185
/homeassistant/components/proxmoxve/ @jhollowe @Corbeno
/homeassistant/components/prusalink/ @balloob
/tests/components/prusalink/ @balloob
/homeassistant/components/ps4/ @ktnrg45
/tests/components/ps4/ @ktnrg45
/homeassistant/components/pterodactyl/ @elmurato
@@ -1365,16 +1297,16 @@ build.json @home-assistant/supervisor
/tests/components/rflink/ @javicalle
/homeassistant/components/rfxtrx/ @danielhiversen @elupus @RobBie1221
/tests/components/rfxtrx/ @danielhiversen @elupus @RobBie1221
/homeassistant/components/rhasspy/ @synesthesiam
/tests/components/rhasspy/ @synesthesiam
/homeassistant/components/rhasspy/ @balloob @synesthesiam
/tests/components/rhasspy/ @balloob @synesthesiam
/homeassistant/components/ridwell/ @bachya
/tests/components/ridwell/ @bachya
/homeassistant/components/ring/ @sdb9696
/tests/components/ring/ @sdb9696
/homeassistant/components/risco/ @OnFreund
/tests/components/risco/ @OnFreund
/homeassistant/components/rituals_perfume_genie/ @milanmeu @frenck @quebulm
/tests/components/rituals_perfume_genie/ @milanmeu @frenck @quebulm
/homeassistant/components/rituals_perfume_genie/ @milanmeu @frenck
/tests/components/rituals_perfume_genie/ @milanmeu @frenck
/homeassistant/components/rmvtransport/ @cgtobi
/tests/components/rmvtransport/ @cgtobi
/homeassistant/components/roborock/ @Lash-L @allenporter
@@ -1387,8 +1319,6 @@ build.json @home-assistant/supervisor
/tests/components/roomba/ @pschmitt @cyr-ius @shenxn @Orhideous
/homeassistant/components/roon/ @pavoni
/tests/components/roon/ @pavoni
/homeassistant/components/route_b_smart_meter/ @SeraphicRav
/tests/components/route_b_smart_meter/ @SeraphicRav
/homeassistant/components/rpi_power/ @shenxn @swetoast
/tests/components/rpi_power/ @shenxn @swetoast
/homeassistant/components/rss_feed_template/ @home-assistant/core
@@ -1411,10 +1341,6 @@ build.json @home-assistant/supervisor
/tests/components/samsungtv/ @chemelli74 @epenet
/homeassistant/components/sanix/ @tomaszsluszniak
/tests/components/sanix/ @tomaszsluszniak
/homeassistant/components/satel_integra/ @Tommatheussen
/tests/components/satel_integra/ @Tommatheussen
/homeassistant/components/saunum/ @mettolen
/tests/components/saunum/ @mettolen
/homeassistant/components/scene/ @home-assistant/core
/tests/components/scene/ @home-assistant/core
/homeassistant/components/schedule/ @home-assistant/core
@@ -1460,14 +1386,12 @@ build.json @home-assistant/supervisor
/tests/components/seventeentrack/ @shaiu
/homeassistant/components/sfr_box/ @epenet
/tests/components/sfr_box/ @epenet
/homeassistant/components/sftp_storage/ @maretodoric
/tests/components/sftp_storage/ @maretodoric
/homeassistant/components/sharkiq/ @JeffResc @funkybunch @TheOneOgre
/tests/components/sharkiq/ @JeffResc @funkybunch @TheOneOgre
/homeassistant/components/sharkiq/ @JeffResc @funkybunch
/tests/components/sharkiq/ @JeffResc @funkybunch
/homeassistant/components/shell_command/ @home-assistant/core
/tests/components/shell_command/ @home-assistant/core
/homeassistant/components/shelly/ @bieniu @thecode @chemelli74 @bdraco
/tests/components/shelly/ @bieniu @thecode @chemelli74 @bdraco
/homeassistant/components/shelly/ @balloob @bieniu @thecode @chemelli74 @bdraco
/tests/components/shelly/ @balloob @bieniu @thecode @chemelli74 @bdraco
/homeassistant/components/shodan/ @fabaff
/homeassistant/components/sia/ @eavanvalkenburg
/tests/components/sia/ @eavanvalkenburg
@@ -1518,6 +1442,8 @@ build.json @home-assistant/supervisor
/tests/components/smhi/ @gjohansson-ST
/homeassistant/components/smlight/ @tl-sl
/tests/components/smlight/ @tl-sl
/homeassistant/components/sms/ @ocalvo
/tests/components/sms/ @ocalvo
/homeassistant/components/snapcast/ @luar123
/tests/components/snapcast/ @luar123
/homeassistant/components/snmp/ @nmaggioni
@@ -1526,8 +1452,8 @@ build.json @home-assistant/supervisor
/tests/components/snoo/ @Lash-L
/homeassistant/components/snooz/ @AustinBrunkhorst
/tests/components/snooz/ @AustinBrunkhorst
/homeassistant/components/solaredge/ @frenck @bdraco @tronikos
/tests/components/solaredge/ @frenck @bdraco @tronikos
/homeassistant/components/solaredge/ @frenck @bdraco
/tests/components/solaredge/ @frenck @bdraco
/homeassistant/components/solaredge_local/ @drobtravels @scheric
/homeassistant/components/solarlog/ @Ernst79 @dontinelli
/tests/components/solarlog/ @Ernst79 @dontinelli
@@ -1580,8 +1506,6 @@ build.json @home-assistant/supervisor
/tests/components/suez_water/ @ooii @jb101010-2
/homeassistant/components/sun/ @home-assistant/core
/tests/components/sun/ @home-assistant/core
/homeassistant/components/sunricher_dali/ @niracler
/tests/components/sunricher_dali/ @niracler
/homeassistant/components/supla/ @mwegrzynek
/homeassistant/components/surepetcare/ @benleb @danielhiversen
/tests/components/surepetcare/ @benleb @danielhiversen
@@ -1596,8 +1520,8 @@ build.json @home-assistant/supervisor
/tests/components/switchbee/ @jafar-atili
/homeassistant/components/switchbot/ @danielhiversen @RenierM26 @murtas @Eloston @dsypniewski @zerzhang
/tests/components/switchbot/ @danielhiversen @RenierM26 @murtas @Eloston @dsypniewski @zerzhang
/homeassistant/components/switchbot_cloud/ @SeraphicRav @laurence-presland @Gigatrappeur @XiaoLing-git
/tests/components/switchbot_cloud/ @SeraphicRav @laurence-presland @Gigatrappeur @XiaoLing-git
/homeassistant/components/switchbot_cloud/ @SeraphicRav @laurence-presland @Gigatrappeur
/tests/components/switchbot_cloud/ @SeraphicRav @laurence-presland @Gigatrappeur
/homeassistant/components/switcher_kis/ @thecode @YogevBokobza
/tests/components/switcher_kis/ @thecode @YogevBokobza
/homeassistant/components/switchmate/ @danielhiversen @qiz-li
@@ -1614,8 +1538,8 @@ build.json @home-assistant/supervisor
/tests/components/systemmonitor/ @gjohansson-ST
/homeassistant/components/tado/ @erwindouna
/tests/components/tado/ @erwindouna
/homeassistant/components/tag/ @home-assistant/core
/tests/components/tag/ @home-assistant/core
/homeassistant/components/tag/ @balloob @dmulcahey
/tests/components/tag/ @balloob @dmulcahey
/homeassistant/components/tailscale/ @frenck
/tests/components/tailscale/ @frenck
/homeassistant/components/tailwind/ @frenck
@@ -1703,8 +1627,8 @@ build.json @home-assistant/supervisor
/tests/components/trafikverket_train/ @gjohansson-ST
/homeassistant/components/trafikverket_weatherstation/ @gjohansson-ST
/tests/components/trafikverket_weatherstation/ @gjohansson-ST
/homeassistant/components/transmission/ @engrbm87 @JPHutchins @andrew-codechimp
/tests/components/transmission/ @engrbm87 @JPHutchins @andrew-codechimp
/homeassistant/components/transmission/ @engrbm87 @JPHutchins
/tests/components/transmission/ @engrbm87 @JPHutchins
/homeassistant/components/trend/ @jpbede
/tests/components/trend/ @jpbede
/homeassistant/components/triggercmd/ @rvmey
@@ -1742,8 +1666,6 @@ build.json @home-assistant/supervisor
/tests/components/uptime_kuma/ @tr4nt0r
/homeassistant/components/uptimerobot/ @ludeeus @chemelli74
/tests/components/uptimerobot/ @ludeeus @chemelli74
/homeassistant/components/usage_prediction/ @home-assistant/core
/tests/components/usage_prediction/ @home-assistant/core
/homeassistant/components/usb/ @bdraco
/tests/components/usb/ @bdraco
/homeassistant/components/usgs_earthquakes_feed/ @exxamalte
@@ -1758,43 +1680,40 @@ build.json @home-assistant/supervisor
/tests/components/vallox/ @andre-richter @slovdahl @viiru- @yozik04
/homeassistant/components/valve/ @home-assistant/core
/tests/components/valve/ @home-assistant/core
/homeassistant/components/vegehub/ @thulrus
/tests/components/vegehub/ @thulrus
/homeassistant/components/vegehub/ @ghowevege
/tests/components/vegehub/ @ghowevege
/homeassistant/components/velbus/ @Cereal2nd @brefra
/tests/components/velbus/ @Cereal2nd @brefra
/homeassistant/components/velux/ @Julius2342 @DeerMaximum @pawlizio @wollew
/tests/components/velux/ @Julius2342 @DeerMaximum @pawlizio @wollew
/homeassistant/components/velux/ @Julius2342 @DeerMaximum @pawlizio
/tests/components/velux/ @Julius2342 @DeerMaximum @pawlizio
/homeassistant/components/venstar/ @garbled1 @jhollowe
/tests/components/venstar/ @garbled1 @jhollowe
/homeassistant/components/versasense/ @imstevenxyz
/homeassistant/components/version/ @ludeeus
/tests/components/version/ @ludeeus
/homeassistant/components/vesync/ @markperdue @webdjoe @thegardenmonkey @cdnninja @iprak @sapuseven
/tests/components/vesync/ @markperdue @webdjoe @thegardenmonkey @cdnninja @iprak @sapuseven
/homeassistant/components/vesync/ @markperdue @webdjoe @thegardenmonkey @cdnninja @iprak
/tests/components/vesync/ @markperdue @webdjoe @thegardenmonkey @cdnninja @iprak
/homeassistant/components/vicare/ @CFenner
/tests/components/vicare/ @CFenner
/homeassistant/components/victron_ble/ @rajlaud
/tests/components/victron_ble/ @rajlaud
/homeassistant/components/victron_remote_monitoring/ @AndyTempel
/tests/components/victron_remote_monitoring/ @AndyTempel
/homeassistant/components/vilfo/ @ManneW
/tests/components/vilfo/ @ManneW
/homeassistant/components/vivotek/ @HarlemSquirrel
/tests/components/vivotek/ @HarlemSquirrel
/homeassistant/components/vizio/ @raman325
/tests/components/vizio/ @raman325
/homeassistant/components/vlc_telnet/ @rodripf @MartinHjelmare
/tests/components/vlc_telnet/ @rodripf @MartinHjelmare
/homeassistant/components/vodafone_station/ @paoloantinori @chemelli74
/tests/components/vodafone_station/ @paoloantinori @chemelli74
/homeassistant/components/voip/ @synesthesiam @jaminh
/tests/components/voip/ @synesthesiam @jaminh
/homeassistant/components/voip/ @balloob @synesthesiam @jaminh
/tests/components/voip/ @balloob @synesthesiam @jaminh
/homeassistant/components/volumio/ @OnFreund
/tests/components/volumio/ @OnFreund
/homeassistant/components/volvo/ @thomasddn
/tests/components/volvo/ @thomasddn
/homeassistant/components/volvooncall/ @molobrakos @svrooij
/tests/components/volvooncall/ @molobrakos @svrooij
/homeassistant/components/volvooncall/ @molobrakos
/tests/components/volvooncall/ @molobrakos
/homeassistant/components/vulcan/ @Antoni-Czaplicki
/tests/components/vulcan/ @Antoni-Czaplicki
/homeassistant/components/wake_on_lan/ @ntilley905
/tests/components/wake_on_lan/ @ntilley905
/homeassistant/components/wake_word/ @home-assistant/core @synesthesiam
@@ -1805,12 +1724,9 @@ build.json @home-assistant/supervisor
/tests/components/waqi/ @joostlek
/homeassistant/components/water_heater/ @home-assistant/core
/tests/components/water_heater/ @home-assistant/core
/homeassistant/components/waterfurnace/ @sdague @masterkoppa
/homeassistant/components/watergate/ @adam-the-hero
/tests/components/watergate/ @adam-the-hero
/homeassistant/components/watson_tts/ @rutkai
/homeassistant/components/watts/ @theobld-ww @devender-verma-ww @ssi-spyro
/tests/components/watts/ @theobld-ww @devender-verma-ww @ssi-spyro
/homeassistant/components/watttime/ @bachya
/tests/components/watttime/ @bachya
/homeassistant/components/waze_travel_time/ @eifinger
@@ -1823,8 +1739,6 @@ build.json @home-assistant/supervisor
/tests/components/weatherflow_cloud/ @jeeftor
/homeassistant/components/weatherkit/ @tjhorner
/tests/components/weatherkit/ @tjhorner
/homeassistant/components/web_rtc/ @home-assistant/core
/tests/components/web_rtc/ @home-assistant/core
/homeassistant/components/webdav/ @jpbede
/tests/components/webdav/ @jpbede
/homeassistant/components/webhook/ @home-assistant/core
@@ -1864,10 +1778,10 @@ build.json @home-assistant/supervisor
/tests/components/worldclock/ @fabaff
/homeassistant/components/ws66i/ @ssaenger
/tests/components/ws66i/ @ssaenger
/homeassistant/components/wyoming/ @synesthesiam
/tests/components/wyoming/ @synesthesiam
/homeassistant/components/xbox/ @hunterjm @tr4nt0r
/tests/components/xbox/ @hunterjm @tr4nt0r
/homeassistant/components/wyoming/ @balloob @synesthesiam
/tests/components/wyoming/ @balloob @synesthesiam
/homeassistant/components/xbox/ @hunterjm
/tests/components/xbox/ @hunterjm
/homeassistant/components/xiaomi_aqara/ @danielhiversen @syssi
/tests/components/xiaomi_aqara/ @danielhiversen @syssi
/homeassistant/components/xiaomi_ble/ @Jc2k @Ernst79

View File

@@ -14,8 +14,5 @@ Still interested? Then you should take a peek at the [developer documentation](h
## Feature suggestions
If you want to suggest a new feature for Home Assistant (e.g. new integrations), please [start a discussion](https://github.com/orgs/home-assistant/discussions) on GitHub.
## Issue Tracker
If you want to report an issue, please [create an issue](https://github.com/home-assistant/core/issues) on GitHub.
If you want to suggest a new feature for Home Assistant (e.g., new integrations), please open a thread in our [Community Forum: Feature Requests](https://community.home-assistant.io/c/feature-requests).
We use [GitHub for tracking issues](https://github.com/home-assistant/core/issues), not for tracking feature requests.

33
Dockerfile generated
View File

@@ -4,33 +4,34 @@
ARG BUILD_FROM
FROM ${BUILD_FROM}
LABEL \
io.hass.type="core" \
org.opencontainers.image.authors="The Home Assistant Authors" \
org.opencontainers.image.description="Open-source home automation platform running on Python 3" \
org.opencontainers.image.documentation="https://www.home-assistant.io/docs/" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.source="https://github.com/home-assistant/core" \
org.opencontainers.image.title="Home Assistant" \
org.opencontainers.image.url="https://www.home-assistant.io/"
# Synchronize with homeassistant/core.py:async_stop
ENV \
S6_SERVICES_GRACETIME=240000 \
UV_SYSTEM_PYTHON=true \
UV_NO_CACHE=true
ARG QEMU_CPU
# Home Assistant S6-Overlay
COPY rootfs /
# Add go2rtc binary
COPY --from=ghcr.io/alexxit/go2rtc@sha256:f394f6329f5389a4c9a7fc54b09fdec9621bbb78bf7a672b973440bbdfb02241 /usr/local/bin/go2rtc /bin/go2rtc
# Needs to be redefined inside the FROM statement to be set for RUN commands
ARG BUILD_ARCH
# Get go2rtc binary
RUN \
case "${BUILD_ARCH}" in \
"aarch64") go2rtc_suffix='arm64' ;; \
"armhf") go2rtc_suffix='armv6' ;; \
"armv7") go2rtc_suffix='arm' ;; \
*) go2rtc_suffix=${BUILD_ARCH} ;; \
esac \
&& curl -L https://github.com/AlexxIT/go2rtc/releases/download/v1.9.9/go2rtc_linux_${go2rtc_suffix} --output /bin/go2rtc \
&& chmod +x /bin/go2rtc \
# Verify go2rtc can be executed
go2rtc --version \
# Install uv
&& pip3 install uv==0.9.17
&& go2rtc --version
# Install uv
RUN pip3 install uv==0.8.9
WORKDIR /usr/src

View File

@@ -3,7 +3,8 @@ FROM mcr.microsoft.com/vscode/devcontainers/base:debian
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN \
apt-get update \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
# Additional library needed by some tests and accordingly by VScode Tests Discovery
bluez \
@@ -13,6 +14,7 @@ RUN \
libavcodec-dev \
libavdevice-dev \
libavutil-dev \
libgammu-dev \
libswscale-dev \
libswresample-dev \
libavfilter-dev \
@@ -33,24 +35,25 @@ WORKDIR /usr/src
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
USER vscode
RUN uv python install 3.13.2
USER vscode
ENV VIRTUAL_ENV="/home/vscode/.local/ha-venv"
RUN --mount=type=bind,source=.python-version,target=.python-version \
uv python install \
&& uv venv $VIRTUAL_ENV
RUN uv venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
WORKDIR /tmp
# Setup hass-release
RUN git clone --depth 1 https://github.com/home-assistant/hass-release ~/hass-release \
&& uv pip install -e ~/hass-release/
# Install Python dependencies from requirements
RUN --mount=type=bind,source=requirements.txt,target=requirements.txt \
--mount=type=bind,source=homeassistant/package_constraints.txt,target=homeassistant/package_constraints.txt \
--mount=type=bind,source=requirements_test.txt,target=requirements_test.txt \
--mount=type=bind,source=requirements_test_pre_commit.txt,target=requirements_test_pre_commit.txt \
uv pip install -r requirements.txt -r requirements_test.txt
COPY requirements.txt ./
COPY homeassistant/package_constraints.txt homeassistant/package_constraints.txt
RUN uv pip install -r requirements.txt
COPY requirements_test.txt requirements_test_pre_commit.txt ./
RUN uv pip install -r requirements_test.txt
WORKDIR /workspaces

22
build.yaml Normal file
View File

@@ -0,0 +1,22 @@
image: ghcr.io/home-assistant/{arch}-homeassistant
build_from:
aarch64: ghcr.io/home-assistant/aarch64-homeassistant-base:2025.05.0
armhf: ghcr.io/home-assistant/armhf-homeassistant-base:2025.05.0
armv7: ghcr.io/home-assistant/armv7-homeassistant-base:2025.05.0
amd64: ghcr.io/home-assistant/amd64-homeassistant-base:2025.05.0
i386: ghcr.io/home-assistant/i386-homeassistant-base:2025.05.0
codenotary:
signer: notary@home-assistant.io
base_image: notary@home-assistant.io
cosign:
base_identity: https://github.com/home-assistant/docker/.*
identity: https://github.com/home-assistant/core/.*
labels:
io.hass.type: core
org.opencontainers.image.title: Home Assistant
org.opencontainers.image.description: Open-source home automation platform running on Python 3
org.opencontainers.image.source: https://github.com/home-assistant/core
org.opencontainers.image.authors: The Home Assistant Authors
org.opencontainers.image.url: https://www.home-assistant.io/
org.opencontainers.image.documentation: https://www.home-assistant.io/docs/
org.opencontainers.image.licenses: Apache-2.0

View File

@@ -187,42 +187,36 @@ def main() -> int:
from . import config, runner # noqa: PLC0415
# Ensure only one instance runs per config directory
with runner.ensure_single_execution(config_dir) as single_execution_lock:
# Check if another instance is already running
if single_execution_lock.exit_code is not None:
return single_execution_lock.exit_code
safe_mode = config.safe_mode_enabled(config_dir)
safe_mode = config.safe_mode_enabled(config_dir)
runtime_conf = runner.RuntimeConfig(
config_dir=config_dir,
verbose=args.verbose,
log_rotate_days=args.log_rotate_days,
log_file=args.log_file,
log_no_color=args.log_no_color,
skip_pip=args.skip_pip,
skip_pip_packages=args.skip_pip_packages,
recovery_mode=args.recovery_mode,
debug=args.debug,
open_ui=args.open_ui,
safe_mode=safe_mode,
)
runtime_conf = runner.RuntimeConfig(
config_dir=config_dir,
verbose=args.verbose,
log_rotate_days=args.log_rotate_days,
log_file=args.log_file,
log_no_color=args.log_no_color,
skip_pip=args.skip_pip,
skip_pip_packages=args.skip_pip_packages,
recovery_mode=args.recovery_mode,
debug=args.debug,
open_ui=args.open_ui,
safe_mode=safe_mode,
)
fault_file_name = os.path.join(config_dir, FAULT_LOG_FILENAME)
with open(fault_file_name, mode="a", encoding="utf8") as fault_file:
faulthandler.enable(fault_file)
exit_code = runner.run(runtime_conf)
faulthandler.disable()
fault_file_name = os.path.join(config_dir, FAULT_LOG_FILENAME)
with open(fault_file_name, mode="a", encoding="utf8") as fault_file:
faulthandler.enable(fault_file)
exit_code = runner.run(runtime_conf)
faulthandler.disable()
# It's possible for the fault file to disappear, so suppress obvious errors
with suppress(FileNotFoundError):
if os.path.getsize(fault_file_name) == 0:
os.remove(fault_file_name)
# It's possible for the fault file to disappear, so suppress obvious errors
with suppress(FileNotFoundError):
if os.path.getsize(fault_file_name) == 0:
os.remove(fault_file_name)
check_threads()
check_threads()
return exit_code
return exit_code
if __name__ == "__main__":

View File

@@ -402,8 +402,6 @@ class AuthManager:
if user.is_owner:
raise ValueError("Unable to deactivate the owner")
await self._store.async_deactivate_user(user)
for refresh_token in list(user.refresh_tokens.values()):
self.async_remove_refresh_token(refresh_token)
async def async_remove_credentials(self, credentials: models.Credentials) -> None:
"""Remove credentials."""

View File

@@ -6,6 +6,7 @@ Sending HOTP through notify service
from __future__ import annotations
import asyncio
from collections import OrderedDict
import logging
from typing import Any, cast
@@ -26,7 +27,7 @@ from . import (
SetupFlow,
)
REQUIREMENTS = ["pyotp==2.9.0"]
REQUIREMENTS = ["pyotp==2.8.0"]
CONF_MESSAGE = "message"
@@ -303,14 +304,13 @@ class NotifySetupFlow(SetupFlow[NotifyAuthModule]):
if not self._available_notify_services:
return self.async_abort(reason="no_available_service")
schema = vol.Schema(
{
vol.Required("notify_service"): vol.In(self._available_notify_services),
vol.Optional("target"): str,
}
)
schema: dict[str, Any] = OrderedDict()
schema["notify_service"] = vol.In(self._available_notify_services)
schema["target"] = vol.Optional(str)
return self.async_show_form(step_id="init", data_schema=schema, errors=errors)
return self.async_show_form(
step_id="init", data_schema=vol.Schema(schema), errors=errors
)
async def async_step_setup(
self, user_input: dict[str, str] | None = None

View File

@@ -20,7 +20,7 @@ from . import (
SetupFlow,
)
REQUIREMENTS = ["pyotp==2.9.0", "PyQRCode==1.2.1"]
REQUIREMENTS = ["pyotp==2.8.0", "PyQRCode==1.2.1"]
CONFIG_SCHEMA = MULTI_FACTOR_AUTH_MODULE_SCHEMA.extend({}, extra=vol.PREVENT_EXTRA)
@@ -34,9 +34,6 @@ INPUT_FIELD_CODE = "code"
DUMMY_SECRET = "FPPTH34D4E3MI2HG"
GOOGLE_AUTHENTICATOR_URL = "https://support.google.com/accounts/answer/1066447"
AUTHY_URL = "https://authy.com/"
def _generate_qr_code(data: str) -> str:
"""Generate a base64 PNG string represent QR Code image of data."""
@@ -232,8 +229,6 @@ class TotpSetupFlow(SetupFlow[TotpAuthModule]):
"code": self._ota_secret,
"url": self._url,
"qr_code": self._image,
"google_authenticator_url": GOOGLE_AUTHENTICATOR_URL,
"authy_url": AUTHY_URL,
},
errors=errors,
)

View File

@@ -7,7 +7,6 @@ from typing import Any, Final
from homeassistant.const import (
EVENT_COMPONENT_LOADED,
EVENT_CORE_CONFIG_UPDATE,
EVENT_LABS_UPDATED,
EVENT_LOVELACE_UPDATED,
EVENT_PANELS_UPDATED,
EVENT_RECORDER_5MIN_STATISTICS_GENERATED,
@@ -46,7 +45,6 @@ SUBSCRIBE_ALLOWLIST: Final[set[EventType[Any] | str]] = {
EVENT_STATE_CHANGED,
EVENT_THEMES_UPDATED,
EVENT_LABEL_REGISTRY_UPDATED,
EVENT_LABS_UPDATED,
EVENT_CATEGORY_REGISTRY_UPDATED,
EVENT_FLOOR_REGISTRY_UPDATED,
}

View File

@@ -179,18 +179,12 @@ class Data:
user_hash = base64.b64decode(found["password"])
# bcrypt.checkpw is timing-safe
# With bcrypt 5.0 passing a password longer than 72 bytes raises a ValueError.
# Previously the password was silently truncated.
# https://github.com/pyca/bcrypt/pull/1000
if not bcrypt.checkpw(password.encode()[:72], user_hash):
if not bcrypt.checkpw(password.encode(), user_hash):
raise InvalidAuth
def hash_password(self, password: str, for_storage: bool = False) -> bytes:
"""Encode a password."""
# With bcrypt 5.0 passing a password longer than 72 bytes raises a ValueError.
# Previously the password was silently truncated.
# https://github.com/pyca/bcrypt/pull/1000
hashed: bytes = bcrypt.hashpw(password.encode()[:72], bcrypt.gensalt(rounds=12))
hashed: bytes = bcrypt.hashpw(password.encode(), bcrypt.gensalt(rounds=12))
if for_storage:
hashed = base64.b64encode(hashed)

View File

@@ -176,8 +176,6 @@ FRONTEND_INTEGRATIONS = {
STAGE_0_INTEGRATIONS = (
# Load logging and http deps as soon as possible
("logging, http deps", LOGGING_AND_HTTP_DEPS_INTEGRATIONS, None),
# Setup labs for preview features
("labs", {"labs"}, STAGE_0_SUBSTAGE_TIMEOUT),
# Setup frontend
("frontend", FRONTEND_INTEGRATIONS, None),
# Setup recorder
@@ -214,7 +212,6 @@ DEFAULT_INTEGRATIONS = {
"backup",
"frontend",
"hardware",
"labs",
"logger",
"network",
"system_health",
@@ -619,37 +616,34 @@ async def async_enable_logging(
),
)
logger = logging.getLogger()
logger.setLevel(logging.INFO if verbose else logging.WARNING)
# Log errors to a file if we have write access to file or config dir
if log_file is None:
default_log_path = hass.config.path(ERROR_LOG_FILENAME)
if "SUPERVISOR" in os.environ and "HA_DUPLICATE_LOG_FILE" not in os.environ:
# Rename the default log file if it exists, since previous versions created
# it even on Supervisor
def rename_old_file() -> None:
"""Rename old log file in executor."""
if os.path.isfile(default_log_path):
with contextlib.suppress(OSError):
os.rename(default_log_path, f"{default_log_path}.old")
await hass.async_add_executor_job(rename_old_file)
err_log_path = None
else:
err_log_path = default_log_path
err_log_path = hass.config.path(ERROR_LOG_FILENAME)
else:
err_log_path = os.path.abspath(log_file)
if err_log_path:
err_path_exists = os.path.isfile(err_log_path)
err_dir = os.path.dirname(err_log_path)
# Check if we can write to the error log if it exists or that
# we can create files in the containing directory if not.
if (err_path_exists and os.access(err_log_path, os.W_OK)) or (
not err_path_exists and os.access(err_dir, os.W_OK)
):
err_handler = await hass.async_add_executor_job(
_create_log_file, err_log_path, log_rotate_days
)
err_handler.setFormatter(logging.Formatter(fmt, datefmt=FORMAT_DATETIME))
logger = logging.getLogger()
logger.addHandler(err_handler)
logger.setLevel(logging.INFO if verbose else logging.WARNING)
# Save the log file location for access by other components.
hass.data[DATA_LOGGING] = err_log_path
else:
_LOGGER.error("Unable to set up error log %s (access denied)", err_log_path)
async_activate_log_queue_handler(hass)
@@ -1003,7 +997,7 @@ class _WatchPendingSetups:
# We log every LOG_SLOW_STARTUP_INTERVAL until all integrations are done
# once we take over LOG_SLOW_STARTUP_INTERVAL (60s) to start up
_LOGGER.warning(
"Waiting for integrations to complete setup: %s",
"Waiting on integrations to complete setup: %s",
self._setup_started,
)

View File

@@ -1,5 +0,0 @@
{
"domain": "eltako",
"name": "Eltako",
"iot_standards": ["matter"]
}

View File

@@ -1,5 +1,5 @@
{
"domain": "fritzbox",
"name": "FRITZ!",
"name": "FRITZ!Box",
"integrations": ["fritz", "fritzbox", "fritzbox_callmonitor"]
}

View File

@@ -2,11 +2,11 @@
"domain": "google",
"name": "Google",
"integrations": [
"google_air_quality",
"google_assistant",
"google_assistant_sdk",
"google_cloud",
"google_drive",
"google_gemini",
"google_generative_ai_conversation",
"google_mail",
"google_maps",
@@ -16,7 +16,6 @@
"google_tasks",
"google_translate",
"google_travel_time",
"google_weather",
"google_wifi",
"google",
"nest",

View File

@@ -0,0 +1,5 @@
{
"domain": "ibm",
"name": "IBM",
"integrations": ["watson_iot", "watson_tts"]
}

View File

@@ -1,5 +0,0 @@
{
"domain": "konnected",
"name": "Konnected",
"integrations": ["konnected", "konnected_esphome"]
}

View File

@@ -1,5 +0,0 @@
{
"domain": "level",
"name": "Level",
"iot_standards": ["matter"]
}

View File

@@ -1,5 +1,5 @@
{
"domain": "philips",
"name": "Philips",
"integrations": ["dynalite", "hue", "hue_ble", "philips_js"]
"integrations": ["dynalite", "hue", "philips_js"]
}

View File

@@ -1,5 +1,5 @@
{
"domain": "raspberry_pi",
"name": "Raspberry Pi",
"integrations": ["raspberry_pi", "rpi_power", "remote_rpi_gpio"]
"integrations": ["raspberry_pi", "rpi_camera", "rpi_power", "remote_rpi_gpio"]
}

View File

@@ -1,5 +0,0 @@
{
"domain": "victron",
"name": "Victron",
"integrations": ["victron_ble", "victron_remote_monitoring"]
}

View File

@@ -1,5 +1,11 @@
{
"domain": "yale",
"name": "Yale (non-US/Canada)",
"integrations": ["yale", "yalexs_ble", "yale_smart_alarm"]
"name": "Yale",
"integrations": [
"august",
"yale_smart_alarm",
"yalexs_ble",
"yale_home",
"yale"
]
}

View File

@@ -1,5 +0,0 @@
{
"domain": "yale_august",
"name": "Yale August (US/Canada)",
"integrations": ["august", "august_ble"]
}

View File

@@ -1,70 +1,70 @@
{
"config": {
"abort": {
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]"
},
"error": {
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
"invalid_mfa_code": "Invalid MFA code"
},
"step": {
"user": {
"title": "Fill in your Abode login information",
"data": {
"username": "[%key:common::config_flow::data::email%]",
"password": "[%key:common::config_flow::data::password%]"
}
},
"mfa": {
"title": "Enter your MFA code for Abode",
"data": {
"mfa_code": "MFA code (6-digits)"
},
"title": "Enter your MFA code for Abode"
}
},
"reauth_confirm": {
"title": "[%key:component::abode::config::step::user::title%]",
"data": {
"password": "[%key:common::config_flow::data::password%]",
"username": "[%key:common::config_flow::data::email%]"
},
"title": "[%key:component::abode::config::step::user::title%]"
},
"user": {
"data": {
"password": "[%key:common::config_flow::data::password%]",
"username": "[%key:common::config_flow::data::email%]"
},
"title": "Fill in your Abode login information"
"username": "[%key:common::config_flow::data::email%]",
"password": "[%key:common::config_flow::data::password%]"
}
}
},
"error": {
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
"invalid_mfa_code": "Invalid MFA code"
},
"abort": {
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]"
}
},
"services": {
"capture_image": {
"name": "Capture image",
"description": "Requests a new image capture from a camera device.",
"fields": {
"entity_id": {
"description": "Entity ID of the camera to request an image from.",
"name": "Entity"
"name": "Entity",
"description": "Entity ID of the camera to request an image from."
}
},
"name": "Capture image"
}
},
"change_setting": {
"name": "Change setting",
"description": "Changes an Abode system setting.",
"fields": {
"setting": {
"description": "Setting to change.",
"name": "Setting"
"name": "Setting",
"description": "Setting to change."
},
"value": {
"description": "Value of the setting.",
"name": "Value"
"name": "Value",
"description": "Value of the setting."
}
},
"name": "Change setting"
}
},
"trigger_automation": {
"name": "Trigger automation",
"description": "Triggers an Abode automation.",
"fields": {
"entity_id": {
"description": "Entity ID of the automation to trigger.",
"name": "Entity"
"name": "Entity",
"description": "Entity ID of the automation to trigger."
}
},
"name": "Trigger automation"
}
}
}
}

View File

@@ -8,17 +8,14 @@ import logging
from aioacaia.acaiascale import AcaiaScale
from aioacaia.exceptions import AcaiaDeviceNotFound, AcaiaError
from homeassistant.components.bluetooth import async_get_scanner
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_ADDRESS
from homeassistant.core import HomeAssistant
from homeassistant.helpers.debounce import Debouncer
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from .const import CONF_IS_NEW_STYLE_SCALE
SCAN_INTERVAL = timedelta(seconds=15)
UPDATE_DEBOUNCE_TIME = 0.2
_LOGGER = logging.getLogger(__name__)
@@ -40,20 +37,11 @@ class AcaiaCoordinator(DataUpdateCoordinator[None]):
config_entry=entry,
)
debouncer = Debouncer(
hass=hass,
logger=_LOGGER,
cooldown=UPDATE_DEBOUNCE_TIME,
immediate=True,
function=self.async_update_listeners,
)
self._scale = AcaiaScale(
address_or_ble_device=entry.data[CONF_ADDRESS],
name=entry.title,
is_new_style_scale=entry.data[CONF_IS_NEW_STYLE_SCALE],
notify_callback=debouncer.async_schedule_call,
scanner=async_get_scanner(hass),
notify_callback=self.async_update_listeners,
)
@property

View File

@@ -4,20 +4,20 @@
"timer_running": {
"default": "mdi:timer",
"state": {
"off": "mdi:timer-off",
"on": "mdi:timer-play"
"on": "mdi:timer-play",
"off": "mdi:timer-off"
}
}
},
"button": {
"tare": {
"default": "mdi:scale-balance"
},
"reset_timer": {
"default": "mdi:timer-refresh"
},
"start_stop": {
"default": "mdi:timer-play"
},
"tare": {
"default": "mdi:scale-balance"
}
}
}

View File

@@ -26,5 +26,5 @@
"iot_class": "local_push",
"loggers": ["aioacaia"],
"quality_scale": "platinum",
"requirements": ["aioacaia==0.1.17"]
"requirements": ["aioacaia==0.1.14"]
}

View File

@@ -1,5 +1,6 @@
{
"config": {
"flow_title": "{name}",
"abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
"no_devices_found": "[%key:common::config_flow::abort::no_devices_found%]",
@@ -9,19 +10,18 @@
"device_not_found": "Device could not be found.",
"unknown": "[%key:common::config_flow::error::unknown%]"
},
"flow_title": "{name}",
"step": {
"bluetooth_confirm": {
"description": "[%key:component::bluetooth::config::step::bluetooth_confirm::description%]"
},
"user": {
"description": "[%key:component::bluetooth::config::step::user::description%]",
"data": {
"address": "[%key:common::config_flow::data::device%]"
},
"data_description": {
"address": "Select Acaia scale you want to set up"
},
"description": "[%key:component::bluetooth::config::step::user::description%]"
}
}
}
},
@@ -32,14 +32,14 @@
}
},
"button": {
"tare": {
"name": "Tare"
},
"reset_timer": {
"name": "Reset timer"
},
"start_stop": {
"name": "Start/stop timer"
},
"tare": {
"name": "Tare"
}
}
}

View File

@@ -2,23 +2,21 @@
from __future__ import annotations
import asyncio
import logging
from accuweather import AccuWeather
from homeassistant.components.sensor import DOMAIN as SENSOR_PLATFORM
from homeassistant.const import CONF_API_KEY, Platform
from homeassistant.const import CONF_API_KEY, CONF_NAME, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN
from .const import DOMAIN, UPDATE_INTERVAL_DAILY_FORECAST, UPDATE_INTERVAL_OBSERVATION
from .coordinator import (
AccuWeatherConfigEntry,
AccuWeatherDailyForecastDataUpdateCoordinator,
AccuWeatherData,
AccuWeatherHourlyForecastDataUpdateCoordinator,
AccuWeatherObservationDataUpdateCoordinator,
)
@@ -30,6 +28,7 @@ PLATFORMS = [Platform.SENSOR, Platform.WEATHER]
async def async_setup_entry(hass: HomeAssistant, entry: AccuWeatherConfigEntry) -> bool:
"""Set up AccuWeather as config entry."""
api_key: str = entry.data[CONF_API_KEY]
name: str = entry.data[CONF_NAME]
location_key = entry.unique_id
@@ -42,28 +41,26 @@ async def async_setup_entry(hass: HomeAssistant, entry: AccuWeatherConfigEntry)
hass,
entry,
accuweather,
name,
"observation",
UPDATE_INTERVAL_OBSERVATION,
)
coordinator_daily_forecast = AccuWeatherDailyForecastDataUpdateCoordinator(
hass,
entry,
accuweather,
)
coordinator_hourly_forecast = AccuWeatherHourlyForecastDataUpdateCoordinator(
hass,
entry,
accuweather,
name,
"daily forecast",
UPDATE_INTERVAL_DAILY_FORECAST,
)
await asyncio.gather(
coordinator_observation.async_config_entry_first_refresh(),
coordinator_daily_forecast.async_config_entry_first_refresh(),
coordinator_hourly_forecast.async_config_entry_first_refresh(),
)
await coordinator_observation.async_config_entry_first_refresh()
await coordinator_daily_forecast.async_config_entry_first_refresh()
entry.runtime_data = AccuWeatherData(
coordinator_observation=coordinator_observation,
coordinator_daily_forecast=coordinator_daily_forecast,
coordinator_hourly_forecast=coordinator_hourly_forecast,
)
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

View File

@@ -3,7 +3,6 @@
from __future__ import annotations
from asyncio import timeout
from collections.abc import Mapping
from typing import Any
from accuweather import AccuWeather, ApiError, InvalidApiKeyError, RequestsExceededError
@@ -23,8 +22,6 @@ class AccuWeatherFlowHandler(ConfigFlow, domain=DOMAIN):
"""Config flow for AccuWeather."""
VERSION = 1
_latitude: float | None = None
_longitude: float | None = None
async def async_step_user(
self, user_input: dict[str, Any] | None = None
@@ -53,7 +50,6 @@ class AccuWeatherFlowHandler(ConfigFlow, domain=DOMAIN):
await self.async_set_unique_id(
accuweather.location_key, raise_on_progress=False
)
self._abort_if_unique_id_configured()
return self.async_create_entry(
title=user_input[CONF_NAME], data=user_input
@@ -77,46 +73,3 @@ class AccuWeatherFlowHandler(ConfigFlow, domain=DOMAIN):
),
errors=errors,
)
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle configuration by re-auth."""
self._latitude = entry_data[CONF_LATITUDE]
self._longitude = entry_data[CONF_LONGITUDE]
return await self.async_step_reauth_confirm()
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Dialog that informs the user that reauth is required."""
errors: dict[str, str] = {}
if user_input is not None:
websession = async_get_clientsession(self.hass)
try:
async with timeout(10):
accuweather = AccuWeather(
user_input[CONF_API_KEY],
websession,
latitude=self._latitude,
longitude=self._longitude,
)
await accuweather.async_get_location()
except (ApiError, ClientConnectorError, TimeoutError, ClientError):
errors["base"] = "cannot_connect"
except InvalidApiKeyError:
errors["base"] = "invalid_api_key"
except RequestsExceededError:
errors["base"] = "requests_exceeded"
else:
return self.async_update_reload_and_abort(
self._get_reauth_entry(), data_updates=user_input
)
return self.async_show_form(
step_id="reauth_confirm",
data_schema=vol.Schema({vol.Required(CONF_API_KEY): str}),
errors=errors,
)

View File

@@ -69,6 +69,5 @@ POLLEN_CATEGORY_MAP = {
4: "very_high",
5: "extreme",
}
UPDATE_INTERVAL_OBSERVATION = timedelta(minutes=10)
UPDATE_INTERVAL_OBSERVATION = timedelta(minutes=40)
UPDATE_INTERVAL_DAILY_FORECAST = timedelta(hours=6)
UPDATE_INTERVAL_HOURLY_FORECAST = timedelta(minutes=30)

View File

@@ -3,7 +3,6 @@
from __future__ import annotations
from asyncio import timeout
from collections.abc import Awaitable, Callable
from dataclasses import dataclass
from datetime import timedelta
import logging
@@ -13,9 +12,7 @@ from accuweather import AccuWeather, ApiError, InvalidApiKeyError, RequestsExcee
from aiohttp.client_exceptions import ClientConnectorError
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_NAME
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
from homeassistant.helpers.update_coordinator import (
DataUpdateCoordinator,
@@ -23,15 +20,9 @@ from homeassistant.helpers.update_coordinator import (
UpdateFailed,
)
from .const import (
DOMAIN,
MANUFACTURER,
UPDATE_INTERVAL_DAILY_FORECAST,
UPDATE_INTERVAL_HOURLY_FORECAST,
UPDATE_INTERVAL_OBSERVATION,
)
from .const import DOMAIN, MANUFACTURER
EXCEPTIONS = (ApiError, ClientConnectorError, RequestsExceededError)
EXCEPTIONS = (ApiError, ClientConnectorError, InvalidApiKeyError, RequestsExceededError)
_LOGGER = logging.getLogger(__name__)
@@ -42,7 +33,6 @@ class AccuWeatherData:
coordinator_observation: AccuWeatherObservationDataUpdateCoordinator
coordinator_daily_forecast: AccuWeatherDailyForecastDataUpdateCoordinator
coordinator_hourly_forecast: AccuWeatherHourlyForecastDataUpdateCoordinator
type AccuWeatherConfigEntry = ConfigEntry[AccuWeatherData]
@@ -53,18 +43,18 @@ class AccuWeatherObservationDataUpdateCoordinator(
):
"""Class to manage fetching AccuWeather data API."""
config_entry: AccuWeatherConfigEntry
def __init__(
self,
hass: HomeAssistant,
config_entry: AccuWeatherConfigEntry,
accuweather: AccuWeather,
name: str,
coordinator_type: str,
update_interval: timedelta,
) -> None:
"""Initialize."""
self.accuweather = accuweather
self.location_key = accuweather.location_key
name = config_entry.data[CONF_NAME]
if TYPE_CHECKING:
assert self.location_key is not None
@@ -75,8 +65,8 @@ class AccuWeatherObservationDataUpdateCoordinator(
hass,
_LOGGER,
config_entry=config_entry,
name=f"{name} (observation)",
update_interval=UPDATE_INTERVAL_OBSERVATION,
name=f"{name} ({coordinator_type})",
update_interval=update_interval,
)
async def _async_update_data(self) -> dict[str, Any]:
@@ -90,39 +80,29 @@ class AccuWeatherObservationDataUpdateCoordinator(
translation_key="current_conditions_update_error",
translation_placeholders={"error": repr(error)},
) from error
except InvalidApiKeyError as err:
raise ConfigEntryAuthFailed(
translation_domain=DOMAIN,
translation_key="auth_error",
translation_placeholders={"entry": self.config_entry.title},
) from err
_LOGGER.debug("Requests remaining: %d", self.accuweather.requests_remaining)
return result
class AccuWeatherForecastDataUpdateCoordinator(
class AccuWeatherDailyForecastDataUpdateCoordinator(
TimestampDataUpdateCoordinator[list[dict[str, Any]]]
):
"""Base class for AccuWeather forecast."""
config_entry: AccuWeatherConfigEntry
"""Class to manage fetching AccuWeather data API."""
def __init__(
self,
hass: HomeAssistant,
config_entry: AccuWeatherConfigEntry,
accuweather: AccuWeather,
name: str,
coordinator_type: str,
update_interval: timedelta,
fetch_method: Callable[..., Awaitable[list[dict[str, Any]]]],
) -> None:
"""Initialize."""
self.accuweather = accuweather
self.location_key = accuweather.location_key
self._fetch_method = fetch_method
name = config_entry.data[CONF_NAME]
if TYPE_CHECKING:
assert self.location_key is not None
@@ -138,71 +118,24 @@ class AccuWeatherForecastDataUpdateCoordinator(
)
async def _async_update_data(self) -> list[dict[str, Any]]:
"""Update forecast data via library."""
"""Update data via library."""
try:
async with timeout(10):
result = await self._fetch_method(language=self.hass.config.language)
result = await self.accuweather.async_get_daily_forecast(
language=self.hass.config.language
)
except EXCEPTIONS as error:
raise UpdateFailed(
translation_domain=DOMAIN,
translation_key="forecast_update_error",
translation_placeholders={"error": repr(error)},
) from error
except InvalidApiKeyError as err:
raise ConfigEntryAuthFailed(
translation_domain=DOMAIN,
translation_key="auth_error",
translation_placeholders={"entry": self.config_entry.title},
) from err
_LOGGER.debug("Requests remaining: %d", self.accuweather.requests_remaining)
return result
class AccuWeatherDailyForecastDataUpdateCoordinator(
AccuWeatherForecastDataUpdateCoordinator
):
"""Coordinator for daily forecast."""
def __init__(
self,
hass: HomeAssistant,
config_entry: AccuWeatherConfigEntry,
accuweather: AccuWeather,
) -> None:
"""Initialize."""
super().__init__(
hass,
config_entry,
accuweather,
"daily forecast",
UPDATE_INTERVAL_DAILY_FORECAST,
fetch_method=accuweather.async_get_daily_forecast,
)
class AccuWeatherHourlyForecastDataUpdateCoordinator(
AccuWeatherForecastDataUpdateCoordinator
):
"""Coordinator for hourly forecast."""
def __init__(
self,
hass: HomeAssistant,
config_entry: AccuWeatherConfigEntry,
accuweather: AccuWeather,
) -> None:
"""Initialize."""
super().__init__(
hass,
config_entry,
accuweather,
"hourly forecast",
UPDATE_INTERVAL_HOURLY_FORECAST,
fetch_method=accuweather.async_get_hourly_forecast,
)
def _get_device_info(location_key: str, name: str) -> DeviceInfo:
"""Get device info."""
return DeviceInfo(

View File

@@ -1,9 +1,6 @@
{
"entity": {
"sensor": {
"air_quality": {
"default": "mdi:air-filter"
},
"cloud_ceiling": {
"default": "mdi:weather-fog"
},
@@ -37,6 +34,9 @@
"thunderstorm_probability_night": {
"default": "mdi:weather-lightning"
},
"translation_key": {
"default": "mdi:air-filter"
},
"tree_pollen": {
"default": "mdi:tree-outline"
},

View File

@@ -7,5 +7,6 @@
"integration_type": "service",
"iot_class": "cloud_polling",
"loggers": ["accuweather"],
"requirements": ["accuweather==5.0.0"]
"requirements": ["accuweather==4.2.0"],
"single_config_entry": true
}

View File

@@ -1,8 +1,14 @@
{
"config": {
"abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_location%]",
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]"
"step": {
"user": {
"data": {
"name": "[%key:common::config_flow::data::name%]",
"api_key": "[%key:common::config_flow::data::api_key%]",
"latitude": "[%key:common::config_flow::data::latitude%]",
"longitude": "[%key:common::config_flow::data::longitude%]"
}
}
},
"create_entry": {
"default": "Some sensors are not enabled by default. You can enable them in the entity registry after the integration configuration."
@@ -11,27 +17,6 @@
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
"invalid_api_key": "[%key:common::config_flow::error::invalid_api_key%]",
"requests_exceeded": "The allowed number of requests to the AccuWeather API has been exceeded. You have to wait or change the API key."
},
"step": {
"reauth_confirm": {
"data": {
"api_key": "[%key:common::config_flow::data::api_key%]"
},
"data_description": {
"api_key": "[%key:component::accuweather::config::step::user::data_description::api_key%]"
}
},
"user": {
"data": {
"api_key": "[%key:common::config_flow::data::api_key%]",
"latitude": "[%key:common::config_flow::data::latitude%]",
"longitude": "[%key:common::config_flow::data::longitude%]",
"name": "[%key:common::config_flow::data::name%]"
},
"data_description": {
"api_key": "API key generated in the AccuWeather APIs portal."
}
}
}
},
"entity": {
@@ -120,9 +105,9 @@
"pressure_tendency": {
"name": "Pressure tendency",
"state": {
"falling": "Falling",
"steady": "Steady",
"rising": "Rising",
"steady": "Steady"
"falling": "Falling"
},
"state_attributes": {
"options": {
@@ -227,6 +212,9 @@
"wet_bulb_temperature": {
"name": "Wet bulb temperature"
},
"wind_speed": {
"name": "[%key:component::weather::entity_component::_::state_attributes::wind_speed::name%]"
},
"wind_chill_temperature": {
"name": "Wind chill temperature"
},
@@ -239,9 +227,6 @@
"wind_gust_speed_night": {
"name": "Wind gust speed night {forecast_day}"
},
"wind_speed": {
"name": "[%key:component::weather::entity_component::_::state_attributes::wind_speed::name%]"
},
"wind_speed_day": {
"name": "Wind speed day {forecast_day}"
},
@@ -251,9 +236,6 @@
}
},
"exceptions": {
"auth_error": {
"message": "Authentication failed for {entry}, please update your API key"
},
"current_conditions_update_error": {
"message": "An error occurred while retrieving weather current conditions data from the AccuWeather API: {error}"
},

View File

@@ -45,7 +45,6 @@ from .coordinator import (
AccuWeatherConfigEntry,
AccuWeatherDailyForecastDataUpdateCoordinator,
AccuWeatherData,
AccuWeatherHourlyForecastDataUpdateCoordinator,
AccuWeatherObservationDataUpdateCoordinator,
)
@@ -65,7 +64,6 @@ class AccuWeatherEntity(
CoordinatorWeatherEntity[
AccuWeatherObservationDataUpdateCoordinator,
AccuWeatherDailyForecastDataUpdateCoordinator,
AccuWeatherHourlyForecastDataUpdateCoordinator,
]
):
"""Define an AccuWeather entity."""
@@ -78,7 +76,6 @@ class AccuWeatherEntity(
super().__init__(
observation_coordinator=accuweather_data.coordinator_observation,
daily_coordinator=accuweather_data.coordinator_daily_forecast,
hourly_coordinator=accuweather_data.coordinator_hourly_forecast,
)
self._attr_native_precipitation_unit = UnitOfPrecipitationDepth.MILLIMETERS
@@ -89,13 +86,10 @@ class AccuWeatherEntity(
self._attr_unique_id = accuweather_data.coordinator_observation.location_key
self._attr_attribution = ATTRIBUTION
self._attr_device_info = accuweather_data.coordinator_observation.device_info
self._attr_supported_features = (
WeatherEntityFeature.FORECAST_DAILY | WeatherEntityFeature.FORECAST_HOURLY
)
self._attr_supported_features = WeatherEntityFeature.FORECAST_DAILY
self.observation_coordinator = accuweather_data.coordinator_observation
self.daily_coordinator = accuweather_data.coordinator_daily_forecast
self.hourly_coordinator = accuweather_data.coordinator_hourly_forecast
@property
def condition(self) -> str | None:
@@ -213,32 +207,3 @@ class AccuWeatherEntity(
}
for item in self.daily_coordinator.data
]
@callback
def _async_forecast_hourly(self) -> list[Forecast] | None:
"""Return the hourly forecast in native units."""
return [
{
ATTR_FORECAST_TIME: utc_from_timestamp(
item["EpochDateTime"]
).isoformat(),
ATTR_FORECAST_CLOUD_COVERAGE: item["CloudCover"],
ATTR_FORECAST_HUMIDITY: item["RelativeHumidity"],
ATTR_FORECAST_NATIVE_TEMP: item["Temperature"][ATTR_VALUE],
ATTR_FORECAST_NATIVE_APPARENT_TEMP: item["RealFeelTemperature"][
ATTR_VALUE
],
ATTR_FORECAST_NATIVE_PRECIPITATION: item["TotalLiquid"][ATTR_VALUE],
ATTR_FORECAST_PRECIPITATION_PROBABILITY: item[
"PrecipitationProbability"
],
ATTR_FORECAST_NATIVE_WIND_SPEED: item["Wind"][ATTR_SPEED][ATTR_VALUE],
ATTR_FORECAST_NATIVE_WIND_GUST_SPEED: item["WindGust"][ATTR_SPEED][
ATTR_VALUE
],
ATTR_FORECAST_UV_INDEX: item["UVIndex"],
ATTR_FORECAST_WIND_BEARING: item["Wind"][ATTR_DIRECTION]["Degrees"],
ATTR_FORECAST_CONDITION: CONDITION_MAP.get(item["WeatherIcon"]),
}
for item in self.hourly_coordinator.data
]

View File

@@ -1,15 +1,15 @@
{
"config": {
"abort": {
"no_devices_found": "[%key:common::config_flow::abort::no_devices_found%]"
},
"step": {
"user": {
"title": "Pick a hub to add",
"data": {
"id": "Host ID"
},
"title": "Pick a hub to add"
}
}
},
"abort": {
"no_devices_found": "[%key:common::config_flow::abort::no_devices_found%]"
}
}
}

View File

@@ -1,59 +0,0 @@
"""The Actron Air integration."""
from actron_neo_api import (
ActronAirACSystem,
ActronAirAPI,
ActronAirAPIError,
ActronAirAuthError,
)
from homeassistant.const import CONF_API_TOKEN, Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
from .const import _LOGGER, DOMAIN
from .coordinator import (
ActronAirConfigEntry,
ActronAirRuntimeData,
ActronAirSystemCoordinator,
)
PLATFORMS = [Platform.CLIMATE, Platform.SWITCH]
async def async_setup_entry(hass: HomeAssistant, entry: ActronAirConfigEntry) -> bool:
"""Set up Actron Air integration from a config entry."""
api = ActronAirAPI(refresh_token=entry.data[CONF_API_TOKEN])
systems: list[ActronAirACSystem] = []
try:
systems = await api.get_ac_systems()
await api.update_status()
except ActronAirAuthError as err:
raise ConfigEntryAuthFailed(
translation_domain=DOMAIN,
translation_key="auth_error",
) from err
except ActronAirAPIError as err:
raise ConfigEntryNotReady from err
system_coordinators: dict[str, ActronAirSystemCoordinator] = {}
for system in systems:
coordinator = ActronAirSystemCoordinator(hass, entry, api, system)
_LOGGER.debug("Setting up coordinator for system: %s", system["serial"])
await coordinator.async_config_entry_first_refresh()
system_coordinators[system["serial"]] = coordinator
entry.runtime_data = ActronAirRuntimeData(
api=api,
system_coordinators=system_coordinators,
)
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
return True
async def async_unload_entry(hass: HomeAssistant, entry: ActronAirConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)

View File

@@ -1,219 +0,0 @@
"""Climate platform for Actron Air integration."""
from typing import Any
from actron_neo_api import ActronAirStatus, ActronAirZone
from homeassistant.components.climate import (
FAN_AUTO,
FAN_HIGH,
FAN_LOW,
FAN_MEDIUM,
ClimateEntity,
ClimateEntityFeature,
HVACMode,
)
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from .coordinator import ActronAirConfigEntry, ActronAirSystemCoordinator
from .entity import ActronAirAcEntity, ActronAirZoneEntity
PARALLEL_UPDATES = 0
FAN_MODE_MAPPING_ACTRONAIR_TO_HA = {
"AUTO": FAN_AUTO,
"LOW": FAN_LOW,
"MED": FAN_MEDIUM,
"HIGH": FAN_HIGH,
}
FAN_MODE_MAPPING_HA_TO_ACTRONAIR = {
v: k for k, v in FAN_MODE_MAPPING_ACTRONAIR_TO_HA.items()
}
HVAC_MODE_MAPPING_ACTRONAIR_TO_HA = {
"COOL": HVACMode.COOL,
"HEAT": HVACMode.HEAT,
"FAN": HVACMode.FAN_ONLY,
"AUTO": HVACMode.AUTO,
"OFF": HVACMode.OFF,
}
HVAC_MODE_MAPPING_HA_TO_ACTRONAIR = {
v: k for k, v in HVAC_MODE_MAPPING_ACTRONAIR_TO_HA.items()
}
async def async_setup_entry(
hass: HomeAssistant,
entry: ActronAirConfigEntry,
async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
"""Set up Actron Air climate entities."""
system_coordinators = entry.runtime_data.system_coordinators
entities: list[ClimateEntity] = []
for coordinator in system_coordinators.values():
status = coordinator.data
entities.append(ActronSystemClimate(coordinator))
entities.extend(
ActronZoneClimate(coordinator, zone)
for zone in status.remote_zone_info
if zone.exists
)
async_add_entities(entities)
class ActronAirClimateEntity(ClimateEntity):
"""Base class for Actron Air climate entities."""
_attr_temperature_unit = UnitOfTemperature.CELSIUS
_attr_supported_features = (
ClimateEntityFeature.TARGET_TEMPERATURE
| ClimateEntityFeature.FAN_MODE
| ClimateEntityFeature.TURN_ON
| ClimateEntityFeature.TURN_OFF
)
_attr_name = None
_attr_fan_modes = list(FAN_MODE_MAPPING_ACTRONAIR_TO_HA.values())
_attr_hvac_modes = list(HVAC_MODE_MAPPING_ACTRONAIR_TO_HA.values())
class ActronSystemClimate(ActronAirAcEntity, ActronAirClimateEntity):
"""Representation of the Actron Air system."""
def __init__(
self,
coordinator: ActronAirSystemCoordinator,
) -> None:
"""Initialize an Actron Air unit."""
super().__init__(coordinator)
self._attr_unique_id = self._serial_number
@property
def min_temp(self) -> float:
"""Return the minimum temperature that can be set."""
return self._status.min_temp
@property
def max_temp(self) -> float:
"""Return the maximum temperature that can be set."""
return self._status.max_temp
@property
def _status(self) -> ActronAirStatus:
"""Get the current status from the coordinator."""
return self.coordinator.data
@property
def hvac_mode(self) -> HVACMode | None:
"""Return the current HVAC mode."""
if not self._status.user_aircon_settings.is_on:
return HVACMode.OFF
mode = self._status.user_aircon_settings.mode
return HVAC_MODE_MAPPING_ACTRONAIR_TO_HA.get(mode)
@property
def fan_mode(self) -> str | None:
"""Return the current fan mode."""
fan_mode = self._status.user_aircon_settings.base_fan_mode
return FAN_MODE_MAPPING_ACTRONAIR_TO_HA.get(fan_mode)
@property
def current_humidity(self) -> float:
"""Return the current humidity."""
return self._status.master_info.live_humidity_pc
@property
def current_temperature(self) -> float:
"""Return the current temperature."""
return self._status.master_info.live_temp_c
@property
def target_temperature(self) -> float:
"""Return the target temperature."""
return self._status.user_aircon_settings.temperature_setpoint_cool_c
async def async_set_fan_mode(self, fan_mode: str) -> None:
"""Set a new fan mode."""
api_fan_mode = FAN_MODE_MAPPING_HA_TO_ACTRONAIR.get(fan_mode)
await self._status.user_aircon_settings.set_fan_mode(api_fan_mode)
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
"""Set the HVAC mode."""
ac_mode = HVAC_MODE_MAPPING_HA_TO_ACTRONAIR.get(hvac_mode)
await self._status.ac_system.set_system_mode(ac_mode)
async def async_set_temperature(self, **kwargs: Any) -> None:
"""Set the temperature."""
temp = kwargs.get(ATTR_TEMPERATURE)
await self._status.user_aircon_settings.set_temperature(temperature=temp)
class ActronZoneClimate(ActronAirZoneEntity, ActronAirClimateEntity):
"""Representation of a zone within the Actron Air system."""
_attr_supported_features = (
ClimateEntityFeature.TARGET_TEMPERATURE
| ClimateEntityFeature.TURN_ON
| ClimateEntityFeature.TURN_OFF
)
def __init__(
self,
coordinator: ActronAirSystemCoordinator,
zone: ActronAirZone,
) -> None:
"""Initialize an Actron Air unit."""
super().__init__(coordinator, zone)
self._attr_unique_id: str = self._zone_identifier
@property
def min_temp(self) -> float:
"""Return the minimum temperature that can be set."""
return self._zone.min_temp
@property
def max_temp(self) -> float:
"""Return the maximum temperature that can be set."""
return self._zone.max_temp
@property
def _zone(self) -> ActronAirZone:
"""Get the current zone data from the coordinator."""
status = self.coordinator.data
return status.zones[self._zone_id]
@property
def hvac_mode(self) -> HVACMode | None:
"""Return the current HVAC mode."""
if self._zone.is_active:
mode = self._zone.hvac_mode
return HVAC_MODE_MAPPING_ACTRONAIR_TO_HA.get(mode)
return HVACMode.OFF
@property
def current_humidity(self) -> float | None:
"""Return the current humidity."""
return self._zone.humidity
@property
def current_temperature(self) -> float | None:
"""Return the current temperature."""
return self._zone.live_temp_c
@property
def target_temperature(self) -> float | None:
"""Return the target temperature."""
return self._zone.temperature_setpoint_cool_c
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
"""Set the HVAC mode."""
is_enabled = hvac_mode != HVACMode.OFF
await self._zone.enable(is_enabled)
async def async_set_temperature(self, **kwargs: Any) -> None:
"""Set the temperature."""
await self._zone.set_temperature(temperature=kwargs.get(ATTR_TEMPERATURE))

View File

@@ -1,156 +0,0 @@
"""Setup config flow for Actron Air integration."""
import asyncio
from collections.abc import Mapping
from typing import Any
from actron_neo_api import ActronAirAPI, ActronAirAuthError
from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_API_TOKEN
from homeassistant.exceptions import HomeAssistantError
from .const import _LOGGER, DOMAIN
class ActronAirConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Actron Air."""
def __init__(self) -> None:
"""Initialize the config flow."""
self._api: ActronAirAPI | None = None
self._device_code: str | None = None
self._user_code: str = ""
self._verification_uri: str = ""
self._expires_minutes: str = "30"
self.login_task: asyncio.Task | None = None
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Handle the initial step."""
if self._api is None:
_LOGGER.debug("Initiating device authorization")
self._api = ActronAirAPI()
try:
device_code_response = await self._api.request_device_code()
except ActronAirAuthError as err:
_LOGGER.error("OAuth2 flow failed: %s", err)
return self.async_abort(reason="oauth2_error")
self._device_code = device_code_response["device_code"]
self._user_code = device_code_response["user_code"]
self._verification_uri = device_code_response["verification_uri_complete"]
self._expires_minutes = str(device_code_response["expires_in"] // 60)
async def _wait_for_authorization() -> None:
"""Wait for the user to authorize the device."""
assert self._api is not None
assert self._device_code is not None
_LOGGER.debug("Waiting for device authorization")
try:
await self._api.poll_for_token(self._device_code)
_LOGGER.debug("Authorization successful")
except ActronAirAuthError as ex:
_LOGGER.exception("Error while waiting for device authorization")
raise CannotConnect from ex
_LOGGER.debug("Checking login task")
if self.login_task is None:
_LOGGER.debug("Creating task for device authorization")
self.login_task = self.hass.async_create_task(_wait_for_authorization())
if self.login_task.done():
_LOGGER.debug("Login task is done, checking results")
if exception := self.login_task.exception():
if isinstance(exception, CannotConnect):
return self.async_show_progress_done(
next_step_id="connection_error"
)
return self.async_show_progress_done(next_step_id="timeout")
return self.async_show_progress_done(next_step_id="finish_login")
return self.async_show_progress(
step_id="user",
progress_action="wait_for_authorization",
description_placeholders={
"user_code": self._user_code,
"verification_uri": self._verification_uri,
"expires_minutes": self._expires_minutes,
},
progress_task=self.login_task,
)
async def async_step_finish_login(
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Handle the finalization of login."""
_LOGGER.debug("Finalizing authorization")
assert self._api is not None
try:
user_data = await self._api.get_user_info()
except ActronAirAuthError as err:
_LOGGER.error("Error getting user info: %s", err)
return self.async_abort(reason="oauth2_error")
unique_id = str(user_data["id"])
await self.async_set_unique_id(unique_id)
# Check if this is a reauth flow
if self.source == SOURCE_REAUTH:
self._abort_if_unique_id_mismatch(reason="wrong_account")
return self.async_update_reload_and_abort(
self._get_reauth_entry(),
data_updates={CONF_API_TOKEN: self._api.refresh_token_value},
)
self._abort_if_unique_id_configured()
return self.async_create_entry(
title=user_data["email"],
data={CONF_API_TOKEN: self._api.refresh_token_value},
)
async def async_step_timeout(
self,
user_input: dict[str, Any] | None = None,
) -> ConfigFlowResult:
"""Handle issues that need transition await from progress step."""
if user_input is None:
return self.async_show_form(
step_id="timeout",
)
del self.login_task
return await self.async_step_user()
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle reauthentication request."""
return await self.async_step_reauth_confirm()
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Confirm reauth dialog."""
if user_input is not None:
return await self.async_step_user()
return self.async_show_form(step_id="reauth_confirm")
async def async_step_connection_error(
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Handle connection error from progress step."""
if user_input is None:
return self.async_show_form(step_id="connection_error")
# Reset state and try again
self._api = None
self._device_code = None
self.login_task = None
return await self.async_step_user()
class CannotConnect(HomeAssistantError):
"""Error to indicate we cannot connect."""

View File

@@ -1,6 +0,0 @@
"""Constants used by Actron Air integration."""
import logging
_LOGGER = logging.getLogger(__package__)
DOMAIN = "actron_air"

View File

@@ -1,87 +0,0 @@
"""Coordinator for Actron Air integration."""
from __future__ import annotations
from dataclasses import dataclass
from datetime import timedelta
from actron_neo_api import (
ActronAirACSystem,
ActronAirAPI,
ActronAirAPIError,
ActronAirAuthError,
ActronAirStatus,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from homeassistant.util import dt as dt_util
from .const import _LOGGER, DOMAIN
SCAN_INTERVAL = timedelta(seconds=30)
STALE_DEVICE_TIMEOUT = timedelta(minutes=5)
ERROR_NO_SYSTEMS_FOUND = "no_systems_found"
ERROR_UNKNOWN = "unknown_error"
@dataclass
class ActronAirRuntimeData:
"""Runtime data for the Actron Air integration."""
api: ActronAirAPI
system_coordinators: dict[str, ActronAirSystemCoordinator]
type ActronAirConfigEntry = ConfigEntry[ActronAirRuntimeData]
class ActronAirSystemCoordinator(DataUpdateCoordinator[ActronAirACSystem]):
"""System coordinator for Actron Air integration."""
def __init__(
self,
hass: HomeAssistant,
entry: ActronAirConfigEntry,
api: ActronAirAPI,
system: ActronAirACSystem,
) -> None:
"""Initialize the coordinator."""
super().__init__(
hass,
_LOGGER,
name="Actron Air Status",
update_interval=SCAN_INTERVAL,
config_entry=entry,
)
self.system = system
self.serial_number = system["serial"]
self.api = api
self.status = self.api.state_manager.get_status(self.serial_number)
self.last_seen = dt_util.utcnow()
async def _async_update_data(self) -> ActronAirStatus:
"""Fetch updates and merge incremental changes into the full state."""
try:
await self.api.update_status()
except ActronAirAuthError as err:
raise ConfigEntryAuthFailed(
translation_domain=DOMAIN,
translation_key="auth_error",
) from err
except ActronAirAPIError as err:
raise UpdateFailed(
translation_domain=DOMAIN,
translation_key="update_error",
translation_placeholders={"error": repr(err)},
) from err
self.status = self.api.state_manager.get_status(self.serial_number)
self.last_seen = dt_util.utcnow()
return self.status
def is_device_stale(self) -> bool:
"""Check if a device is stale (not seen for a while)."""
return (dt_util.utcnow() - self.last_seen) > STALE_DEVICE_TIMEOUT

View File

@@ -1,63 +0,0 @@
"""Base entity classes for Actron Air integration."""
from actron_neo_api import ActronAirZone
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import DOMAIN
from .coordinator import ActronAirSystemCoordinator
class ActronAirEntity(CoordinatorEntity[ActronAirSystemCoordinator]):
"""Base class for Actron Air entities."""
_attr_has_entity_name = True
def __init__(self, coordinator: ActronAirSystemCoordinator) -> None:
"""Initialize the entity."""
super().__init__(coordinator)
self._serial_number = coordinator.serial_number
@property
def available(self) -> bool:
"""Return True if entity is available."""
return not self.coordinator.is_device_stale()
class ActronAirAcEntity(ActronAirEntity):
"""Base class for Actron Air entities."""
def __init__(self, coordinator: ActronAirSystemCoordinator) -> None:
"""Initialize the entity."""
super().__init__(coordinator)
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, self._serial_number)},
name=coordinator.data.ac_system.system_name,
manufacturer="Actron Air",
model_id=coordinator.data.ac_system.master_wc_model,
sw_version=coordinator.data.ac_system.master_wc_firmware_version,
serial_number=self._serial_number,
)
class ActronAirZoneEntity(ActronAirEntity):
"""Base class for Actron Air zone entities."""
def __init__(
self,
coordinator: ActronAirSystemCoordinator,
zone: ActronAirZone,
) -> None:
"""Initialize the entity."""
super().__init__(coordinator)
self._zone_id: int = zone.zone_id
self._zone_identifier = f"{self._serial_number}_zone_{zone.zone_id}"
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, self._zone_identifier)},
name=zone.title,
manufacturer="Actron Air",
model="Zone",
suggested_area=zone.title,
via_device=(DOMAIN, self._serial_number),
)

View File

@@ -1,30 +0,0 @@
{
"entity": {
"switch": {
"away_mode": {
"default": "mdi:home-export-outline",
"state": {
"off": "mdi:home-import-outline"
}
},
"continuous_fan": {
"default": "mdi:fan",
"state": {
"off": "mdi:fan-off"
}
},
"quiet_mode": {
"default": "mdi:volume-low",
"state": {
"off": "mdi:volume-high"
}
},
"turbo_mode": {
"default": "mdi:fan-plus",
"state": {
"off": "mdi:fan"
}
}
}
}
}

View File

@@ -1,17 +0,0 @@
{
"domain": "actron_air",
"name": "Actron Air",
"codeowners": ["@kclif9", "@JagadishDhanamjayam"],
"config_flow": true,
"dhcp": [
{
"hostname": "neo-*",
"macaddress": "FC0FE7*"
}
],
"documentation": "https://www.home-assistant.io/integrations/actron_air",
"integration_type": "hub",
"iot_class": "cloud_polling",
"quality_scale": "bronze",
"requirements": ["actron-neo-api==0.4.1"]
}

View File

@@ -1,78 +0,0 @@
rules:
# Bronze
action-setup:
status: exempt
comment: This integration does not have custom service actions.
appropriate-polling: done
brands: done
common-modules: done
config-flow-test-coverage: done
config-flow: done
dependency-transparency: done
docs-actions:
status: exempt
comment: This integration does not have custom service actions.
docs-high-level-description: done
docs-installation-instructions: done
docs-removal-instructions: done
entity-event-setup:
status: exempt
comment: This integration does not subscribe to external events.
entity-unique-id: done
has-entity-name: done
runtime-data: done
test-before-configure: done
test-before-setup: done
unique-config-entry: done
# Silver
action-exceptions: todo
config-entry-unloading: done
docs-configuration-parameters:
status: exempt
comment: No options flow
docs-installation-parameters: done
entity-unavailable: done
integration-owner: done
log-when-unavailable: done
parallel-updates: done
reauthentication-flow: done
test-coverage: todo
# Gold
devices: done
diagnostics: todo
discovery-update-info:
status: exempt
comment: This integration uses DHCP discovery, however is cloud polling. Therefore there is no information to update.
discovery: done
docs-data-update: done
docs-examples: done
docs-known-limitations: done
docs-supported-devices: done
docs-supported-functions: done
docs-troubleshooting: done
docs-use-cases: done
dynamic-devices: todo
entity-category:
status: exempt
comment: This integration does not use entity categories.
entity-device-class:
status: exempt
comment: This integration does not use entity device classes.
entity-disabled-by-default:
status: exempt
comment: Not required for this integration at this stage.
entity-translations: todo
exception-translations: todo
icon-translations: todo
reconfiguration-flow: todo
repair-issues:
status: exempt
comment: This integration does not have any known issues that require repair.
stale-devices: todo
# Platinum
async-dependency: done
inject-websession: todo
strict-typing: todo

View File

@@ -1,59 +0,0 @@
{
"config": {
"abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_account%]",
"oauth2_error": "Failed to start authentication flow",
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]",
"wrong_account": "You must reauthenticate with the same Actron Air account that was originally configured."
},
"error": {
"oauth2_error": "Failed to start authentication flow. Please try again later."
},
"progress": {
"wait_for_authorization": "To authenticate, open the following URL and login at Actron Air:\n{verification_uri}\nIf the code is not automatically copied, paste the following code to authorize the integration:\n\n```{user_code}```\n\n\nThe login attempt will time out after {expires_minutes} minutes."
},
"step": {
"connection_error": {
"data": {},
"description": "Failed to connect to Actron Air. Please check your internet connection and try again.",
"title": "Connection error"
},
"reauth_confirm": {
"description": "Your Actron Air authentication has expired. Select continue to reauthenticate with your Actron Air account. You will be prompted to log in again to restore the connection.",
"title": "Authentication expired"
},
"timeout": {
"data": {},
"description": "The authentication process timed out. Please try again.",
"title": "Authentication timeout"
},
"user": {
"title": "Actron Air Authentication"
}
}
},
"entity": {
"switch": {
"away_mode": {
"name": "Away mode"
},
"continuous_fan": {
"name": "Continuous fan"
},
"quiet_mode": {
"name": "Quiet mode"
},
"turbo_mode": {
"name": "Turbo mode"
}
}
},
"exceptions": {
"auth_error": {
"message": "Authentication failed, please reauthenticate"
},
"update_error": {
"message": "An error occurred while retrieving data from the Actron Air API: {error}"
}
}
}

View File

@@ -1,102 +0,0 @@
"""Switch platform for Actron Air integration."""
from collections.abc import Awaitable, Callable
from dataclasses import dataclass
from typing import Any
from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
from homeassistant.const import EntityCategory
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from .coordinator import ActronAirConfigEntry, ActronAirSystemCoordinator
from .entity import ActronAirAcEntity
PARALLEL_UPDATES = 0
@dataclass(frozen=True, kw_only=True)
class ActronAirSwitchEntityDescription(SwitchEntityDescription):
"""Class describing Actron Air switch entities."""
is_on_fn: Callable[[ActronAirSystemCoordinator], bool]
set_fn: Callable[[ActronAirSystemCoordinator, bool], Awaitable[None]]
is_supported_fn: Callable[[ActronAirSystemCoordinator], bool] = lambda _: True
SWITCHES: tuple[ActronAirSwitchEntityDescription, ...] = (
ActronAirSwitchEntityDescription(
key="away_mode",
translation_key="away_mode",
is_on_fn=lambda coordinator: coordinator.data.user_aircon_settings.away_mode,
set_fn=lambda coordinator,
enabled: coordinator.data.user_aircon_settings.set_away_mode(enabled),
),
ActronAirSwitchEntityDescription(
key="continuous_fan",
translation_key="continuous_fan",
is_on_fn=lambda coordinator: coordinator.data.user_aircon_settings.continuous_fan_enabled,
set_fn=lambda coordinator,
enabled: coordinator.data.user_aircon_settings.set_continuous_mode(enabled),
),
ActronAirSwitchEntityDescription(
key="quiet_mode",
translation_key="quiet_mode",
is_on_fn=lambda coordinator: coordinator.data.user_aircon_settings.quiet_mode_enabled,
set_fn=lambda coordinator,
enabled: coordinator.data.user_aircon_settings.set_quiet_mode(enabled),
),
ActronAirSwitchEntityDescription(
key="turbo_mode",
translation_key="turbo_mode",
is_on_fn=lambda coordinator: coordinator.data.user_aircon_settings.turbo_enabled,
set_fn=lambda coordinator,
enabled: coordinator.data.user_aircon_settings.set_turbo_mode(enabled),
is_supported_fn=lambda coordinator: coordinator.data.user_aircon_settings.turbo_supported,
),
)
async def async_setup_entry(
hass: HomeAssistant,
entry: ActronAirConfigEntry,
async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
"""Set up Actron Air switch entities."""
system_coordinators = entry.runtime_data.system_coordinators
async_add_entities(
ActronAirSwitch(coordinator, description)
for coordinator in system_coordinators.values()
for description in SWITCHES
if description.is_supported_fn(coordinator)
)
class ActronAirSwitch(ActronAirAcEntity, SwitchEntity):
"""Actron Air switch."""
_attr_entity_category = EntityCategory.CONFIG
entity_description: ActronAirSwitchEntityDescription
def __init__(
self,
coordinator: ActronAirSystemCoordinator,
description: ActronAirSwitchEntityDescription,
) -> None:
"""Initialize the switch."""
super().__init__(coordinator)
self.entity_description = description
self._attr_unique_id = f"{coordinator.serial_number}_{description.key}"
@property
def is_on(self) -> bool:
"""Return true if the switch is on."""
return self.entity_description.is_on_fn(self.coordinator)
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the switch on."""
await self.entity_description.set_fn(self.coordinator, True)
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the switch off."""
await self.entity_description.set_fn(self.coordinator, False)

View File

@@ -17,11 +17,6 @@ from homeassistant.const import (
CONF_UNIQUE_ID,
)
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.selector import (
TextSelector,
TextSelectorConfig,
TextSelectorType,
)
from .const import (
ACCOUNT_ID,
@@ -71,15 +66,7 @@ class AdaxConfigFlow(ConfigFlow, domain=DOMAIN):
) -> ConfigFlowResult:
"""Handle the local step."""
data_schema = vol.Schema(
{
vol.Required(WIFI_SSID): str,
vol.Required(WIFI_PSWD): TextSelector(
TextSelectorConfig(
type=TextSelectorType.PASSWORD,
autocomplete="current-password",
),
),
}
{vol.Required(WIFI_SSID): str, vol.Required(WIFI_PSWD): str}
)
if user_input is None:
return self.async_show_form(

View File

@@ -6,5 +6,5 @@
"documentation": "https://www.home-assistant.io/integrations/adax",
"iot_class": "local_polling",
"loggers": ["adax", "adax_local"],
"requirements": ["adax==0.4.0", "Adax-local==0.3.0"]
"requirements": ["adax==0.4.0", "Adax-local==0.1.5"]
}

View File

@@ -2,16 +2,14 @@
from __future__ import annotations
from dataclasses import dataclass
from typing import cast
from homeassistant.components.sensor import (
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
SensorStateClass,
)
from homeassistant.const import UnitOfEnergy, UnitOfTemperature
from homeassistant.const import UnitOfEnergy
from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
@@ -22,74 +20,44 @@ from .const import CONNECTION_TYPE, DOMAIN, LOCAL
from .coordinator import AdaxCloudCoordinator
@dataclass(kw_only=True, frozen=True)
class AdaxSensorDescription(SensorEntityDescription):
"""Describes Adax sensor entity."""
data_key: str
SENSORS: tuple[AdaxSensorDescription, ...] = (
AdaxSensorDescription(
key="temperature",
data_key="temperature",
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=1,
),
AdaxSensorDescription(
key="energy",
data_key="energyWh",
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
state_class=SensorStateClass.TOTAL_INCREASING,
suggested_display_precision=3,
),
)
async def async_setup_entry(
hass: HomeAssistant,
entry: AdaxConfigEntry,
async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
"""Set up the Adax sensors with config flow."""
"""Set up the Adax energy sensors with config flow."""
if entry.data.get(CONNECTION_TYPE) != LOCAL:
cloud_coordinator = cast(AdaxCloudCoordinator, entry.runtime_data)
# Create individual energy sensors for each device
async_add_entities(
[
AdaxSensor(cloud_coordinator, entity_description, device_id)
for device_id in cloud_coordinator.data
for entity_description in SENSORS
]
AdaxEnergySensor(cloud_coordinator, device_id)
for device_id in cloud_coordinator.data
)
class AdaxSensor(CoordinatorEntity[AdaxCloudCoordinator], SensorEntity):
"""Representation of an Adax sensor."""
class AdaxEnergySensor(CoordinatorEntity[AdaxCloudCoordinator], SensorEntity):
"""Representation of an Adax energy sensor."""
entity_description: AdaxSensorDescription
_attr_has_entity_name = True
_attr_translation_key = "energy"
_attr_device_class = SensorDeviceClass.ENERGY
_attr_native_unit_of_measurement = UnitOfEnergy.WATT_HOUR
_attr_suggested_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR
_attr_state_class = SensorStateClass.TOTAL_INCREASING
_attr_suggested_display_precision = 3
def __init__(
self,
coordinator: AdaxCloudCoordinator,
entity_description: AdaxSensorDescription,
device_id: str,
) -> None:
"""Initialize the sensor."""
"""Initialize the energy sensor."""
super().__init__(coordinator)
self.entity_description = entity_description
self._device_id = device_id
room = coordinator.data[device_id]
self._attr_unique_id = (
f"{room['homeId']}_{device_id}_{self.entity_description.key}"
)
self._attr_unique_id = f"{room['homeId']}_{device_id}_energy"
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, device_id)},
name=room["name"],
@@ -100,14 +68,10 @@ class AdaxSensor(CoordinatorEntity[AdaxCloudCoordinator], SensorEntity):
def available(self) -> bool:
"""Return True if entity is available."""
return (
super().available
and self.entity_description.data_key
in self.coordinator.data[self._device_id]
super().available and "energyWh" in self.coordinator.data[self._device_id]
)
@property
def native_value(self) -> int | float | None:
def native_value(self) -> int:
"""Return the native value of the sensor."""
return self.coordinator.data[self._device_id].get(
self.entity_description.data_key
)
return int(self.coordinator.data[self._device_id]["energyWh"])

View File

@@ -1,34 +1,34 @@
{
"config": {
"abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
"heater_not_available": "Heater not available. Try to reset the heater by pressing + and OK for some seconds.",
"heater_not_found": "Heater not found. Try to move the heater closer to Home Assistant computer.",
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]"
},
"error": {
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
},
"step": {
"cloud": {
"data": {
"account_id": "Account ID",
"password": "[%key:common::config_flow::data::password%]"
}
},
"local": {
"data": {
"wifi_pswd": "Wi-Fi password",
"wifi_ssid": "Wi-Fi SSID"
},
"description": "Reset the heater by pressing + and OK until display shows 'Reset'. Then press and hold OK button on the heater until the blue LED starts blinking before pressing Submit. Configuring heater might take some minutes."
},
"user": {
"data": {
"connection_type": "Select connection type"
},
"description": "Select connection type. Local requires heaters with Bluetooth"
},
"local": {
"data": {
"wifi_ssid": "Wi-Fi SSID",
"wifi_pswd": "Wi-Fi password"
},
"description": "Reset the heater by pressing + and OK until display shows 'Reset'. Then press and hold OK button on the heater until the blue LED starts blinking before pressing Submit. Configuring heater might take some minutes."
},
"cloud": {
"data": {
"account_id": "Account ID",
"password": "[%key:common::config_flow::data::password%]"
}
}
},
"error": {
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
},
"abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
"heater_not_available": "Heater not available. Try to reset the heater by pressing + and OK for some seconds.",
"heater_not_found": "Heater not found. Try to move the heater closer to Home Assistant computer.",
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]"
}
}
}

View File

@@ -45,7 +45,7 @@ SERVICE_REFRESH_SCHEMA = vol.Schema(
{vol.Optional(CONF_FORCE, default=False): cv.boolean}
)
PLATFORMS = [Platform.SENSOR, Platform.SWITCH, Platform.UPDATE]
PLATFORMS = [Platform.SENSOR, Platform.SWITCH]
type AdGuardConfigEntry = ConfigEntry[AdGuardData]

View File

@@ -1,9 +1,6 @@
{
"entity": {
"sensor": {
"average_processing_speed": {
"default": "mdi:speedometer"
},
"dns_queries": {
"default": "mdi:magnify"
},
@@ -16,18 +13,21 @@
"parental_control_blocked": {
"default": "mdi:human-male-girl"
},
"rules_count": {
"default": "mdi:counter"
},
"safe_browsing_blocked": {
"default": "mdi:shield-half-full"
},
"safe_searches_enforced": {
"default": "mdi:shield-search"
},
"average_processing_speed": {
"default": "mdi:speedometer"
},
"rules_count": {
"default": "mdi:counter"
}
},
"switch": {
"filtering": {
"protection": {
"default": "mdi:shield-check",
"state": {
"off": "mdi:shield-off"
@@ -39,13 +39,7 @@
"off": "mdi:shield-off"
}
},
"protection": {
"default": "mdi:shield-check",
"state": {
"off": "mdi:shield-off"
}
},
"query_log": {
"safe_search": {
"default": "mdi:shield-check",
"state": {
"off": "mdi:shield-off"
@@ -57,7 +51,13 @@
"off": "mdi:shield-off"
}
},
"safe_search": {
"filtering": {
"default": "mdi:shield-check",
"state": {
"off": "mdi:shield-off"
}
},
"query_log": {
"default": "mdi:shield-check",
"state": {
"off": "mdi:shield-off"
@@ -69,17 +69,17 @@
"add_url": {
"service": "mdi:link-plus"
},
"disable_url": {
"service": "mdi:link-variant-off"
"remove_url": {
"service": "mdi:link-off"
},
"enable_url": {
"service": "mdi:link-variant"
},
"disable_url": {
"service": "mdi:link-variant-off"
},
"refresh": {
"service": "mdi:refresh"
},
"remove_url": {
"service": "mdi:link-off"
}
}
}

View File

@@ -7,5 +7,5 @@
"integration_type": "service",
"iot_class": "local_polling",
"loggers": ["adguardhome"],
"requirements": ["adguardhome==0.8.1"]
"requirements": ["adguardhome==0.7.0"]
}

View File

@@ -1,38 +1,35 @@
{
"config": {
"abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_service%]",
"existing_instance_updated": "Updated existing configuration."
},
"error": {
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
},
"step": {
"hassio_confirm": {
"description": "Do you want to configure Home Assistant to connect to the AdGuard Home provided by the add-on: {addon}?",
"title": "AdGuard Home via Home Assistant add-on"
},
"user": {
"description": "Set up your AdGuard Home instance to allow monitoring and control.",
"data": {
"host": "[%key:common::config_flow::data::host%]",
"password": "[%key:common::config_flow::data::password%]",
"port": "[%key:common::config_flow::data::port%]",
"ssl": "[%key:common::config_flow::data::ssl%]",
"username": "[%key:common::config_flow::data::username%]",
"ssl": "[%key:common::config_flow::data::ssl%]",
"verify_ssl": "[%key:common::config_flow::data::verify_ssl%]"
},
"data_description": {
"host": "The hostname or IP address of the device running your AdGuard Home."
},
"description": "Set up your AdGuard Home instance to allow monitoring and control."
}
},
"hassio_confirm": {
"title": "AdGuard Home via Home Assistant add-on",
"description": "Do you want to configure Home Assistant to connect to the AdGuard Home provided by the add-on: {addon}?"
}
},
"error": {
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
},
"abort": {
"existing_instance_updated": "Updated existing configuration.",
"already_configured": "[%key:common::config_flow::abort::already_configured_service%]"
}
},
"entity": {
"sensor": {
"average_processing_speed": {
"name": "Average processing speed"
},
"dns_queries": {
"name": "DNS queries"
},
@@ -45,91 +42,94 @@
"parental_control_blocked": {
"name": "Parental control blocked"
},
"rules_count": {
"name": "Rules count"
},
"safe_browsing_blocked": {
"name": "Safe browsing blocked"
},
"safe_searches_enforced": {
"name": "Safe searches enforced"
},
"average_processing_speed": {
"name": "Average processing speed"
},
"rules_count": {
"name": "Rules count"
}
},
"switch": {
"filtering": {
"name": "Filtering"
"protection": {
"name": "Protection"
},
"parental": {
"name": "Parental control"
},
"protection": {
"name": "Protection"
},
"query_log": {
"name": "Query log"
"safe_search": {
"name": "Safe search"
},
"safe_browsing": {
"name": "Safe browsing"
},
"safe_search": {
"name": "Safe search"
"filtering": {
"name": "Filtering"
},
"query_log": {
"name": "Query log"
}
}
},
"services": {
"add_url": {
"name": "Add URL",
"description": "Adds a new filter subscription to AdGuard Home.",
"fields": {
"name": {
"description": "The name of the filter subscription.",
"name": "[%key:common::config_flow::data::name%]"
"name": "[%key:common::config_flow::data::name%]",
"description": "The name of the filter subscription."
},
"url": {
"description": "The filter URL to subscribe to, containing the filter rules.",
"name": "[%key:common::config_flow::data::url%]"
"name": "[%key:common::config_flow::data::url%]",
"description": "The filter URL to subscribe to, containing the filter rules."
}
},
"name": "Add URL"
},
"disable_url": {
"description": "Disables a filter subscription in AdGuard Home.",
"fields": {
"url": {
"description": "The filter subscription URL to disable.",
"name": "[%key:common::config_flow::data::url%]"
}
},
"name": "Disable URL"
},
"enable_url": {
"description": "Enables a filter subscription in AdGuard Home.",
"fields": {
"url": {
"description": "The filter subscription URL to enable.",
"name": "[%key:common::config_flow::data::url%]"
}
},
"name": "Enable URL"
},
"refresh": {
"description": "Refreshes all filter subscriptions in AdGuard Home.",
"fields": {
"force": {
"description": "Force update (bypasses AdGuard Home throttling), omit for a regular refresh.",
"name": "Force"
}
},
"name": "Refresh"
}
},
"remove_url": {
"name": "Remove URL",
"description": "Removes a filter subscription from AdGuard Home.",
"fields": {
"url": {
"description": "The filter subscription URL to remove.",
"name": "[%key:common::config_flow::data::url%]"
"name": "[%key:common::config_flow::data::url%]",
"description": "The filter subscription URL to remove."
}
},
"name": "Remove URL"
}
},
"enable_url": {
"name": "Enable URL",
"description": "Enables a filter subscription in AdGuard Home.",
"fields": {
"url": {
"name": "[%key:common::config_flow::data::url%]",
"description": "The filter subscription URL to enable."
}
}
},
"disable_url": {
"name": "Disable URL",
"description": "Disables a filter subscription in AdGuard Home.",
"fields": {
"url": {
"name": "[%key:common::config_flow::data::url%]",
"description": "The filter subscription URL to disable."
}
}
},
"refresh": {
"name": "Refresh",
"description": "Refreshes all filter subscriptions in AdGuard Home.",
"fields": {
"force": {
"name": "Force",
"description": "Force update (bypasses AdGuard Home throttling), omit for a regular refresh."
}
}
}
}
}

View File

@@ -1,71 +0,0 @@
"""AdGuard Home Update platform."""
from __future__ import annotations
from datetime import timedelta
from typing import Any
from adguardhome import AdGuardHomeError
from homeassistant.components.update import UpdateEntity, UpdateEntityFeature
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from . import AdGuardConfigEntry, AdGuardData
from .const import DOMAIN
from .entity import AdGuardHomeEntity
SCAN_INTERVAL = timedelta(seconds=300)
PARALLEL_UPDATES = 1
async def async_setup_entry(
hass: HomeAssistant,
entry: AdGuardConfigEntry,
async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
"""Set up AdGuard Home update entity based on a config entry."""
data = entry.runtime_data
if (await data.client.update.update_available()).disabled:
return
async_add_entities([AdGuardHomeUpdate(data, entry)], True)
class AdGuardHomeUpdate(AdGuardHomeEntity, UpdateEntity):
"""Defines an AdGuard Home update."""
_attr_supported_features = UpdateEntityFeature.INSTALL
_attr_name = None
def __init__(
self,
data: AdGuardData,
entry: AdGuardConfigEntry,
) -> None:
"""Initialize AdGuard Home update."""
super().__init__(data, entry)
self._attr_unique_id = "_".join(
[DOMAIN, self.adguard.host, str(self.adguard.port), "update"]
)
async def _adguard_update(self) -> None:
"""Update AdGuard Home entity."""
value = await self.adguard.update.update_available()
self._attr_installed_version = self.data.version
self._attr_latest_version = value.new_version
self._attr_release_summary = value.announcement
self._attr_release_url = value.announcement_url
async def async_install(
self, version: str | None, backup: bool, **kwargs: Any
) -> None:
"""Install latest update."""
try:
await self.adguard.update.begin_update()
except AdGuardHomeError as err:
raise HomeAssistantError(f"Failed to install update: {err}") from err
self.hass.config_entries.async_schedule_reload(self._entry.entry_id)

View File

@@ -1,22 +1,22 @@
{
"services": {
"write_data_by_name": {
"name": "Write data by name",
"description": "Write a value to the connected ADS device.",
"fields": {
"adstype": {
"description": "The data type of the variable to write to.",
"name": "ADS type"
},
"adsvar": {
"description": "The name of the variable to write to.",
"name": "ADS variable"
"name": "ADS variable",
"description": "The name of the variable to write to."
},
"adstype": {
"name": "ADS type",
"description": "The data type of the variable to write to."
},
"value": {
"description": "The value to write to the variable.",
"name": "Value"
"name": "Value",
"description": "The value to write to the variable."
}
},
"name": "Write data by name"
}
}
}
}

View File

@@ -4,7 +4,6 @@
"codeowners": ["@Bre77"],
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/advantage_air",
"integration_type": "hub",
"iot_class": "local_polling",
"loggers": ["advantage_air"],
"requirements": ["advantage-air==0.4.4"]

View File

@@ -1,11 +1,11 @@
{
"config": {
"abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
},
"error": {
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
},
"abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
},
"step": {
"user": {
"data": {
@@ -19,14 +19,14 @@
},
"services": {
"set_time_to": {
"name": "Set time to",
"description": "Controls timers to turn the system on or off after a set number of minutes.",
"fields": {
"minutes": {
"description": "Minutes until action.",
"name": "Minutes"
"name": "Minutes",
"description": "Minutes until action."
}
},
"name": "Set time to"
}
}
}
}

View File

@@ -71,14 +71,7 @@ class AemetConfigFlow(ConfigFlow, domain=DOMAIN):
}
)
return self.async_show_form(
step_id="user",
data_schema=schema,
errors=errors,
description_placeholders={
"api_key_url": "https://opendata.aemet.es/centrodedescargas/altaUsuario"
},
)
return self.async_show_form(step_id="user", data_schema=schema, errors=errors)
@staticmethod
@callback

View File

@@ -4,7 +4,6 @@
"codeowners": ["@Noltari"],
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/aemet",
"integration_type": "service",
"iot_class": "cloud_polling",
"loggers": ["aemet_opendata"],
"requirements": ["AEMET-OpenData==0.6.4"]

View File

@@ -14,7 +14,7 @@
"longitude": "[%key:common::config_flow::data::longitude%]",
"name": "Name of the integration"
},
"description": "To generate API key go to {api_key_url}"
"description": "To generate API key go to https://opendata.aemet.es/centrodedescargas/altaUsuario"
}
}
},

View File

@@ -4,7 +4,6 @@
"codeowners": [],
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/aftership",
"integration_type": "service",
"iot_class": "cloud_polling",
"requirements": ["pyaftership==21.11.0"]
}

View File

@@ -1,57 +1,57 @@
{
"config": {
"abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
},
"error": {
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
},
"step": {
"user": {
"data": {
"api_key": "[%key:common::config_flow::data::api_key%]"
}
}
}
},
"issues": {
"deprecated_yaml_import_issue_cannot_connect": {
"description": "Configuring {integration_title} using YAML is being removed but there was a connection error importing your YAML configuration.\n\nEnsure connection to {integration_title} works and restart Home Assistant to try again or remove the {integration_title} YAML configuration from your configuration.yaml file and continue to [set up the integration]({url}) manually.",
"title": "The {integration_title} YAML configuration import failed"
},
"error": {
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
},
"abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
}
},
"services": {
"add_tracking": {
"name": "Add tracking",
"description": "Adds a new tracking number to Aftership.",
"fields": {
"slug": {
"description": "Slug (carrier) of the new tracking.",
"name": "Slug"
"tracking_number": {
"name": "Tracking number",
"description": "Tracking number for the new tracking."
},
"title": {
"description": "A custom title for the new tracking.",
"name": "Title"
"name": "Title",
"description": "A custom title for the new tracking."
},
"tracking_number": {
"description": "Tracking number for the new tracking.",
"name": "Tracking number"
"slug": {
"name": "Slug",
"description": "Slug (carrier) of the new tracking."
}
},
"name": "Add tracking"
}
},
"remove_tracking": {
"name": "Remove tracking",
"description": "Removes a tracking number from Aftership.",
"fields": {
"slug": {
"description": "Slug (carrier) of the tracking to remove.",
"name": "[%key:component::aftership::services::add_tracking::fields::slug::name%]"
},
"tracking_number": {
"description": "Tracking number of the tracking to remove.",
"name": "[%key:component::aftership::services::add_tracking::fields::tracking_number::name%]"
"name": "[%key:component::aftership::services::add_tracking::fields::tracking_number::name%]",
"description": "Tracking number of the tracking to remove."
},
"slug": {
"name": "[%key:component::aftership::services::add_tracking::fields::slug::name%]",
"description": "Slug (carrier) of the tracking to remove."
}
},
"name": "Remove tracking"
}
}
},
"issues": {
"deprecated_yaml_import_issue_cannot_connect": {
"title": "The {integration_title} YAML configuration import failed",
"description": "Configuring {integration_title} using YAML is being removed but there was a connection error importing your YAML configuration.\n\nEnsure connection to {integration_title} works and restart Home Assistant to try again or remove the {integration_title} YAML configuration from your configuration.yaml file and continue to [set up the integration]({url}) manually."
}
}
}

View File

@@ -1,19 +1,19 @@
{
"services": {
"disable_alerts": {
"service": "mdi:bell-off"
},
"enable_alerts": {
"service": "mdi:bell-alert"
},
"snapshot": {
"service": "mdi:camera"
},
"start_recording": {
"service": "mdi:record-rec"
},
"stop_recording": {
"service": "mdi:stop"
},
"enable_alerts": {
"service": "mdi:bell-alert"
},
"disable_alerts": {
"service": "mdi:bell-off"
},
"snapshot": {
"service": "mdi:camera"
}
}
}

Some files were not shown because too many files have changed in this diff Show More