From 5d8e81b6c8fc7abe75188007c6a86bb501a314ad Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Sun, 11 Jun 2023 14:02:47 +0300 Subject: config: turn ConfigUnit into singleton --- include/py/homekit/config/config.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/py/homekit/config/config.py b/include/py/homekit/config/config.py index f2a3990..29364af 100644 --- a/include/py/homekit/config/config.py +++ b/include/py/homekit/config/config.py @@ -76,6 +76,13 @@ class BaseConfigUnit(ABC): class ConfigUnit(BaseConfigUnit): NAME = 'dumb' + _instance = None + + def __new__(cls, *args, **kwargs): + if cls._instance is None: + cls._instance = super(ConfigUnit, cls).__new__(cls, *args, **kwargs) + return cls._instance + def __init__(self, name=None, load=True): super().__init__() -- cgit v1.2.3