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:
Erwin Douna 2023-12-12 21:18:12 +01:00 committed by GitHub
parent 0e5d72a501
commit 8bd265c3ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 1 deletions

View File

@ -7,7 +7,8 @@ import voluptuous as vol
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
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
from homeassistant.helpers.typing import ConfigType
@ -52,6 +53,20 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Request a 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:
await coordinator.async_config_entry_first_refresh()
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.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator
hass.services.async_register(DOMAIN, "speedtest", _request_refresh_service)
await hass.config_entries.async_forward_entry_setups(
entry,
PLATFORMS,

View File

@ -21,5 +21,18 @@
"name": "Speed test",
"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."
}
}
}
}
}
}