mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Add repair item to remove no-longer-functioning Flu Near You integration (#76177)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
parent
b5a6ee3c56
commit
639a522caa
@ -388,6 +388,7 @@ omit =
|
|||||||
homeassistant/components/flume/__init__.py
|
homeassistant/components/flume/__init__.py
|
||||||
homeassistant/components/flume/sensor.py
|
homeassistant/components/flume/sensor.py
|
||||||
homeassistant/components/flunearyou/__init__.py
|
homeassistant/components/flunearyou/__init__.py
|
||||||
|
homeassistant/components/flunearyou/repairs.py
|
||||||
homeassistant/components/flunearyou/sensor.py
|
homeassistant/components/flunearyou/sensor.py
|
||||||
homeassistant/components/folder/sensor.py
|
homeassistant/components/folder/sensor.py
|
||||||
homeassistant/components/folder_watcher/*
|
homeassistant/components/folder_watcher/*
|
||||||
|
@ -9,6 +9,7 @@ from typing import Any
|
|||||||
from pyflunearyou import Client
|
from pyflunearyou import Client
|
||||||
from pyflunearyou.errors import FluNearYouError
|
from pyflunearyou.errors import FluNearYouError
|
||||||
|
|
||||||
|
from homeassistant.components.repairs import IssueSeverity, async_create_issue
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, Platform
|
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -26,6 +27,15 @@ PLATFORMS = [Platform.SENSOR]
|
|||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up Flu Near You as config entry."""
|
"""Set up Flu Near You as config entry."""
|
||||||
|
async_create_issue(
|
||||||
|
hass,
|
||||||
|
DOMAIN,
|
||||||
|
"integration_removal",
|
||||||
|
is_fixable=True,
|
||||||
|
severity=IssueSeverity.ERROR,
|
||||||
|
translation_key="integration_removal",
|
||||||
|
)
|
||||||
|
|
||||||
websession = aiohttp_client.async_get_clientsession(hass)
|
websession = aiohttp_client.async_get_clientsession(hass)
|
||||||
client = Client(session=websession)
|
client = Client(session=websession)
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
"name": "Flu Near You",
|
"name": "Flu Near You",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/flunearyou",
|
"documentation": "https://www.home-assistant.io/integrations/flunearyou",
|
||||||
|
"dependencies": ["repairs"],
|
||||||
"requirements": ["pyflunearyou==2.0.2"],
|
"requirements": ["pyflunearyou==2.0.2"],
|
||||||
"codeowners": ["@bachya"],
|
"codeowners": ["@bachya"],
|
||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
|
42
homeassistant/components/flunearyou/repairs.py
Normal file
42
homeassistant/components/flunearyou/repairs.py
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
"""Repairs platform for the Flu Near You integration."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant import data_entry_flow
|
||||||
|
from homeassistant.components.repairs import RepairsFlow
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
|
||||||
|
class FluNearYouFixFlow(RepairsFlow):
|
||||||
|
"""Handler for an issue fixing flow."""
|
||||||
|
|
||||||
|
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:
|
||||||
|
removal_tasks = [
|
||||||
|
self.hass.config_entries.async_remove(entry.entry_id)
|
||||||
|
for entry in self.hass.config_entries.async_entries(DOMAIN)
|
||||||
|
]
|
||||||
|
await asyncio.gather(*removal_tasks)
|
||||||
|
return self.async_create_entry(title="Fixed issue", data={})
|
||||||
|
return self.async_show_form(step_id="confirm", data_schema=vol.Schema({}))
|
||||||
|
|
||||||
|
|
||||||
|
async def async_create_fix_flow(
|
||||||
|
hass: HomeAssistant, issue_id: str
|
||||||
|
) -> FluNearYouFixFlow:
|
||||||
|
"""Create flow."""
|
||||||
|
return FluNearYouFixFlow()
|
@ -16,5 +16,18 @@
|
|||||||
"abort": {
|
"abort": {
|
||||||
"already_configured": "[%key:common::config_flow::abort::already_configured_location%]"
|
"already_configured": "[%key:common::config_flow::abort::already_configured_location%]"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"issues": {
|
||||||
|
"integration_removal": {
|
||||||
|
"title": "Flu Near You is no longer available",
|
||||||
|
"fix_flow": {
|
||||||
|
"step": {
|
||||||
|
"confirm": {
|
||||||
|
"title": "Remove Flu Near You",
|
||||||
|
"description": "The external data source powering the Flu Near You integration is no longer available; thus, the integration no longer works.\n\nPress SUBMIT to remove Flu Near You from your Home Assistant instance."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,5 +16,18 @@
|
|||||||
"title": "Configure Flu Near You"
|
"title": "Configure Flu Near You"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"issues": {
|
||||||
|
"integration_removal": {
|
||||||
|
"fix_flow": {
|
||||||
|
"step": {
|
||||||
|
"confirm": {
|
||||||
|
"description": "The data source that powered the Flu Near You integration is no longer available. Press SUBMIT to remove all configured instances of the integration from Home Assistant.",
|
||||||
|
"title": "Remove Flu Near You"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"title": "Flu Near You is no longer available"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user