Rename domain import in modbus (#33906)
parent
4c38e6cfa5
commit
9535dd87b0
|
@ -35,7 +35,7 @@ from .const import (
|
|||
CONF_PARITY,
|
||||
CONF_STOPBITS,
|
||||
DEFAULT_HUB,
|
||||
MODBUS_DOMAIN,
|
||||
MODBUS_DOMAIN as DOMAIN,
|
||||
SERVICE_WRITE_COIL,
|
||||
SERVICE_WRITE_REGISTER,
|
||||
)
|
||||
|
@ -68,7 +68,7 @@ ETHERNET_SCHEMA = BASE_SCHEMA.extend(
|
|||
)
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
{MODBUS_DOMAIN: vol.All(cv.ensure_list, [vol.Any(SERIAL_SCHEMA, ETHERNET_SCHEMA)])},
|
||||
{DOMAIN: vol.All(cv.ensure_list, [vol.Any(SERIAL_SCHEMA, ETHERNET_SCHEMA)])},
|
||||
extra=vol.ALLOW_EXTRA,
|
||||
)
|
||||
|
||||
|
@ -95,9 +95,9 @@ SERVICE_WRITE_COIL_SCHEMA = vol.Schema(
|
|||
|
||||
async def async_setup(hass, config):
|
||||
"""Set up Modbus component."""
|
||||
hass.data[MODBUS_DOMAIN] = hub_collect = {}
|
||||
hass.data[DOMAIN] = hub_collect = {}
|
||||
|
||||
for client_config in config[MODBUS_DOMAIN]:
|
||||
for client_config in config[DOMAIN]:
|
||||
hub_collect[client_config[CONF_NAME]] = ModbusHub(client_config, hass.loop)
|
||||
|
||||
def stop_modbus(event):
|
||||
|
@ -140,13 +140,13 @@ async def async_setup(hass, config):
|
|||
|
||||
# Register services for modbus
|
||||
hass.services.async_register(
|
||||
MODBUS_DOMAIN,
|
||||
DOMAIN,
|
||||
SERVICE_WRITE_REGISTER,
|
||||
write_register,
|
||||
schema=SERVICE_WRITE_REGISTER_SCHEMA,
|
||||
)
|
||||
hass.services.async_register(
|
||||
MODBUS_DOMAIN, SERVICE_WRITE_COIL, write_coil, schema=SERVICE_WRITE_COIL_SCHEMA,
|
||||
DOMAIN, SERVICE_WRITE_COIL, write_coil, schema=SERVICE_WRITE_COIL_SCHEMA,
|
||||
)
|
||||
return True
|
||||
|
||||
|
@ -204,7 +204,6 @@ class ModbusHub:
|
|||
stopbits=self._config_stopbits,
|
||||
bytesize=self._config_bytesize,
|
||||
parity=self._config_parity,
|
||||
timeout=self._config_timeout,
|
||||
loop=self._loop,
|
||||
)
|
||||
elif self._config_type == "rtuovertcp":
|
||||
|
|
|
@ -11,7 +11,7 @@ from homeassistant.components.modbus.const import (
|
|||
CONF_REGISTER_TYPE,
|
||||
CONF_REGISTERS,
|
||||
DEFAULT_HUB,
|
||||
MODBUS_DOMAIN,
|
||||
MODBUS_DOMAIN as DOMAIN,
|
||||
)
|
||||
from homeassistant.const import CONF_NAME, CONF_PLATFORM, CONF_SCAN_INTERVAL
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
@ -25,10 +25,10 @@ _LOGGER = logging.getLogger(__name__)
|
|||
@pytest.fixture()
|
||||
def mock_hub(hass):
|
||||
"""Mock hub."""
|
||||
mock_integration(hass, MockModule(MODBUS_DOMAIN))
|
||||
mock_integration(hass, MockModule(DOMAIN))
|
||||
hub = mock.MagicMock()
|
||||
hub.name = "hub"
|
||||
hass.data[MODBUS_DOMAIN] = {DEFAULT_HUB: hub}
|
||||
hass.data[DOMAIN] = {DEFAULT_HUB: hub}
|
||||
return hub
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue