light info has unique id no

This commit is contained in:
2025-08-30 21:38:24 +02:00
parent 14041120cd
commit 3c018ebba5
2 changed files with 27 additions and 10 deletions

View File

@@ -4,14 +4,32 @@
#include "pin.h"
struct LightInfo {
LightInfo() = default;
LightInfo(const std::string& id) {
uniqueId = id;
updateTopics();
}
void setUniqueId(const std::string& id) {
uniqueId = id;
updateTopics();
}
void updateTopics() {
discoveryTopic = discoveryTopicBase + uniqueId + "/config";
availabilityTopic = topicBase + uniqueId + "/availability";
stateTopic = topicBase + uniqueId + "/state";
jsonAttributesTopic = topicBase + uniqueId + "/attributes";
commandTopic = topicBase + uniqueId + "/state/set";
}
std::string uniqueId;
const std::string name = "Smart RGB Light";
const std::string discoveryTopic = "homeassistant/light/smart_rgb_light/light/config";
const std::string availabilityTopic = "studiotj/smart-rgb/light/status";
const std::string stateTopic = "studiotj/smart-rgb/light/state";
const std::string jsonAttributesTopic = "studiotj/smart-rgb/light/attributes";
const std::string stateValueTemplate = "{{ value_json.state }}";
const std::string commandTopic = "studiotj/smart-rgb/light/state/set";
const std::string discoveryTopicBase = "homeassistant/light/";
std::string discoveryTopic = discoveryTopicBase + uniqueId + "/config";
const std::string topicBase = "studiotj/";
std::string availabilityTopic = topicBase + uniqueId + "/availability";
std::string stateTopic = topicBase + uniqueId + "/state";
std::string jsonAttributesTopic = topicBase + uniqueId + "/attributes";
std::string stateValueTemplate = "{{ value_json.state }}";
std::string commandTopic = topicBase + uniqueId + "/state/set";
const std::string supportedColorModesValue = "['rgb', 'brightness']";
const std::string availabilityTemplate = "{{ value_json.availability }}";
};