diff --git a/include/devices.h b/include/devices.h index f40130e..7ed34dc 100644 --- a/include/devices.h +++ b/include/devices.h @@ -71,8 +71,8 @@ Command* commands[] = { ) .build(), #endif - new EasyHomeSwitch{'A', (uint32_t[4]) { 4483136, 4626800, 4661552, 4819632 }, (uint32_t[4]) { 4326544, 4537104, 4767520, 4972704 }, "KabelBox", "Basement"}, - new EasyHomeSwitch{'B', (uint32_t[4]) { 4483140, 4626804, 4661556, 4819636 }, (uint32_t[4]) { 4326548, 4537108, 4767524, 4972708 }}, + new EasyHomeSwitch{'A', array{ 4483136, 4626800, 4661552, 4819632 }, array{ 4326544, 4537104, 4767520, 4972704 }, "KabelBox", "Basement"}, + new EasyHomeSwitch{'B', array{ 4483140, 4626804, 4661556, 4819636 }, array{ 4326548, 4537108, 4767524, 4972708 }}, new PollinSwitch{"00001", 1}, new PollinSwitch{"00001", 2, "Fire Tv", "Living room"}, new PollinSwitch{"00001", 3, "Diningroom player", "Dining room"}, diff --git a/include/rc_devices.h b/include/rc_devices.h index 2d274f2..2973e73 100644 --- a/include/rc_devices.h +++ b/include/rc_devices.h @@ -41,17 +41,17 @@ struct PollinSwitch : Switch { }; struct EasyHomeSwitch : Switch { - uint32_t on[8] = { 4326554, 4537114, 4767530, 4972714, 0, 0, 0, 0 }; - uint32_t off[8] = { 4483146, 4626810, 4661562, 4819642, 0, 0, 0, 0 }; + constexpr static const array onAll = { 4326554, 4537114, 4767530, 4972714 }; + constexpr static const array offAll = { 4483146, 4626810, 4661562, 4819642 }; + array onButton; + array offButton; - EasyHomeSwitch(const char remotePosition, uint32_t on[4], uint32_t off[4], const char* name = nullptr, const char* area = nullptr) + EasyHomeSwitch(const char remotePosition, array on, array off, 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(uint32_t)); // cppcheck-suppress [overlappingWriteFunction] - memcpy(&this->off[4], off, 4 * sizeof(uint32_t)); // cppcheck-suppress [overlappingWriteFunction] + }()), onButton(on), offButton(off) { if (!name) { auto n = new string("Easy Home "); (*n) += remotePosition; @@ -60,15 +60,17 @@ struct EasyHomeSwitch : Switch { mainDevice = &DeviceConfig::create(id).withName(name).withManufacturer("Intertek").withModel("Easy Home").withArea(area).withParent(gatewayDevice); withStateTopic(); deviceClass = "outlet"; - for (int i = 0; i < 8; i++) { - onSwitches.insert({ this->on[i], this }); - offSwitches.insert({ this->off[i], this }); + for (int i = 0; i < 4; i++) { + onSwitches.insert({ onAll[i], this }); + onSwitches.insert({ onButton[i], this }); + offSwitches.insert({ offAll[i], this }); + offSwitches.insert({ offButton[i], this }); } } void onCommand(const char* msg) override { mySwitch.setProtocol(4); - strcmp("ON", msg) == 0 ? mySwitch.send(on[4], 24) : mySwitch.send(off[4], 24); + strcmp("ON", msg) == 0 ? mySwitch.send(onButton[0], 24) : mySwitch.send(offButton[0], 24); publisher(State::topic, msg); } };