add write_coil for pump control
This commit is contained in:
parent
94252cfc28
commit
a01a674b1e
@ -30,3 +30,13 @@ def poll_site(site_cfg):
|
|||||||
tag = plc.get("tags", {}).get(str(i), f"{plc['host']}:r{i}")
|
tag = plc.get("tags", {}).get(str(i), f"{plc['host']}:r{i}")
|
||||||
results[tag] = val
|
results[tag] = val
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
def write_coil(host, port=502, unit=1, address=0, value=True):
|
||||||
|
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