mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 14:27:07 +00:00
Add modbus write coils (#48676)
* Add missing function in class. write_coils was missing. * Remove dead code. The HA configuration secures that CONF_TYPE only contains legal values, so having an empty assert to catch unknown values is dead code. An empty assert is not informative.
This commit is contained in:
parent
b34cc7ef2c
commit
d5ef382fd5
@ -182,8 +182,6 @@ class ModbusHub:
|
|||||||
port=self._config_port,
|
port=self._config_port,
|
||||||
timeout=self._config_timeout,
|
timeout=self._config_timeout,
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
assert False
|
|
||||||
|
|
||||||
# Connect device
|
# Connect device
|
||||||
self.connect()
|
self.connect()
|
||||||
@ -228,6 +226,12 @@ class ModbusHub:
|
|||||||
kwargs = {"unit": unit} if unit else {}
|
kwargs = {"unit": unit} if unit else {}
|
||||||
self._client.write_coil(address, value, **kwargs)
|
self._client.write_coil(address, value, **kwargs)
|
||||||
|
|
||||||
|
def write_coils(self, unit, address, value):
|
||||||
|
"""Write coil."""
|
||||||
|
with self._lock:
|
||||||
|
kwargs = {"unit": unit} if unit else {}
|
||||||
|
self._client.write_coils(address, value, **kwargs)
|
||||||
|
|
||||||
def write_register(self, unit, address, value):
|
def write_register(self, unit, address, value):
|
||||||
"""Write register."""
|
"""Write register."""
|
||||||
with self._lock:
|
with self._lock:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user