question

Jan Novak avatar image
Jan Novak asked

Python can't read register 0x1F214

Hallo,

das VRM Portal hängt ja der aktuellen Situation einige bis mehrere Minuten hinterher. Abgesehen davon, dass mir das gar nicht gefällt, dass meine Daten dorthin fliessen. Aber das ist ein anderes Thema.

Gibt es auch eine json Api nach dem Vorbild der VRM API, wo ich meinen Multiplus II direkt aus dem Lan abfragen kann?


bfo

Modbus TCPMQTTapipython
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

4 Answers
klandos avatar image
klandos answered ·

Mqtt und modbustcp gibts über GX Device.

Je nach Präferenz gibts da alles an Daten lokal.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Stefanie (Victron Energy Staff) avatar image
Stefanie (Victron Energy Staff) answered ·
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Jan Novak avatar image
Jan Novak answered ·

Hallo,

danke für die schnelle Antwort.

Ich hoffe, jemand kann mir etwas zu dem Fehler sagen, welcher beim Abruf des Modbus auf der Multiplus kommt. Laut Liste ist z.B. das Register 0x1F214 die Batteriespannung.

Ich bekomme aber den Fehler, das python dieses Register nicht abrufen kann. Die Verbindung klappt aber.


#!/usr/bin/python 
import sys
import os
import time
import getopt
import struct
import json
from pymodbus.client.sync import ModbusTcpClient 
ipadd = '192.168.1.79'
client = ModbusTcpClient(ipadd, port=502) 
sdmid = 1 
outdir='/arc/1'
devout=True
values={}

val = client.connect()
if not val:
    print("******** Connection error *************")
    quit()

def gr(key, value, div):
    resp = client.read_input_registers(int(value,16),2, unit=sdmid)
    all = format(resp.registers[1], '04x') + format(resp.registers[0], '04x')
    out = float(struct.unpack('>i', all.decode('hex'))[0])
    out = float("%.1f" % out) / 10
    values.update({key:out})
    if devout :
        print (key+": " + str(out/div))

arr = [\
    ("Batteriespannung","0x1F214",1)
    ]
for key,value, div in arr: 
    gr(key, value, div)


js=json.dumps(values)
print(js)
2 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Ich kann da leider nicht helfen, verschiebe das aber mal in den Modificationsbereich und passe den Titel entsprechend nochmal an, um mehr Aufmerksamkeit zu erreichen.

0 Likes 0 ·
Jan Novak avatar image Jan Novak Stefanie (Victron Energy Staff) ♦♦ commented ·

Es gibt bereits einen Ansatz:

https://community.victronenergy.com/questions/121846/my-attempt-at-playing-with-python-modbus-mqtt.html
Leider hat das Script von "elvis" noch kleine Fehler. Ich habe ihn kontaktiert, aber er hat sich noch nicht gemeldet.

0 Likes 0 ·
lifeingalicia avatar image
lifeingalicia answered ·

bin kein phyton specialist aber unit id ?

  1. sdmid = 1


2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Related Resources

Additional resources still need to be added for this topic

Modbus TCP Basics

Victron MQTT readme