2022-11-17 18:48:16 +01:00
|
|
|
"""
|
|
|
|
Doorlockd -- Binary Kitchen's smart door opener
|
|
|
|
|
|
|
|
Copyright (c) Binary Kitchen e.V., 2022
|
|
|
|
|
|
|
|
Author:
|
|
|
|
Thomas Schmid <tom@binary-kitchen.de>
|
|
|
|
|
|
|
|
This work is licensed under the terms of the GNU GPL, version 2. See
|
|
|
|
the LICENSE file in the top-level directory.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
details.
|
|
|
|
"""
|
|
|
|
|
2022-11-16 20:58:32 +01:00
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
|
2022-11-17 18:35:06 +01:00
|
|
|
|
2022-11-16 20:58:32 +01:00
|
|
|
class DoorlockBackend(ABC):
|
|
|
|
def __init__(self):
|
|
|
|
self.callbacks = list()
|
|
|
|
self.current_state = None
|
|
|
|
|
|
|
|
def update_state(self):
|
|
|
|
self.state_change_callback(self.current_state)
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def set_state(self, state):
|
|
|
|
self.current_state = state
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def get_state(self, state):
|
2022-11-17 18:39:49 +01:00
|
|
|
return self.current_state
|