I went with the logic on the Shelly approach. The main reason was to mitigate WIFI related problems, so the Shelly is able to control the hot water production even if it has no connection to the MQTT server (i.e. Home Assistant).
To make things reliable I made the following so far:
1. I have two scripts running on the Shelly.
2. The first one is the main controller script.
3. The second is a watchdog script.
4. In the controller script in case of a logic error (for example can not read one of the sensors or temperature is outside of normal range) I switch of the pump's relay and do nothing until everything is okay in the next try (the logic is timer based, so it runs periodically every 60s).
5. The watchdog script handles the script status change events. If the main script stops, the watchdog switches of the pump's relay.
6. The watchdog periodically publishes the status of the main script on MQTT. (The status update over MQTT is enabled in the Shelly settings, but in case of Home Assistant restart without this I won't get the status of the running script as it is published only on change.)
7. Home assistant alerts me if the control script's status changes from running to stopped.
8. Home assistant alerts me if there is not enough hot water.
Any tips on this?
Until now it works fine. I like this scripting possibility on the Shelly, I even didn't know that this is available on the Shellys when I bought the Plus 2PM. I have to polish the scripts further and I will extend it with control of the 2nd relay in the Shelly, which will switch the electric heater in the tank based on water usage and weather forecast published on MQTT by Home Assistant. (The electric heater will be switched by a high power contactor not the small relay in the Shelly, and I have RC snubbers certified for mains use on both loads).