|
14 | 14 | from homeassistant.helpers import config_validation as cv |
15 | 15 | from homeassistant.helpers import entity_registry as er |
16 | 16 | from homeassistant.helpers.helper_integration import async_handle_source_entity_changes |
17 | | -from homeassistant.helpers.issue_registry import ( |
18 | | - IssueSeverity, |
19 | | - async_create_issue, |
20 | | - async_delete_issue, |
21 | | -) |
22 | 17 | from homeassistant.helpers.typing import ConfigType |
23 | 18 |
|
24 | 19 | from .const import ( |
25 | 20 | CONF_CALENDAR_ENTITY_ID, |
26 | 21 | DOMAIN, |
27 | | - ISSUE_MISSING_CALENDAR_ENTITY, |
28 | 22 | LOGGER, |
29 | 23 | MIN_HA_VERSION, |
30 | 24 | PLATFORMS, |
@@ -61,52 +55,22 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: |
61 | 55 | entity_registry, entry.options[CONF_CALENDAR_ENTITY_ID] |
62 | 56 | ) |
63 | 57 | except vol.Invalid: |
64 | | - async_create_issue( |
65 | | - hass, |
66 | | - DOMAIN, |
67 | | - f"{ISSUE_MISSING_CALENDAR_ENTITY}_{entry.entry_id}", |
68 | | - is_fixable=True, |
69 | | - severity=IssueSeverity.ERROR, |
70 | | - translation_key="missing_calendar_entity", |
71 | | - translation_placeholders={ |
72 | | - "calendar_entity": entry.options[CONF_CALENDAR_ENTITY_ID], |
73 | | - "entry_title": entry.title or "Calendar Event", |
74 | | - }, |
75 | | - data={"entry_id": entry.entry_id}, |
| 58 | + LOGGER.error( |
| 59 | + "Failed to setup calendar_event for unknown entity %s", |
| 60 | + entry.options[CONF_CALENDAR_ENTITY_ID], |
76 | 61 | ) |
77 | 62 |
|
78 | 63 | return False |
79 | 64 |
|
80 | | - # Clean up any existing repair issues since the entity is now valid |
81 | | - async_delete_issue( |
82 | | - hass, DOMAIN, f"{ISSUE_MISSING_CALENDAR_ENTITY}_{entry.entry_id}" |
83 | | - ) |
84 | | - |
85 | 65 | def set_source_entity_id_or_uuid(source_entity_id: str) -> None: |
86 | 66 | hass.config_entries.async_update_entry( |
87 | 67 | entry, |
88 | 68 | options={**entry.options, CONF_CALENDAR_ENTITY_ID: source_entity_id}, |
89 | 69 | ) |
90 | | - # Clean up repair issue when entity is updated |
91 | | - async_delete_issue( |
92 | | - hass, DOMAIN, f"{ISSUE_MISSING_CALENDAR_ENTITY}_{entry.entry_id}" |
93 | | - ) |
94 | 70 |
|
95 | 71 | async def source_entity_removed() -> None: |
96 | | - # The source entity has been removed, create a repair issue for the removed calendar entity. |
97 | | - async_create_issue( |
98 | | - hass, |
99 | | - DOMAIN, |
100 | | - f"{ISSUE_MISSING_CALENDAR_ENTITY}_{entry.entry_id}", |
101 | | - is_fixable=True, |
102 | | - severity=IssueSeverity.ERROR, |
103 | | - translation_key="missing_calendar_entity", |
104 | | - translation_placeholders={ |
105 | | - "calendar_entity": entry.options[CONF_CALENDAR_ENTITY_ID], |
106 | | - "entry_title": entry.title or "Calendar Event", |
107 | | - }, |
108 | | - data={"entry_id": entry.entry_id}, |
109 | | - ) |
| 72 | + # The source entity has been removed, remove the config entry. |
| 73 | + await hass.config_entries.async_remove(entry.entry_id) |
110 | 74 |
|
111 | 75 | entry.async_on_unload( |
112 | 76 | async_handle_source_entity_changes( |
@@ -134,9 +98,4 @@ async def config_entry_update_listener(hass: HomeAssistant, entry: ConfigEntry) |
134 | 98 | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: |
135 | 99 | """Unload a config entry.""" |
136 | 100 |
|
137 | | - # Clean up any repair issues when unloading the entry |
138 | | - async_delete_issue( |
139 | | - hass, DOMAIN, f"{ISSUE_MISSING_CALENDAR_ENTITY}_{entry.entry_id}" |
140 | | - ) |
141 | | - |
142 | 101 | return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) |
0 commit comments