diff --git a/enocean/__init__.py b/enocean/__init__.py index 0871991ad..09b4a505b 100755 --- a/enocean/__init__.py +++ b/enocean/__init__.py @@ -165,7 +165,7 @@ class EnOcean(SmartPlugin): ALLOW_MULTIINSTANCE = False - PLUGIN_VERSION = "1.3.11" + PLUGIN_VERSION = "1.4.0" def __init__(self, sh): @@ -187,13 +187,7 @@ def __init__(self, sh): self.tx_id = int(tx_id, 16) self.logger.info(f"Stick TX ID configured via plugin.conf to: {tx_id}") self._log_unknown_msg = self.get_parameter_value("log_unknown_messages") - try: - self._tcm = serial.serial_for_url(self.port, 57600, timeout=1.5) - except Exception as e: - self._tcm = None - self._init_complete = False - self.logger.error(f"Exception occurred during serial open: {e}") - return + self._tcm = None self._cmd_lock = threading.Lock() self._response_lock = threading.Condition() self._rx_items = {} @@ -447,7 +441,18 @@ def run(self): self.logger.debug("Call function << run >>") self.alive = True self.UTE_listen = False - #self.learn_id = 0 + + # open serial or serial2TCP device: + try: + self._tcm = serial.serial_for_url(self.port, 57600, timeout=1.5) + except Exception as e: + self._tcm = None + self._init_complete = False + self.logger.error(f"Exception occurred during serial open: {e}") + return + else: + self.logger.info(f"Serial port successfully opened at port {self.port}") + t = threading.Thread(target=self._startup, name="enocean-startup") # if you need to create child threads, do not make them daemon = True! # They will not shutdown properly. (It's a python bug) @@ -508,6 +513,8 @@ def run(self): self._tcm.close() except Exception as e: self.logger.error(f"Exception during tcm close occured: {e}") + else: + self.logger.info(f"Enocean serial device closed") self.logger.info("Run method stopped") def stop(self): diff --git a/enocean/plugin.yaml b/enocean/plugin.yaml index 4d40fe6a1..ebaf6538b 100755 --- a/enocean/plugin.yaml +++ b/enocean/plugin.yaml @@ -16,7 +16,7 @@ plugin: # url of the support thread support: https://knx-user-forum.de/forum/supportforen/smarthome-py/26542-featurewunsch-enocean-plugin/page13 - version: 1.3.11 # Plugin version + version: 1.4.0 # Plugin version sh_minversion: 1.3 # minimum shNG version to use this plugin #sh_maxversion: # maximum shNG version to use this plugin (leave empty if latest) multi_instance: False # plugin supports multi instance diff --git a/enocean/user_doc.rst b/enocean/user_doc.rst index d8b4d9c28..94b102c41 100755 --- a/enocean/user_doc.rst +++ b/enocean/user_doc.rst @@ -55,6 +55,7 @@ Alternativ kann eines der oben erwähnten Serial-Geräte auch über das Netzwerk 57600n81,local Für und sind die entsprechenden Werte einzufügen. + Konfiguration ============= @@ -112,7 +113,7 @@ Zu b) 4. Nach dem Neustart das Logfile öffnen und nach dem Eintrag ``enocean: Base ID = 0xYYYYZZZZ`` suchen. -6. Übernahme dieser im Log angezeigten Base-ID in die plugin.yaml als Parameter `tx_id`. +5. Übernahme dieser im Log angezeigten Base-ID in die plugin.yaml als Parameter `tx_id`. item.yaml