Integrate PI IO's into HA

Hello,

i have an PI3 with 32 IO Shiftregister Boards (74595/74165) and the values are strored in
SHIFT_IN[0] to SHIFT_IN[31] / SHIFT_OUT[0] to SHIFT_OUT[31].

My goal is to implement those Inputs/Outputs in Home Assistant(HA is not running on that PI!)
What do i have to do so HA accept the PI as a device?
I use Python3 on the PI…
Is a Website on the PI neccesari?

Wolfram.

Write a Python program that reads the i/o and publishes their state via mqtt. Discovery is supported. See:

And

And

thank you,
do you have an example for a python-code with MQTT?
I have never used MQTT and need some help.

Nope. Sorry. Try Google.

I settet Mosquito MQTT up so i have a local MQTT Server. Works fine.
Now i could add some example to my PI and it sends a random Number “Lottery” to HA.
It is displayed fine in an orange circle.

broker = '192.168.2.223'
state_topic = 'homesys/lottery/number'
delay = 1
client = mqtt.Client()
client.connect(broker, 1883, 60)
client.loop_start()

       client.publish(state_topic, random.randrange(0, 50, 1))

in HA the config is:

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
sensor:
  - platform: mqtt
    name: "Lottery"
    state_topic: "homesys/lottery/number"
    unit_of_measurement: "No."

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

mqtt:
  discovery: true
  discovery_prefix: homesys
  broker: 192.168.2.223

To stay firstly at that Lottery Example:
How can i send 7 Numbers for the real Lottery Numbers and how can those be displayed in a row instead in that orange circle-icon?