Skip to content
Open
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
15 changes: 14 additions & 1 deletion enocean/protocol/eep.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,11 @@ def find_profile(self, bitarray, eep_rorg, rorg_func, rorg_type, direction=None,
return None

profile = self.telegrams[eep_rorg][rorg_func][rorg_type]
eep_command = profile.find('command', recursive=False)

if command:
# multiple commands can be defined, with the command id always in same location (per RORG-FUNC-TYPE).
eep_command = profile.find('command', recursive=False)

# If commands are not set in EEP, or command is None,
# get the first data as a "best guess".
if not eep_command:
Expand All @@ -185,6 +186,18 @@ def find_profile(self, bitarray, eep_rorg, rorg_func, rorg_type, direction=None,
# If eep_command is defined, so should be data.command
return profile.find('data', {'command': str(command)}, recursive=False)

elif eep_command:
# no explicit command has been passed, but the EEP prescribes a command
# try to decode it from the packet
command_value = self._get_raw(eep_command, bitarray)

found_data = profile.find('data', {'command': str(command_value)}, recursive=False)
if found_data:
return found_data

# return the first hit as a best guess
return profile.find('data', recursive=False)

# extract data description
# the direction tag is optional
if direction is None:
Expand Down