Skip to content

Commit

Permalink
knx plugin: prevent send actions to bus while plugin is not running
Browse files Browse the repository at this point in the history
  • Loading branch information
bmxp committed Jun 29, 2023
1 parent 817ff16 commit 40bbec8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions knx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ def _check_projectfile_destination(self):
self.logger.warning(self.translate("could not create directory {}").format(self.projectpath.parent))

def _send(self, data):
if not self.alive:
# do not send anything while plugin is not really running
self.logger.warning(self.translate('send called while self.alive is False, will NOT send anything to KNX'))
return

if len(data) < 2 or len(data) > 0xffff:
if self.logger.isEnabledFor(logging.DEBUG):
self.logger.debug(self.translate('Illegal data size: {}').format(repr(data)))
Expand Down Expand Up @@ -257,6 +262,8 @@ def handle_connect(self, client):
:param client: the calling client for adaption purposes
:type client: TCP_client
"""
if not self.alive:
self.logger.warning(self.translate('handle_connect called while self.alive is False'))

# let the knxd use its group address cache
enable_cache = bytearray([0, KNXD.CACHE_ENABLE])
Expand Down

0 comments on commit 40bbec8

Please sign in to comment.