Remove initialisation warning from the boiler

This commit is contained in:
Pierre committed 2026-10-14 19:05:40 +02:00
1 parent 9a58cc5296
commit d79bba15b0
2 files changed
+30 -5

No files matched your search

+11 -3
View File
@@ -17,7 +17,9 @@ class BoilerWatchdog(hass.Hass, LoggerInterface):
if self.AD.plugins.get_plugin_object(self.mqtt_namespace) is None:
raise RuntimeError('MQTT plugin missing; configure it and restart AppDaemon')
self.last_heartbeat = None
self.waiting_since = time.monotonic()
self.fault = False
self.warned = False
self.listen_event(self._mqtt_event, 'MQTT_MESSAGE', namespace=self.mqtt_namespace)
self.run_every(self._check, 'now', 10)
self._check()
@@ -25,18 +27,24 @@ class BoilerWatchdog(hass.Hass, LoggerInterface):
def _mqtt_event(self, event, data, kwargs):
if data.get('topic') == self.base + '/heartbeat':
self.last_heartbeat = time.monotonic()
if self.fault:
if self.warned:
self.log_info('Boiler climate heartbeat recovered')
self.fault = False
self.warned = False
elif data.get('topic') is None and data.get('state') == 'Connected':
self.last_heartbeat = None
self.waiting_since = time.monotonic()
self.fault = False
self.warned = False
self._check()
def _check(self, kwargs=None):
if self.last_heartbeat is None or time.monotonic() - self.last_heartbeat >= self.timeout:
age = time.monotonic() - (self.waiting_since if self.last_heartbeat is None else self.last_heartbeat)
if self.last_heartbeat is None or age >= self.timeout:
if not self.fault:
self.call_service('mqtt/publish', namespace=self.mqtt_namespace,
topic=self.base + '/availability', payload='offline', qos=0, retain=True)
self.log_warning('Boiler climate unavailable: waiting for a fresh heartbeat')
self.fault = True
if age >= self.timeout and not self.warned:
self.log_warning('Boiler climate unavailable: no heartbeat within the timeout')
self.warned = True