Custom component 8x Relay 8x Input Temperature over pyserial

I have a device I’ve made in my years at University you can see here

I’m new to home assistant, or any established IOT standard (MQTT etc). I’ve wanted use the device on home assistant. The device is seen in linux as /dev/ttyUSBx and i can talk to it over simple binnary protocol - 5 bytes (preamble, some stuff and crc8) to turn a relay on or off. I have a python script I’ve wrote to do it.

The device has 8 relays and 8 inputs for simple buttons, additional I can connect few ds18b20 temperature sensors.

The program has to listen on serial for packet with input state change or for temperature. It can request a relay state, turn on, turn off or toggle a relay. It can also request a temperature sensor serial number.

I’ve read trough docs, but not sure were to start. I have to have a thread on witch I’m gonna listen on serial, and rise some events when inputs state is changes or temperature is received. Not sure how to approach temperature sensor serial number read.

Maybe anybody know a component I can base my code on (multiply relay, multiply inputs, pyserial used)?

Or maybe better approach is to write a MQTT client?

The dirty code to use the device in python is below at link:

1 Like