build a default name for Pollin switches

This commit is contained in:
Nicu Hodos 2024-10-05 21:28:54 +02:00
parent 7e44a0710a
commit e246158502

View File

@ -55,6 +55,7 @@ namespace OilTank {
}
struct PollinSwitch : Switch {
constexpr static const char* man = "Pollin";
const char* group;
unsigned char channel;
@ -66,7 +67,8 @@ struct PollinSwitch : Switch {
strcpy(uId, s.c_str());
return uId;
}()), 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();
deviceClass = "outlet";
p1Switches.insert({ string(id), this });
@ -127,7 +129,7 @@ Command* commands[] = {
new PollinSwitch{"00001", 1, "Meeting sensor", "Dining room"},
new PollinSwitch{"00001", 2, "Fire Tv", "Living room"},
new PollinSwitch{"00001", 3, "Diningroom player", "Dining room"},
new PollinSwitch{"00001", 4, "Bedroom player", "Bedroom"},
new PollinSwitch{"00001", 4},
new PollinSwitch{"11111", 4, "Train", "Playroom"}
};