diff --git a/gateway/include/ha.h b/gateway/include/ha.h index 864119d..e0f1b42 100644 --- a/gateway/include/ha.h +++ b/gateway/include/ha.h @@ -56,14 +56,14 @@ namespace Ha { }; struct Component { + char* id = nullptr; const char* name; - char* id; const char* type; char configTopic[TOPIC_SIZE]; - DeviceConfig* mainDevice; + DeviceConfig* mainDevice = nullptr; static List components; - Component(const char* name, const char* id, const char* type) : name(name), id((char*)id), type(type) { + Component(const char* name, const char* id, const char* type) : id((char*)id), name(name), type(type) { sprintf(configTopic, "homeassistant/%s/%s/%s/config", type, MAIN_DEVICE_ID, id); components.add(this); } @@ -103,6 +103,7 @@ namespace Ha { char commandTopic[TOPIC_SIZE]; Command(const char* name, const char* id, const char* type) : EntityConfig(name, id, type) { + sprintf(commandTopic, "homeassistant/%s/%s/%s", type, MAIN_DEVICE_ID, id); } void buildUniqueId(char* uniqueId) override { @@ -118,10 +119,9 @@ namespace Ha { typedef void (*onMessage)(const char* msg); struct Button : Command