Mosquitto on Home Assistant

I am using Mosquitto in HA with a sonoff 4ch and TH16 to control the pump timer on my pool as well as control the heat using the TH16 as a thermostat. The issue i am having is as follows:
My current temperature is stored on the 4CH ass var1
I have a second variable (var2) which stores the timer state. This is necessary because if the heater comes on outside of the timer period, it has to turn the pump on, and then off once the temperature is satisfied.
I store the temperature setting as mem1. The reason is if the 4CH reboots i lose my temperature setting if it is stored as a variable.
All of these are setting in the tasmotized 4CH. I use an automation to set the temperature and set the timers from HA. All if this is working well.
My issue is this: occasionally the tasmota will reboot for whatever reason. Power hiccup, etc. When it reboots both the current temp variable (var1) and the pump timer status (var2) go to empty values. Eventually the current temp (var1) is updated because the pool temperature changes and the TH16 sends the updated temperature. The pump timer status (var2) doesnt update until the next timer event (on or off).
What i would like to do is set an automation where if the 4CH reboots, it will notify HA (mosquito) and HA will call on mosquito to resend the var1 and var2 values to the 4CH.
I am aware that i can use a rule on the 4CH such as ON system#boot DO cmnd (or stat)/tasmota4Ch/reboot and i can use that to trigger the automation in HA but im not sure what the action on HA should be.

Hi JoelG,

If I understand you right, what you need is to use retained messages.
These will be sent to a subscriber on first connect/reconnect. Basically, the last send message in a topic is the retained message. This allows for instant feedback for new subscriber.

I hope this helps :slight_smile:



They, thanks for help.

I understand the concept of retained messages. But what i not sure of (or what im asking) is lets say i have a message cmnd/tasmota/var1 88 and my client is connected and receives the message and therefor sets the value of var1 to 88. If the client were to reboot for whatever reason, when it starts up and reconnects to the broker, will that message (cmnd/tasmota/var1 88) a second time or is it only sent once?

Hi Joel,

Yes the retained message will always be received after the connect.