diff --git a/src/ha.h b/src/ha.h index ff1e640..216559f 100644 --- a/src/ha.h +++ b/src/ha.h @@ -87,11 +87,12 @@ namespace Ha { } }; - const char* entityCategory = nullptr; - const char* deviceClass = nullptr; - const char* name = nullptr; const char* id = nullptr; const char* type = nullptr; + + const char* name = nullptr; + const char* entityCategory = nullptr; + const char* deviceClass = nullptr; char configTopic[TOPIC_SIZE]; JsonPairs jsonBooleans; JsonPairs jsonNumbers; @@ -100,7 +101,7 @@ namespace Ha { static List components; bool multiValueComponent = false; - Component(const char* name, const char* id, const char* type) : name(name), id(id), type(type) { + Component(const char* id, const char* name, const char* type) : id(id), type(type), name(name) { components.add(this); } @@ -297,7 +298,7 @@ namespace Ha { struct Button : Component, Command { - Button(const char* name, const char* id, onMessage f = nullptr) : Component(name, id, "button"), Command(this, f) {} + Button(const char* name, const char* id, onMessage f = nullptr) : Component(id, name, "button"), Command(this, f) {} void buildConfig(JsonDocument& jsonDoc) override { Component::buildConfig(jsonDoc); @@ -344,7 +345,7 @@ namespace Ha { struct Switch : Component, StatefulCommand { - Switch(const char* name, const char* id, onMessage f = nullptr) : Component(name, id, "switch"), StatefulCommand(this, f) {} + Switch(const char* name, const char* id, onMessage f = nullptr) : Component(id, name, "switch"), StatefulCommand(this, f) {} void updateState(bool state) { State::updateState(state ? "ON" : "OFF"); @@ -359,7 +360,7 @@ namespace Ha { struct Number : Component, StatefulCommand { unsigned int min, max, step; - Number(const char* name, const char* id, onMessage f) : Component(name, id, "number"), StatefulCommand(this, f) {} + Number(const char* name, const char* id, onMessage f) : Component(id, name, "number"), StatefulCommand(this, f) {} void updateState(unsigned int value) { State::updateState(to_string(value).c_str()); @@ -380,7 +381,7 @@ namespace Ha { unsigned int precision = 2; static unordered_map mapSensors; - Sensor(const char* name, const char* id) : Component(name, id, "sensor"), State(this) { + Sensor(const char* name, const char* id) : Component(id, name, "sensor"), State(this) { withStateTopic(); mapSensors.insert({ string(id), this }); }