set entity_id on HA side for all switches - keep the id consistent, regardless of the name or where it is used
This commit is contained in:
parent
b4d4a179f1
commit
0998f815fd
@ -27,6 +27,11 @@ struct PollinSwitch : Switch {
|
|||||||
return (new string{Protocol_1::buildId(group, channel)})->c_str();
|
return (new string{Protocol_1::buildId(group, channel)})->c_str();
|
||||||
}()), group(group), channel(channel) { // cppcheck-suppress [selfInitialization]
|
}()), group(group), channel(channel) { // cppcheck-suppress [selfInitialization]
|
||||||
if (!name) name = (new string{string(man).append(" ").append(id)})->c_str();
|
if (!name) name = (new string{string(man).append(" ").append(id)})->c_str();
|
||||||
|
entityId = [this]() {
|
||||||
|
auto eId = string{man};
|
||||||
|
transform(eId.begin(), eId.end(), eId.begin(), ::tolower);
|
||||||
|
return (new string{eId.append("_").append(id)})->c_str();
|
||||||
|
}();
|
||||||
mainDevice = &DeviceConfig::create(id).withName(name).withManufacturer(man).withArea(area).withParent(gatewayDevice);
|
mainDevice = &DeviceConfig::create(id).withName(name).withManufacturer(man).withArea(area).withParent(gatewayDevice);
|
||||||
withStateTopic();
|
withStateTopic();
|
||||||
deviceClass = "outlet";
|
deviceClass = "outlet";
|
||||||
@ -57,6 +62,7 @@ struct EasyHomeSwitch : Switch {
|
|||||||
(*n) += remotePosition;
|
(*n) += remotePosition;
|
||||||
name = n->c_str();
|
name = n->c_str();
|
||||||
}
|
}
|
||||||
|
entityId = id;
|
||||||
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";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user