Skip to content

Using with Python

Download

Python SDK

Home I/O can be used together with Python. The Python SDK - download link at the top of this page - allows you to write Python programs to interact with Home I/O devices. This means that you can read and write to devices' I/O points from Python programs. Note that, to access I/O points from Python, the devices must be set to External Mode first.

Home I/O / Python integration was developed on top of Home I/O SDK and pythonnet.

Setting Up

  • Install Python from python.org
  • Install pythonnet by running: pip install pythonnet
  • In your program, add a reference to EngineIO (included in the SDK) - see the example below. Keep in mind that the devices you want to use in your program must be set to External Mode.
import time
import clr

clr.AddReference('EngineIO')

from EngineIO import *

print("Home I/O & Python are such good friends thanks to pythonnet!")

livingRoomLight = MemoryMap.Instance.GetBit(0, MemoryType.Output)

for i in range(5):
    livingRoomLight.Value = not livingRoomLight.Value

    # When using a memory value before calling the Update method we are using a cached value.
    print("Light is on? " + str(livingRoomLight.Value))

    # Calling the Update method will write the livingRoomLight.Value to the memory map.
    MemoryMap.Instance.Update()

    time.sleep(1)

# When we no longer need the MemoryMap we should call the Dispose method to release all the allocated resources.
MemoryMap.Instance.Dispose()

print("Bye!")