diff --git a/gateway/include/devices.h b/gateway/include/devices.h index 27f0983..be73e32 100644 --- a/gateway/include/devices.h +++ b/gateway/include/devices.h @@ -15,6 +15,7 @@ struct PollinSwitch : Switch { PollinSwitch(const char* name, const char* group, const unsigned char channel) : Switch(name, Protocol_1::buildId(group, channel)), group(group), channel(channel) { asDevice((new DeviceConfig{id, name})->withManufacturer("Pollin")->withParent(gatewayConfig)); + addToMap(); } void onCommand(const char* msg) override { @@ -37,6 +38,7 @@ struct EasyHomeSwitch : Switch { memcpy(&this->on[4], on, 4 * sizeof(unsigned long)); memcpy(&this->off[4], off, 4 * sizeof(unsigned long)); asDevice((new DeviceConfig{id, name})->withManufacturer("Intertek")->withModel("Easy Home")->withParent(gatewayConfig)); + addToMap(); } void onCommand(const char* msg) override { diff --git a/gateway/include/ha.h b/gateway/include/ha.h index 864119d..ed42855 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