generated from ludeeus/integration_blueprint
-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP * WIP * WIP * WIP * Remove print statement * Change logging * Lint * Error handling * Error handling * Error handling for entities * Remove issues if device deleted
- Loading branch information
1 parent
dfcba9e
commit 14f0aa3
Showing
5 changed files
with
153 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
"""Repairs for battery_notes.""" | ||
|
||
from __future__ import annotations | ||
|
||
import voluptuous as vol | ||
from homeassistant import data_entry_flow | ||
from homeassistant.components.repairs import RepairsFlow | ||
from homeassistant.core import HomeAssistant | ||
from homeassistant.helpers import issue_registry as ir | ||
|
||
|
||
class MissingDeviceRepairFlow(RepairsFlow): | ||
"""Handler for an issue fixing flow.""" | ||
|
||
def __init__(self, data: dict[str, str]) -> None: | ||
"""Initialize.""" | ||
self.entry_id = data["entry_id"] | ||
self.device_id = data["device_id"] | ||
self.source_entity_id = data["source_entity_id"] | ||
|
||
async def async_step_init( | ||
self, user_input: dict[str, str] | None = None | ||
) -> data_entry_flow.FlowResult: | ||
"""Handle the first step of a fix flow.""" | ||
|
||
return await (self.async_step_confirm()) | ||
|
||
async def async_step_confirm( | ||
self, user_input: dict[str, str] | None = None | ||
) -> data_entry_flow.FlowResult: | ||
"""Handle the confirm step of a fix flow.""" | ||
if user_input is not None: | ||
await self.hass.config_entries.async_remove(self.entry_id) | ||
|
||
return self.async_create_entry(title="", data={}) | ||
|
||
issue_registry = ir.async_get(self.hass) | ||
description_placeholders = None | ||
if issue := issue_registry.async_get_issue(self.handler, self.issue_id): | ||
description_placeholders = issue.translation_placeholders | ||
|
||
return self.async_show_form( | ||
step_id="confirm", | ||
data_schema=vol.Schema({}), | ||
description_placeholders=description_placeholders | ||
) | ||
|
||
|
||
async def async_create_fix_flow( | ||
hass: HomeAssistant, | ||
issue_id: str, | ||
data: dict[str, str | int | float | None] | None, | ||
) -> RepairsFlow: | ||
"""Create flow.""" | ||
if issue_id.startswith("missing_device_"): | ||
assert data | ||
return MissingDeviceRepairFlow(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters