api entitiy attributes with hcs

This commit is contained in:
MichaelDvP
2022-05-06 13:27:21 +02:00
parent 1b21e02b7a
commit 6277fbbea1
4 changed files with 95 additions and 46 deletions

View File

@@ -912,16 +912,13 @@ bool EMSdevice::get_value_info(JsonObject & output, const char * cmd, const int8
// make a copy of the string command for parsing
char command_s[30];
strlcpy(command_s, cmd, sizeof(command_s));
char * attribute_s = command_s;
char * attribute_s = nullptr;
// if id=0 then we have a specific attribute to fetch instead of the complete record
if (id == 0) {
char * p = command_s;
char * breakp = strchr(p, '/');
if (breakp) {
*breakp = '\0';
attribute_s = breakp + 1;
}
// check specific attribute to fetch instead of the complete record
char * breakp = strchr(command_s, '/');
if (breakp) {
*breakp = '\0';
attribute_s = breakp + 1;
}
// search device value with this tag
@@ -1065,8 +1062,8 @@ bool EMSdevice::get_value_info(JsonObject & output, const char * cmd, const int8
json[value] = "not set";
}
// if id is 0 then we're filtering on an attribute, go find it
if (id == 0) {
// if we're filtering on an attribute, go find it
if (attribute_s) {
#if defined(EMSESP_DEBUG)
EMSESP::logger().debug(F("[DEBUG] Attribute '%s'"), attribute_s);
#endif