Merge branch 'switches-default-name'
This commit is contained in:
commit
a25746cfc9
@ -55,18 +55,17 @@ namespace OilTank {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct PollinSwitch : Switch {
|
struct PollinSwitch : Switch {
|
||||||
|
constexpr static const char* man = "Pollin";
|
||||||
const char* group;
|
const char* group;
|
||||||
unsigned char channel;
|
unsigned char channel;
|
||||||
|
|
||||||
PollinSwitch(const char* name, const char* group, const unsigned char channel, const char* area = nullptr)
|
PollinSwitch(const char* group, const unsigned char channel, const char* name = nullptr, const char* area = nullptr)
|
||||||
: Switch(nullptr, [group, channel]{
|
: Switch(nullptr, [group, channel]{
|
||||||
// copy id from string into a new pointer, to avoid memory leaks
|
// copy id from string into a new pointer, to avoid memory leaks
|
||||||
string s = Protocol_1::buildId(group, channel);
|
return (new string{Protocol_1::buildId(group, channel)})->c_str();
|
||||||
char* uId = new char[s.length() + 1];
|
|
||||||
strcpy(uId, s.c_str());
|
|
||||||
return uId;
|
|
||||||
}()), group(group), channel(channel) {
|
}()), group(group), channel(channel) {
|
||||||
mainDevice = &DeviceConfig::create(id).withName(name).withManufacturer("Pollin").withArea(area).withParent(gatewayDevice);
|
if (!name) name = (new string{string(man).append(" ").append(id)})->c_str();
|
||||||
|
mainDevice = &DeviceConfig::create(id).withName(name).withManufacturer(man).withArea(area).withParent(gatewayDevice);
|
||||||
withStateTopic();
|
withStateTopic();
|
||||||
deviceClass = "outlet";
|
deviceClass = "outlet";
|
||||||
p1Switches.insert({ string(id), this });
|
p1Switches.insert({ string(id), this });
|
||||||
@ -83,10 +82,19 @@ struct EasyHomeSwitch : Switch {
|
|||||||
unsigned long on[8] = { 4326554, 4537114, 4767530, 4972714 };
|
unsigned long on[8] = { 4326554, 4537114, 4767530, 4972714 };
|
||||||
unsigned long off[8] = { 4483146, 4626810, 4661562, 4819642 };
|
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)
|
EasyHomeSwitch(const char remotePosition, unsigned long on[4], unsigned long off[4], const char* name = nullptr, const char* area = nullptr)
|
||||||
: Switch(nullptr, id) {
|
: 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->on[4], on, 4 * sizeof(unsigned long));
|
||||||
memcpy(&this->off[4], off, 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);
|
mainDevice = &DeviceConfig::create(id).withName(name).withManufacturer("Intertek").withModel("Easy Home").withArea(area).withParent(gatewayDevice);
|
||||||
withStateTopic();
|
withStateTopic();
|
||||||
deviceClass = "outlet";
|
deviceClass = "outlet";
|
||||||
@ -122,13 +130,13 @@ Command* commands[] = {
|
|||||||
.withParent(gatewayDevice)
|
.withParent(gatewayDevice)
|
||||||
)
|
)
|
||||||
.build(),
|
.build(),
|
||||||
new EasyHomeSwitch{"FritzBox", "easy_home_a", (unsigned long[4]) { 4483136, 4626800, 4661552, 4819632 }, (unsigned long[4]) { 4326544, 4537104, 4767520, 4972704 }, "Basement"},
|
new EasyHomeSwitch{'A', (unsigned long[4]) { 4483136, 4626800, 4661552, 4819632 }, (unsigned long[4]) { 4326544, 4537104, 4767520, 4972704 }, "FritzBox", "Basement"},
|
||||||
new EasyHomeSwitch{"Outside", "easy_home_b", (unsigned long[4]) { 4483140, 4626804, 4661556, 4819636 }, (unsigned long[4]) { 4326548, 4537108, 4767524, 4972708 }, "Basement"},
|
new EasyHomeSwitch{'B', (unsigned long[4]) { 4483140, 4626804, 4661556, 4819636 }, (unsigned long[4]) { 4326548, 4537108, 4767524, 4972708 }},
|
||||||
new PollinSwitch{"Meeting sensor", "00001", 1, "Dining room"},
|
new PollinSwitch{"00001", 1, "Meeting sensor", "Dining room"},
|
||||||
new PollinSwitch{"Fire Tv", "00001", 2, "Living room"},
|
new PollinSwitch{"00001", 2, "Fire Tv", "Living room"},
|
||||||
new PollinSwitch{"Diningroom player", "00001", 3, "Dining room"},
|
new PollinSwitch{"00001", 3, "Diningroom player", "Dining room"},
|
||||||
new PollinSwitch{"Bedroom player", "00001", 4, "Bedroom"},
|
new PollinSwitch{"00001", 4},
|
||||||
new PollinSwitch{"Train", "11111", 4, "Playroom"}
|
new PollinSwitch{"11111", 4, "Train", "Playroom"}
|
||||||
};
|
};
|
||||||
|
|
||||||
Sensor* sensors[] = {
|
Sensor* sensors[] = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user