mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Add Fastdotcom service (#105553)
* Add service for manual control * Proper naming * Removing old translation * Reverting back service * Removig services.yaml * Putting back in service * Putting back in service description and yaml * Proper naming * Adding create_issue * Feedback fixes * Fix deprecation date in strings * Update homeassistant/components/fastdotcom/__init__.py * Update homeassistant/components/fastdotcom/strings.json --------- Co-authored-by: G Johansson <goran.johansson@shiftit.se>
This commit is contained in:
parent
0e5d72a501
commit
8bd265c3ae
@ -7,7 +7,8 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||||
from homeassistant.const import CONF_SCAN_INTERVAL, EVENT_HOMEASSISTANT_STARTED
|
from homeassistant.const import CONF_SCAN_INTERVAL, EVENT_HOMEASSISTANT_STARTED
|
||||||
from homeassistant.core import CoreState, Event, HomeAssistant
|
from homeassistant.core import CoreState, Event, HomeAssistant, ServiceCall
|
||||||
|
from homeassistant.helpers import issue_registry as ir
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
@ -52,6 +53,20 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
"""Request a refresh."""
|
"""Request a refresh."""
|
||||||
await coordinator.async_request_refresh()
|
await coordinator.async_request_refresh()
|
||||||
|
|
||||||
|
async def _request_refresh_service(call: ServiceCall) -> None:
|
||||||
|
"""Request a refresh via the service."""
|
||||||
|
ir.async_create_issue(
|
||||||
|
hass,
|
||||||
|
DOMAIN,
|
||||||
|
"service_deprecation",
|
||||||
|
breaks_in_ha_version="2024.7.0",
|
||||||
|
is_fixable=True,
|
||||||
|
is_persistent=False,
|
||||||
|
severity=ir.IssueSeverity.WARNING,
|
||||||
|
translation_key="service_deprecation",
|
||||||
|
)
|
||||||
|
await coordinator.async_request_refresh()
|
||||||
|
|
||||||
if hass.state == CoreState.running:
|
if hass.state == CoreState.running:
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
else:
|
else:
|
||||||
@ -59,6 +74,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, _request_refresh)
|
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, _request_refresh)
|
||||||
|
|
||||||
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator
|
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator
|
||||||
|
hass.services.async_register(DOMAIN, "speedtest", _request_refresh_service)
|
||||||
|
|
||||||
await hass.config_entries.async_forward_entry_setups(
|
await hass.config_entries.async_forward_entry_setups(
|
||||||
entry,
|
entry,
|
||||||
PLATFORMS,
|
PLATFORMS,
|
||||||
|
@ -21,5 +21,18 @@
|
|||||||
"name": "Speed test",
|
"name": "Speed test",
|
||||||
"description": "Immediately executes a speed test with Fast.com."
|
"description": "Immediately executes a speed test with Fast.com."
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"issues": {
|
||||||
|
"service_deprecation": {
|
||||||
|
"title": "Fast.com speedtest service is being removed",
|
||||||
|
"fix_flow": {
|
||||||
|
"step": {
|
||||||
|
"confirm": {
|
||||||
|
"title": "[%key:component::fastdotcom::issues::service_deprecation::title%]",
|
||||||
|
"description": "Use `homeassistant.update_entity` instead to update the data.\n\nPlease replace this service and adjust your automations and scripts and select **submit** to fix this issue."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user