#ifndef MQTT_H
#define MQTT_H

#include "wifi.hpp"
#include "config.hpp"
#include <WiFi.h>
#include <PubSubClient.h>


class Mqtt {
    public:
        Mqtt(WiFiClient& wifiClient);
        void mqttSetup();
        void mqttRun();
        void mqttPublish(const char* topic, const char* payload);
        void publishTemperature(float temp);
        void publishRSSI(int rssi);
        void publishSensorData(float temp, int rssi, int battery);
        void publishDiscoveryConfig();
    private:
        void mqttReconnect();
        void setupHomeAssistantDiscovery();
        static void callback(char *topic, uint8_t *payload, unsigned int length);
        PubSubClient mqttClient;
        String deviceId;
        String baseTopic;
};

#endif /* MQTT_H */