Review components files
This commit is contained in:
24
components/nspanel_ha_blueprint/ha_components.cpp
Normal file
24
components/nspanel_ha_blueprint/ha_components.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
// ha_components.cpp
|
||||
|
||||
#include "ha_components.h"
|
||||
|
||||
namespace nspanel_ha_blueprint {
|
||||
|
||||
// Function Definition
|
||||
HomeAssistantEntity extractHomeAssistantEntity(const std::string& entity_id) {
|
||||
size_t dotPos = entity_id.find(".");
|
||||
HomeAssistantEntity result;
|
||||
|
||||
if (dotPos != std::string::npos) {
|
||||
// Extract domain and id from the entity_id string
|
||||
result.domain = entity_id.substr(0, dotPos);
|
||||
result.id = entity_id.substr(dotPos + 1);
|
||||
} else {
|
||||
// No dot found, the entire entity_id is considered as id.
|
||||
result.domain = "invalid";
|
||||
result.id = entity_id;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace nspanel_ha_blueprint
|
||||
Reference in New Issue
Block a user