add map for command->id to offer support for web server
This commit is contained in:
parent
a717ca9611
commit
c82cb3670c
2
src/ha.h
2
src/ha.h
@ -137,10 +137,12 @@ namespace Ha {
|
|||||||
struct Command : Config {
|
struct Command : Config {
|
||||||
bool retain = false;
|
bool retain = false;
|
||||||
inline static unordered_map<string, Command*> mapCommandTopics;
|
inline static unordered_map<string, Command*> mapCommandTopics;
|
||||||
|
inline static unordered_map<string, Command*> mapCommandIds;
|
||||||
|
|
||||||
Command(Component* cmp, onMessage f) : f(f), cmp(cmp) {
|
Command(Component* cmp, onMessage f) : f(f), cmp(cmp) {
|
||||||
snprintf(commandTopic, sizeof(commandTopic), BASE_TOPIC"/set", cmp->type, MAIN_DEVICE_ID, cmp->id);
|
snprintf(commandTopic, sizeof(commandTopic), BASE_TOPIC"/set", cmp->type, MAIN_DEVICE_ID, cmp->id);
|
||||||
mapCommandTopics.insert({ string(commandTopic), this });
|
mapCommandTopics.insert({ string(commandTopic), this });
|
||||||
|
mapCommandIds.insert({ string(cmp->id), this });
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void onCommand(const char* msg) {
|
virtual void onCommand(const char* msg) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user