Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

knx plugin: improve logging for sending and polling #940

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Changes from all commits
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
16 changes: 9 additions & 7 deletions knx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ def __init__(self, smarthome):
self.date_ga = self.get_parameter_value('date_ga')
self._send_time_do = self.get_parameter_value('send_time')
self._bm_separatefile = False
self._bm_format = "BM': {1} set {2} to {3}"
self._bm_format = "BM: {1} set {2} to {3}"
self._bm_format_send = "BM: Sending value {3} for GA {2}"
self._bm_format_poll = "BM: Polling value for GA {2}"
self._startup_polling = {}

# following needed for statistics
Expand All @@ -110,6 +112,8 @@ def __init__(self, smarthome):
elif busmonitor.lower() == 'logger':
self._bm_separatefile = True
self._bm_format = "{0};{1};{2};{3}"
self._bm_format_send = "{0};{1};{2};{3}"
self._bm_format_poll = "{0};{1};{2}"
self._busmonitor = logging.getLogger("knx_busmonitor").info
self.logger.info(self.translate("Using busmonitor (L) = '{}'").format(busmonitor))
else:
Expand Down Expand Up @@ -241,6 +245,8 @@ def _poll(self, **kwargs):
item = 'unknown item'
if 'ga' in kwargs:
self.groupread(kwargs['ga'])
if self._log_own_packets is True and self.alive:
self._busmonitor(self._bm_format_poll.format(self.get_instance_name(), 'POLL', kwargs["ga"]))
else:
self.logger.warning(self.translate('problem polling {}, no known ga').format(item))

Expand Down Expand Up @@ -662,10 +668,6 @@ def parse_item(self, item):
randomwait = random.randrange(15)
next = self.shtime.now() + timedelta(seconds=poll_interval + randomwait)
self._startup_polling.update({item: {'ga': poll_ga, 'interval': poll_interval}})
'''
self._sh.scheduler.add(f'KNX poll {item}', self._poll,
value={ITEM: item, 'ga': poll_ga, 'interval': poll_interval}, next=next)
'''
else:
self.logger.warning("Ignoring knx_poll for item {}: We need two parameters, one for the GA and one for the polling interval.".format(item))
pass
Expand Down Expand Up @@ -737,14 +739,14 @@ def update_item(self, item, caller=None, source=None, dest=None):
for ga in self.get_iattr_value(item.conf, KNX_SEND):
_value = item()
if self._log_own_packets is True:
self._busmonitor(self._bm_format.format(self.get_instance_name(), 'SEND', ga, _value))
self._busmonitor(self._bm_format_send.format(self.get_instance_name(), 'SEND', ga, _value))
self.groupwrite(ga, _value, self.get_iattr_value(item.conf, KNX_DPT))
if self.has_iattr(item.conf, KNX_STATUS):
for ga in self.get_iattr_value(item.conf, KNX_STATUS): # send status update
if ga != dest:
_value = item()
if self._log_own_packets is True:
self._busmonitor(self._bm_format.format(self.get_instance_name(), 'STATUS', ga, _value))
self._busmonitor(self._bm_format_send.format(self.get_instance_name(), 'STATUS', ga, _value))
self.groupwrite(ga, _value, self.get_iattr_value(item.conf, KNX_DPT))


Expand Down
Loading