Move ebusd action to services module (#186092)

This commit is contained in:
epenet
2026-10-13 09:03:54 +02:00
committed by GitHub
parent a4c2b12722
commit bb02e70a96
2 changed files with 19 additions and 3 deletions
+2 -3
View File
@@ -19,6 +19,7 @@ from homeassistant.helpers.discovery import load_platform
from homeassistant.helpers.typing import ConfigType
from .const import DOMAIN, EBUSD_DATA, SENSOR_TYPES
from .services import setup_services
_LOGGER = logging.getLogger(__name__)
@@ -26,7 +27,6 @@ DEFAULT_NAME = "ebusd"
DEFAULT_PORT = 8888
CONF_CIRCUIT = "circuit"
CACHE_TTL = 900
SERVICE_EBUSD_WRITE = "ebusd_write"
def verify_ebusd_config(config: ConfigType) -> ConfigType:
@@ -62,6 +62,7 @@ CONFIG_SCHEMA = probatio.Schema(
def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the eBusd component."""
_LOGGER.debug("Integration setup started")
setup_services(hass)
conf: ConfigType = config[DOMAIN]
name: str = conf[CONF_NAME]
circuit: str = conf[CONF_CIRCUIT]
@@ -80,8 +81,6 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
}
load_platform(hass, Platform.SENSOR, DOMAIN, sensor_config, config)
hass.services.register(DOMAIN, SERVICE_EBUSD_WRITE, hass.data[EBUSD_DATA].write)
_LOGGER.debug("Ebusd integration setup completed")
return True
@@ -0,0 +1,17 @@
"""Services for the Ebusd integration."""
from homeassistant.core import HomeAssistant, ServiceCall
from .const import DOMAIN, EBUSD_DATA
SERVICE_EBUSD_WRITE = "ebusd_write"
def _ebusd_write(call: ServiceCall) -> None:
"""Call write method on ebusd."""
call.hass.data[EBUSD_DATA].write(call)
def setup_services(hass: HomeAssistant) -> None:
"""Register the Ebusd services."""
hass.services.register(DOMAIN, SERVICE_EBUSD_WRITE, _ebusd_write)