Configure shades via MQTT messages

This commit is contained in:
2024-05-04 23:08:21 +10:00
parent 0458c70b47
commit e8003772ef
4 changed files with 261 additions and 16 deletions

View File

@@ -0,0 +1,30 @@
#ifndef CONFIGURATOR_H
#define CONFIGURATOR_H
#include <vector>
#include <map>
#include <functional>
#include "Shade.h"
// TODO: Allow shades to be removed
class Configurator
{
private:
std::vector<std::function<void (Shade)>> shadeConfiguredCallbacks;
std::map<std::string, uint16_t> discoveredIds;
std::map<std::string, std::string> discoveredFriendlyNames;
std::string extractKey(std::string topic);
bool tryBuild(std::string topic);
public:
Configurator();
void addShadeConfiguredCallback(std::function<void (Shade)> callback);
void processIdMessage(std::string topic, std::string id);
void processFriendlyNameMessage(std::string topic, std::string friendlyName);
};
#endif // CONFIGURATOR_H