Hi!
I’m looking for some advice and help from you! I did some reverse engineering on my Leviton/HAI lightning system that I installed back in 2011. I’m only using relays, dimmers and switches on my system and I used a BUS USB programming interface to initially setup my system. Lately I’ve been getting more and more annoyed that I can’t integrate and automate any of the lights in my automations.
I did some reverse engineering on the USB traffic and was able to create this small Python scripts to control my lights using raspberry pi. I was succesfully able to turn my relays on and off by changing the hex dump on my write command. I just have no idea how to move forward from here to make this a functional custom component inside HA. Any advice how I’d be able to turn this small script into a HA integration? I do not have programming background, and this is the first script I’ve ever created ![:slight_smile: :slight_smile:](https://community.home-assistant.io/images/emoji/twitter/slight_smile.png?v=10)
import usb.core
# USB device Vendor & Product ID
VID = 0x04d8
PID = 0xfe93
# Constants
DEVICE1_ON = [0x02, 0x12, 0x01, 0x7e, 0x25, 0x0d, 0xbc, 0x00, 0x26, 0x03, 0x0e, 0x62, 0x05, 0x00, 0x03, 0x00, 0x00, 0x00, 0x09, 0x7f, 0x8f]
DEVICE1_OFF = [0x02, 0x12, 0x01, 0x7e, 0x25, 0x0d, 0xbc, 0x00, 0x26, 0x03, 0x0e, 0x62, 0x05, 0x01, 0x03, 0x00, 0x00, 0x00, 0xc4, 0x7f, 0x8f]
DEVICE2_ON = [0x02, 0x12, 0x01, 0x7e, 0x25, 0x0d, 0xbc, 0x00, 0x26, 0x03, 0x0e, 0x40, 0x05, 0x00, 0x03, 0x00, 0x00, 0x00, 0x9c, 0x7f, 0x8f]
DEVICE2_OFF = [0x02, 0x12, 0x01, 0x7e, 0x25, 0x0d, 0xbc, 0x00, 0x26, 0x03, 0x0e, 0x40, 0x05, 0x01, 0x03, 0x00, 0x00, 0x00, 0x51, 0x7f, 0x8f]
# Find the device
dev = usb.core.find(idVendor=VID, idProduct=PID)
# Was it found?
if dev is None:
raise ValueError('Device not found')
# Write data to the device
dev.write(1, DEVICE1_ON)