From 7cf2ec4c6218ef0750803204f373ac700e576679 Mon Sep 17 00:00:00 2001 From: Oliver <10700296+ol-iver@users.noreply.github.com> Date: Mon, 7 Oct 2024 21:23:29 +0200 Subject: [PATCH] Register telnet callbacks only once (#310) --- denonavr/api.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/denonavr/api.py b/denonavr/api.py index 3c57a80..4a27acf 100644 --- a/denonavr/api.py +++ b/denonavr/api.py @@ -604,6 +604,8 @@ def register_callback( if event not in self._callbacks.keys(): self._callbacks[event] = [] + elif callback in self._callbacks[event]: + return self._callbacks[event].append(callback) def unregister_callback( @@ -618,6 +620,8 @@ def _register_raw_callback( self, callback: Callable[[str], Awaitable[None]] ) -> None: """Register a callback handler for raw telnet messages.""" + if callback in self._raw_callbacks: + return self._raw_callbacks.append(callback) def _unregister_raw_callback(