Bouni / python-luxtronik

python-luxtronik is a library that allow you to interact with a Luxtronik heatpump controller.
MIT License
37 stars 20 forks source link

Add low-level helper routines for data exchange #111

Closed gerw closed 1 year ago

gerw commented 1 year ago

This PR tries to remove some duplicated code by introducing low-level helper functions for receiving and sending data.

BTW: I am wondering about the except struct.error as err: In which circumstances can the struct.unpack raise an exception? I think only if it gets not the correct number of bytes. This, in turn, can only happen, if the _socket.recv does not return the correct number of bytes (which is, by documentation, possible). Maybe this should be handled in the new reading routines?

kbabioch commented 1 year ago

BTW: I am wondering about the except struct.error as err: In which circumstances can the struct.unpack raise an exception? I think only if it gets not the correct number of bytes. This, in turn, can only happen, if the _socket.recv does not return the correct number of bytes (which is, by documentation, possible). Maybe this should be handled in the new reading routines?

Are you suggesting to add this in this pull request, or will you prepare this later on? Should we create an issue for this?

kbabioch commented 1 year ago

Deleting more lines that are re-added. I like those refactorings. Makes the code better understandable :-).