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

Bugfix bei Headerlänge / Neu: FunctionCall für Energiebilanz #4

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

StefanLSA
Copy link

Hallo,

ich jabe mir mal erlaubt dein Projekt zu modifizieren. Ein Problem bei der Berechnung der Länge der Anfrage habe ich gefunden. Desweiteren habe ich die FunctionCalls basierend auf dieser Diskussion hier openv/openv#480 (comment) zum Auslesen der Energiebilanz eingebaut. Die Methode kann mit dynamischen Antwortlängen aus dem Call umgehen. Außerdem habe ich die Scanner erweitert, um den FunctionCall zu Scannen. Scheinbar ist dort auch das Betriebstagebuch zu finden, das muss ich aber noch verifizieren.

@StefanLSA
Copy link
Author

Noch eine Anmerkung: die testViessman.py musste ich in das root-verzeichnis verschieben, weil VSCode sonst nicht damit klar kommt

@joppi588
Copy link
Owner

Danke für die Erweiterungen! Ich bin dran, brauch aber noch ein paar Tage.

Copy link
Owner

@joppi588 joppi588 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Stefan, ich habe die Commits mal durchgearbeitet und einige Vorschläge gemacht.

Grüße

Jochen

@@ -9,6 +9,9 @@ Replacement for vcontrold when using a python environment.
Python package zur Kommunikation mit Viessmann-Heizungen über die Optolink serielle Schnittstelle.
Geeignet um vcontrold zu ersetzen wenn ohnehin mit Python gearbeitet wird.

Neu:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vorschlag: Änderungshistorie nur in den Commit-Messages pflegen, mögliche Erweiterungen als github issues.

# the commands
# viCommand object value is a bytearray of addr and len

# TODO: statt 'write':False besser mode:rw/w verwenden -- verbessert: es gibt read, write oder func, wenn nichts vorhanden ist
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vorschlag: 'Hysterese_Vorlauf_aus': {'addr': '7313', 'len': 2, 'unit': 'IU10', 'accessmode': 'write'},
'Energiebilanz': {'addr': 'B800', 'len': 16, 'unit': 'F_E', 'accessmode': 'function'}

@@ -114,11 +134,16 @@ def __init__(self, cmdname):
self.__cmdcode__ = cs['addr']
self.__valuebytes__ = cs['len']
self.unit = cs['unit']
self.write = cs['write']
self.write = cs.get('write', False)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.accessmode = cs.get('accessmode')

self.cmdname = cmdname

# create bytearray representation
b = bytes.fromhex(self.__cmdcode__) + self.__valuebytes__.to_bytes(1, 'big')
b = bytes.fromhex(self.__cmdcode__)
if not self.function:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if self.accessmode != "function"

def execReadCmd(self, cmdname) -> viData:
# sends a read command and gets the response.
vc = viCommand(cmdname) # create command

if vc.function:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if vc.accessmode == 'function':

header = self.vs.read(2) #read the header ... the read the length received in the header
logging.debug(f'Requested 2 (0x41 + length) bytes. Received telegram {header.hex()}')

l = viTelegram.checkStartByteAnGetLength(header)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vorschlag: viTelegramLength=viTelegram.length()

logging.debug(f'Requested 2 (0x41 + length) bytes. Received telegram {header.hex()}')

l = viTelegram.checkStartByteAnGetLength(header)
body = self.vs.read(l+1) #read the response (length + checksum)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l und 1 sehen nahezu gleich aus.

@@ -17,7 +17,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##

from email import header
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wo wird header verwendet?


return res

@property
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diese Funktion gehört m.E. thematisch zu viTools, nicht zu viData, da sie nur in dem speziellen Kontext verwendet wird.
viTools verweist auf viData, viData wiederum auf viTools (quasi zirkuläre Abhängigkeit)

body = unpack(f'<{len(self[4:])//2}h', self[4:])
bodyDiv10 = [x*0.1 for x in body]

return f"{self.hex(' ')} -- {header} - {body} / {bodyDiv10}"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vorschlag: Selbsterklärender Ausgabetext

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants