diff --git a/src/ha.h b/src/ha.h index 1580459..4732bee 100644 --- a/src/ha.h +++ b/src/ha.h @@ -137,10 +137,12 @@ namespace Ha { struct Command : Config { bool retain = false; inline static unordered_map mapCommandTopics; + inline static unordered_map 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) {