mirror of
https://github.com/home-assistant/core.git
synced 2026-12-05 21:29:58 -04:00
Move local_file service registration to services module (#184465)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
4847d9e400
commit
e37cd6fea0
@@ -4,13 +4,25 @@ from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_FILE_PATH, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryError
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import DOMAIN
|
||||
from .services import async_setup_services
|
||||
from .util import check_file_path_access
|
||||
|
||||
PLATFORMS = [Platform.CAMERA]
|
||||
|
||||
|
||||
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
|
||||
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up the Local file integration."""
|
||||
async_setup_services(hass)
|
||||
return True
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Set up Local file from a config entry."""
|
||||
file_path: str = entry.options[CONF_FILE_PATH]
|
||||
|
||||
@@ -4,17 +4,13 @@ import logging
|
||||
import mimetypes
|
||||
from typing import override
|
||||
|
||||
import probatio
|
||||
|
||||
from homeassistant.components.camera import Camera
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_FILE_PATH, CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ServiceValidationError
|
||||
from homeassistant.helpers import config_validation as cv, entity_platform
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
||||
from .const import SERVICE_UPDATE_FILE_PATH
|
||||
from .util import check_file_path_access
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@@ -27,15 +23,6 @@ async def async_setup_entry(
|
||||
) -> None:
|
||||
"""Set up the Camera for local file from a config entry."""
|
||||
|
||||
platform = entity_platform.async_get_current_platform()
|
||||
platform.async_register_entity_service(
|
||||
SERVICE_UPDATE_FILE_PATH,
|
||||
{
|
||||
probatio.Required(CONF_FILE_PATH): cv.string,
|
||||
},
|
||||
"update_file_path",
|
||||
)
|
||||
|
||||
async_add_entities(
|
||||
[
|
||||
LocalFile(
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
"""Services for the Local file integration."""
|
||||
|
||||
import probatio
|
||||
|
||||
from homeassistant.components.camera import DOMAIN as CAMERA_DOMAIN
|
||||
from homeassistant.const import CONF_FILE_PATH
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import config_validation as cv, service
|
||||
|
||||
from .const import DOMAIN, SERVICE_UPDATE_FILE_PATH
|
||||
|
||||
|
||||
@callback
|
||||
def async_setup_services(hass: HomeAssistant) -> None:
|
||||
"""Set up the services for the Local file integration."""
|
||||
|
||||
service.async_register_platform_entity_service(
|
||||
hass,
|
||||
DOMAIN,
|
||||
SERVICE_UPDATE_FILE_PATH,
|
||||
entity_domain=CAMERA_DOMAIN,
|
||||
schema={probatio.Required(CONF_FILE_PATH): cv.string},
|
||||
func="update_file_path",
|
||||
)
|
||||
Reference in New Issue
Block a user