Extract Home Assistant discovery logic
This commit is contained in:
27
lib/ha_discovery/HADiscovery.h
Normal file
27
lib/ha_discovery/HADiscovery.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef HA_DISCOVERY_H
|
||||
#define HA_DISCOVERY_H
|
||||
|
||||
#include "Shade.h"
|
||||
#include <ArduinoJson.h>
|
||||
#include <functional>
|
||||
|
||||
class HADiscovery
|
||||
{
|
||||
private:
|
||||
char jsonBuffer[1024];
|
||||
|
||||
const char *topic_prefix;
|
||||
const std::function<void(const char*, const char*)> publish_callback;
|
||||
|
||||
void addDeviceObject(JsonDocument &doc, const Shade &shade);
|
||||
void publishCoverDiscoveryTopic(const Shade &shade);
|
||||
void publishBatteryDiscoveryTopic(const Shade &shade);
|
||||
void publishRefreshButtonDiscoveryTopic(const Shade &shade);
|
||||
|
||||
public:
|
||||
HADiscovery(const char *topic_prefix, std::function<void(const char* topic, const char* message)> publish_callback);
|
||||
|
||||
void publish(const Shade &shade);
|
||||
};
|
||||
|
||||
#endif // HA_DISCOVERY_H
|
||||
Reference in New Issue
Block a user