In Home Assistant, when Home Assistant MQTT-Auto-Discovery is active, almost all Sensors of the auto-discovered Victron device in Home Assistant become "unavailable" after a short time - except those Sensors with frequent changes like battery voltage or panel voltage. This patch introduces regular mqtt updates for all VE.Direct sensors when MQTT-Auto-Discovery is enabled. Signed-off-by: Martin Dummer <martin.dummer@gmx.net>
32 lines
659 B
C++
32 lines
659 B
C++
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
#pragma once
|
|
|
|
#include "VeDirectFrameHandler.h"
|
|
#include "Configuration.h"
|
|
#include <Arduino.h>
|
|
|
|
#ifndef VICTRON_PIN_RX
|
|
#define VICTRON_PIN_RX 22
|
|
#endif
|
|
|
|
#ifndef VICTRON_PIN_TX
|
|
#define VICTRON_PIN_TX 21
|
|
#endif
|
|
|
|
class MqttHandleVedirectClass {
|
|
public:
|
|
void init();
|
|
void loop();
|
|
private:
|
|
veStruct _kvFrame{};
|
|
|
|
// point of time in millis() when updated values will be published
|
|
uint32_t _nextPublishUpdatesOnly = 0;
|
|
|
|
// point of time in millis() when all values will be published
|
|
uint32_t _nextPublishFull = 1;
|
|
|
|
bool _PublishFull;
|
|
};
|
|
|
|
extern MqttHandleVedirectClass MqttHandleVedirect; |