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

feat(eep): add ability to provide custom EEP XML file #140

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions enocean/protocol/eep.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@
class EEP(object):
logger = logging.getLogger('enocean.protocol.eep')

def __init__(self):
def __init__(self, file: str = None):
self.init_ok = False
self.telegrams = {}

eep_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'EEP.xml')
if file is None:
eep_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'EEP.xml')
else:
eep_path = os.path.join(os.path.dirname(os.curdir), file)

try:
if version_info[0] > 2:
with open(eep_path, 'r', encoding='UTF-8') as xml_file:
Expand Down
5 changes: 5 additions & 0 deletions enocean/protocol/packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ def parse(self):
self.repeater_count = enocean.utils.from_bitarray(self._bit_status[4:])
return self.parsed

@classmethod
def set_eep_file(cls, eep_file):
''' Set EEP file '''
cls.eep = EEP(eep_file)

def select_eep(self, rorg_func, rorg_type, direction=None, command=None):
''' Set EEP based on FUNC and TYPE '''
# set EEP profile
Expand Down