From c7021e5c9028782b5c1f5bc30719691b7db4abb1 Mon Sep 17 00:00:00 2001 From: jan Iversen Date: Sun, 4 Apr 2021 13:40:31 +0200 Subject: [PATCH 1/2] Add missing function in class. write_coils was missing. --- homeassistant/components/modbus/modbus.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/homeassistant/components/modbus/modbus.py b/homeassistant/components/modbus/modbus.py index 099289d8472aff..c60cee71244e29 100644 --- a/homeassistant/components/modbus/modbus.py +++ b/homeassistant/components/modbus/modbus.py @@ -228,6 +228,12 @@ def write_coil(self, unit, address, value): kwargs = {"unit": unit} if unit else {} 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): """Write register.""" with self._lock: From b5cddd17236b2e297c552b6b836d9b02c47820e8 Mon Sep 17 00:00:00 2001 From: jan Iversen Date: Sun, 4 Apr 2021 13:41:19 +0200 Subject: [PATCH 2/2] 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. --- homeassistant/components/modbus/modbus.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/homeassistant/components/modbus/modbus.py b/homeassistant/components/modbus/modbus.py index c60cee71244e29..0a5422ff6be0eb 100644 --- a/homeassistant/components/modbus/modbus.py +++ b/homeassistant/components/modbus/modbus.py @@ -182,8 +182,6 @@ def setup(self): port=self._config_port, timeout=self._config_timeout, ) - else: - assert False # Connect device self.connect()