xxxxxxxxxx
from pymodbus.client import ModbusTcpClient
client = ModbusTcpClient('192.168.X.X', port=502) 'If you change the port,'
'change it here too'
print("Tried connecting")
connection = client.connect()
print(connection)
if connection:
client.write_register(2000, False, slave=1)
#Turn off device at 2000 address
else:
print("Modbus Device hasn't been connected")