Hello,
I have a Siemens PAC3200 Monitoring Equipment. I’m trying to integrate the data to HA with modbus, but can’t get it to work, I’m no expert on python or Modbus.
The Python script I have (reads data correctly) is
import struct
from pymodbus.client import ModbusTcpClient
# --------------------------------------------------------------------------- #
# configure the client logging debug:
# --------------------------------------------------------------------------- #
import logging
logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.DEBUG)
ip = '127.0.0.1'
client = ModbusTcpClient(ip, port=502, timeout=3)
client.connect()
log.debug("Reading Registers") #debug mode on
parametros = ['Tensión UL1-N']
unidades = ['V']
for i in range(len(parametros)):
result = client.read_holding_registers(i*2+1, 2, slave = 1)
value = struct.pack('>I',(result.registers[0]<<16)|result.registers[1]) #4 bytes concatenacion de 2 bytes entero + 2 bytes enteros
valor_float = struct.unpack('!f', value)[0] #lo paso a float
print(parametros[i] + " --> " + str(round(valor_float,2)) + " " +unidades[i])
client.close()
I could get some data with HA, but can’t or don’t know how to format them to output the correct data.
Thanks in advanced