fix: Fix OPC UA client async security policy setting and handle missing Modbus registers
- OPC UA client: Await set_security_string method call - Modbus client: Handle case where performance metrics registers might not exist
This commit is contained in:
parent
ac89d72aa9
commit
2bad8c9ea0
|
|
@ -28,7 +28,7 @@ class OPCUAClient:
|
|||
# Explicitly set security policy to match server configuration
|
||||
# The server supports both Basic256Sha256 and None security policies
|
||||
# Use None for development/testing
|
||||
self._client.set_security_string("http://opcfoundation.org/UA/SecurityPolicy#None")
|
||||
await self._client.set_security_string("http://opcfoundation.org/UA/SecurityPolicy#None")
|
||||
|
||||
# Set timeout for connection
|
||||
await asyncio.wait_for(self._client.connect(), timeout=5.0)
|
||||
|
|
@ -201,8 +201,13 @@ class ModbusClient:
|
|||
# Read safety status - base address 200
|
||||
safety_status = self.read_input_register(200 + pump_offset, 1)
|
||||
|
||||
# Read performance metrics - base address 400
|
||||
# Read performance metrics - base address 400 (if available)
|
||||
efficiency = None
|
||||
try:
|
||||
efficiency = self.read_input_register(400 + pump_offset, 1)
|
||||
except Exception:
|
||||
# Performance metrics might not be available
|
||||
pass
|
||||
|
||||
return {
|
||||
"setpoint": setpoint[0] if setpoint else None,
|
||||
|
|
|
|||
Loading…
Reference in New Issue