add map for command->id to offer support for web server

This commit is contained in:
Nicu Hodos 2025-09-06 17:14:15 +02:00
parent a717ca9611
commit c82cb3670c

View File

@ -137,10 +137,12 @@ namespace Ha {
struct Command : Config {
bool retain = false;
inline static unordered_map<string, Command*> mapCommandTopics;
inline static unordered_map<string, Command*> mapCommandIds;
Command(Component* cmp, onMessage f) : f(f), cmp(cmp) {
snprintf(commandTopic, sizeof(commandTopic), BASE_TOPIC"/set", cmp->type, MAIN_DEVICE_ID, cmp->id);
mapCommandTopics.insert({ string(commandTopic), this });
mapCommandIds.insert({ string(cmp->id), this });
}
virtual void onCommand(const char* msg) {