Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion homeassistant/components/modbus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def __init__(self, client_config, main_loop):
self._config_type = client_config[CONF_TYPE]
self._config_port = client_config[CONF_PORT]
self._config_timeout = client_config[CONF_TIMEOUT]
self._config_delay = client_config[CONF_DELAY]
self._config_delay = 0

if self._config_type == "serial":
# serial configuration
Expand All @@ -181,6 +181,7 @@ def __init__(self, client_config, main_loop):
else:
# network configuration
self._config_host = client_config[CONF_HOST]
self._config_delay = client_config[CONF_DELAY]

@property
def name(self):
Expand Down Expand Up @@ -266,12 +267,16 @@ async def _write(self, unit, address, value, func):

async def read_coils(self, unit, address, count):
"""Read coils."""
if self._client is None:
Comment thread
janiversen marked this conversation as resolved.
Outdated
return None
if self._client.protocol is None:
return None
return await self._read(unit, address, count, self._client.protocol.read_coils)

async def read_discrete_inputs(self, unit, address, count):
"""Read discrete inputs."""
if self._client is None:
return None
if self._client.protocol is None:
return None
return await self._read(
Expand All @@ -280,6 +285,8 @@ async def read_discrete_inputs(self, unit, address, count):

async def read_input_registers(self, unit, address, count):
"""Read input registers."""
if self._client is None:
return None
if self._client.protocol is None:
return None
return await self._read(
Expand All @@ -288,6 +295,8 @@ async def read_input_registers(self, unit, address, count):

async def read_holding_registers(self, unit, address, count):
"""Read holding registers."""
if self._client is None:
return None
if self._client.protocol is None:
return None
return await self._read(
Expand All @@ -296,12 +305,16 @@ async def read_holding_registers(self, unit, address, count):

async def write_coil(self, unit, address, value):
"""Write coil."""
if self._client is None:
return None
if self._client.protocol is None:
return None
return await self._write(unit, address, value, self._client.protocol.write_coil)

async def write_register(self, unit, address, value):
"""Write register."""
if self._client is None:
return None
if self._client.protocol is None:
return None
return await self._write(
Expand All @@ -310,6 +323,8 @@ async def write_register(self, unit, address, value):

async def write_registers(self, unit, address, values):
"""Write registers."""
if self._client is None:
return None
if self._client.protocol is None:
return None
return await self._write(
Expand Down