embyt / enocean-mqtt

Receives messages from an enOcean serial interface (USB) and provides selected messages to an MQTT broker.
GNU General Public License v3.0
42 stars 21 forks source link

Fix some exceptions #36

Closed mak-gitdev closed 1 year ago

mak-gitdev commented 1 year ago

Fix some exceptions related to command id in VLD packets support.

1- In get_command_id(), when profile is not found, profile.contents triggered an exception. This is now detected and None is returned. 2- In _handle_data_packet(), when command is None, hex(command) triggered an exception. The debug message is now not printed in that case.

Sorry for missing these exceptions :disappointed:


By the way, one question not related to this PR. In run(), should the transmitter ID request not be made outside the while loop ?

romor commented 1 year ago

Thanks and sorry for the late reply.

Looks fine to me, except for communicator.py:269. I guess that the else clause shall be removed and return None issued without the else.

If the shortcut is found it will not reach that code anyway and if there is a profile set but content not found it shall also return None.

If the code reaches the end of the function without any return it will also issue None, but this is not so nice in my opinion.

mak-gitdev commented 1 year ago

You're absolutely right. I will make the correction.