HW button bar in all pages

Partially solves #1835
Partially solves #1517
Solves #1507
This commit is contained in:
Edward Firmo
2024-02-26 09:38:20 +01:00
parent abd55b4bc0
commit f2a1f27e0c
6 changed files with 939 additions and 1262 deletions

View File

@@ -0,0 +1,36 @@
// ha_components.h
#pragma once
#include <string>
namespace nspanel_ha_blueprint {
struct HomeAssistantEntity {
std::string domain;
std::string id;
};
/**
* Extracts the domain name and unique ID from a given Home Assistant entity string.
* Handles a special case where "alarm_control_panel" should be shortened to "alarm".
*
* @param entity_id The input string containing either the combined domain and unique ID or just the unique ID.
* @return A HomeAssistantEntity struct containing the extracted domain and the unique ID.
*/
HomeAssistantEntity extractHomeAssistantEntity(const std::string& entity_id) {
size_t dotPos = input.find(".");
HomeAssistantEntity result;
if (dotPos != std::string::npos) {
// Extract domain and id from the input string
result.domain = input.substr(0, dotPos);
result.id = input.substr(dotPos + 1);
} else {
// No dot found, the entire input is considered as id.
result.domain = "invalid";
result.id = input;
}
return result;
}
} // namespace nspanel_ha_blueprint