Some changes

This commit is contained in:
Gunnar Skjold 2021-12-06 10:47:42 +01:00
parent 2107ca50e4
commit 097131d7fb
2 changed files with 3 additions and 4 deletions

View File

@ -62,7 +62,7 @@ Timezone* tz;
AmsWebServer ws(&Debug, &hw);
MQTTClient *mqtt = NULL;
WiFiClient *mqttClient = NULL;
WiFiClient *mqttClient = new WiFiClient();
WiFiClientSecure *mqttSecureClient = NULL;
AmsMqttHandler* mqttHandler = NULL;
@ -72,7 +72,6 @@ SoftwareSerial *swSerial = NULL;
GpioConfig gpioConfig;
MeterConfig meterConfig;
bool mqttEnabled = false;
uint8_t payloadFormat = 0;
String topic = "ams";
AmsData meterState;
bool ntpEnabled = false;
@ -920,7 +919,6 @@ void MQTT_connect() {
mqttEnabled = true;
ws.setMqttEnabled(true);
payloadFormat = mqttConfig.payloadFormat;
topic = String(mqttConfig.publishTopic);
if(mqttHandler != NULL) {
@ -1002,6 +1000,7 @@ void MQTT_connect() {
if(Debug.isActive(RemoteDebug::INFO)) {
debugI("Connecting to MQTT %s:%d", mqttConfig.host, mqttConfig.port);
}
mqtt->begin(mqttConfig.host, mqttConfig.port, *mqttClient);
#if defined(ESP8266)

View File

@ -113,7 +113,7 @@ bool JsonMqttHandler::publishTemperatures(AmsConfiguration* config, HwTools* hw)
bool JsonMqttHandler::publishPrices(EntsoeApi* eapi) {
if(topic.isEmpty() || !mqtt->connected())
return false;
if(strcmp(eapi->getToken(), "") == 0)
if(strlen(eapi->getToken()) == 0)
return false;
time_t now = time(nullptr);