diff --git a/gateway/include/devices.h b/gateway/include/devices.h index 924331b..f4977b8 100644 --- a/gateway/include/devices.h +++ b/gateway/include/devices.h @@ -82,10 +82,19 @@ struct EasyHomeSwitch : Switch { unsigned long on[8] = { 4326554, 4537114, 4767530, 4972714 }; unsigned long off[8] = { 4483146, 4626810, 4661562, 4819642 }; - EasyHomeSwitch(const char* name, const char* id, unsigned long on[4], unsigned long off[4], const char* area = nullptr) - : Switch(nullptr, id) { + EasyHomeSwitch(const char remotePosition, unsigned long on[4], unsigned long off[4], const char* name = nullptr, const char* area = nullptr) + : Switch(nullptr, [remotePosition] { + auto uId = new string("easy_home_"); + (*uId) += tolower(remotePosition); + return uId->c_str(); + }()) { memcpy(&this->on[4], on, 4 * sizeof(unsigned long)); memcpy(&this->off[4], off, 4 * sizeof(unsigned long)); + if (!name) { + auto n = new string("Easy Home "); + (*n) += remotePosition; + name = n->c_str(); + } mainDevice = &DeviceConfig::create(id).withName(name).withManufacturer("Intertek").withModel("Easy Home").withArea(area).withParent(gatewayDevice); withStateTopic(); deviceClass = "outlet"; @@ -121,8 +130,8 @@ Command* commands[] = { .withParent(gatewayDevice) ) .build(), - new EasyHomeSwitch{"FritzBox", "easy_home_a", (unsigned long[4]) { 4483136, 4626800, 4661552, 4819632 }, (unsigned long[4]) { 4326544, 4537104, 4767520, 4972704 }, "Basement"}, - new EasyHomeSwitch{"Easy Home B", "easy_home_b", (unsigned long[4]) { 4483140, 4626804, 4661556, 4819636 }, (unsigned long[4]) { 4326548, 4537108, 4767524, 4972708 }}, + new EasyHomeSwitch{'A', (unsigned long[4]) { 4483136, 4626800, 4661552, 4819632 }, (unsigned long[4]) { 4326544, 4537104, 4767520, 4972704 }, "FritzBox", "Basement"}, + new EasyHomeSwitch{'B', (unsigned long[4]) { 4483140, 4626804, 4661556, 4819636 }, (unsigned long[4]) { 4326548, 4537108, 4767524, 4972708 }}, new PollinSwitch{"00001", 1, "Meeting sensor", "Dining room"}, new PollinSwitch{"00001", 2, "Fire Tv", "Living room"}, new PollinSwitch{"00001", 3, "Diningroom player", "Dining room"},