add write_coil for pump control commands
This commit is contained in:
parent
0fe31a31a5
commit
1eb1675ec3
@ -31,3 +31,14 @@ def poll_site(site_cfg):
|
||||
tag = plc.get("tags", {}).get(str(i), f"{plc['host']}:r{i}")
|
||||
results[tag] = val
|
||||
return results
|
||||
|
||||
|
||||
def write_coil(host, port=502, unit=1, address=0, value=True):
|
||||
"""Write single coil — used for pump enable/disable commands."""
|
||||
c = ModbusTcpClient(host, port=port)
|
||||
c.connect()
|
||||
try:
|
||||
rr = c.write_coil(address, value, unit)
|
||||
return not rr.isError()
|
||||
finally:
|
||||
c.close()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user