Custom MQTT-device with command-topic and state-topic(s)

Hi,

I have been using fhem for about 6 years now, having tons of things integrated there.
Recently I have been playing around with HA, but I am still a little bit lost here.
So, I installed several arduino type devices with relays. Those are communicating with fhem using mqtt.
My question now is: How can such a device be implemented in HA? Example:
command_topic: mega1/set/switch_41
state_topic: mega1/state/rel_41
As soon as the relay is switchet, the devices publishes on the state_topic.
Where (configuration.yaml) should this be set up and how?
Best regards and thanks in advance,
Otto

Thanks a lot! Helped :slight_smile: