Addon for libmbus: Best way of exposing shell commands?

This is my first topic here. I hope this is the correct category in which to post it.

I have installed an M-bus HAT (https://www.packom.net/m-bus-master-hat/) in my RPI4 which is running Hassio. I have tested it successfully with libmbus on both Raspberry Pi OS and Hassio (although not as an addon). Now my aim is to write an addon which installs libmbus and exposes its functions or rather shell commands (at least some of them).

I have googled quite a bit and learned a few things about Addons in Hassio and Docker but there are still many things that I still not grasp. I have actually started writing the addon and played a bit with a Dockerfile which clones libmbus and builts it, at least I do not get any errors in the System log when doing those things. I still have not figured out how to debug and test my Docker container but I will look into this more.

My big question is, what is the recommended way of invoking a shell command in my addon from another Docker container (Home assistant or other addon) and get the result (stdout) from it? The command is more specifically: ‘bin/mbus-serial-request-data -b 2400 /dev/ttyAMA0 48’ (the arguments may be different) and I want to invoke it about every second. I suppose I need to specify (yml/yaml file?) what shell commands I want to publish. Where can I find information about that?

As an alternative to invoke the shell commands in the addon I was thinking that the addon could have some more logic and contain settings for e.g. what command to invoke and with what scan interval. If this would be a sensible way of solving it, do I then preferably publish the values as sensors and how do I do that?

I hope my questions are not too unclear or to basic to fit here. :slight_smile:

Thanks,

Mikael

I have actually found an addon, Google Drive Backup, which uses sensors, that I am looking into at the moment. There are maybe plenty of other HA Addons using sensors. Google Drive Backup is quite complex so it would be good with a much simpler Addon to use as a basis.

I will get back with my findings, hopefully soon.

Mikael