From fae8d24b3c97a7575d1fb7f0a0df62c2c629d50e Mon Sep 17 00:00:00 2001 From: Kylie Smith Date: Fri, 5 Apr 2024 16:22:58 +1000 Subject: [PATCH] Zone object DClass names --- src/stateserver/database_state_server.cpp | 10 +++++++++- src/stateserver/state_server.cpp | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/stateserver/database_state_server.cpp b/src/stateserver/database_state_server.cpp index 5d1b33b..f80d16f 100644 --- a/src/stateserver/database_state_server.cpp +++ b/src/stateserver/database_state_server.cpp @@ -487,7 +487,15 @@ void DatabaseStateServer::HandleWeb(ws28::Client *client, // Build a dictionary of zone objects under this Distributed Object. nlohmann::json zoneObjs = nlohmann::json::object(); for (const auto &zoneData : distObj->GetZoneObjects()) { - zoneObjs[std::to_string(zoneData.first)] = zoneData.second; + for (const auto &zoneDoId : zoneData.second) { + // Try to get the DClass name for the zone object. + auto clsName = _distObjs.contains(zoneDoId) + ? _distObjs[zoneDoId]->GetDClass()->get_name() + : "Unknown"; + + zoneObjs[std::to_string(zoneData.first)].push_back( + {{"doId", zoneDoId}, {"clsName", clsName}}); + } } WebPanel::Send(client, { diff --git a/src/stateserver/state_server.cpp b/src/stateserver/state_server.cpp index 9427af5..5609359 100644 --- a/src/stateserver/state_server.cpp +++ b/src/stateserver/state_server.cpp @@ -191,7 +191,15 @@ void StateServer::HandleWeb(ws28::Client *client, nlohmann::json &data) { // Build a dictionary of zone objects under this Distributed Object. nlohmann::json zoneObjs = nlohmann::json::object(); for (const auto &zoneData : distObj->GetZoneObjects()) { - zoneObjs[std::to_string(zoneData.first)] = zoneData.second; + for (const auto &zoneDoId : zoneData.second) { + // Try to get the DClass name for the zone object. + auto clsName = _distObjs.contains(zoneDoId) + ? _distObjs[zoneDoId]->GetDClass()->get_name() + : "Unknown"; + + zoneObjs[std::to_string(zoneData.first)].push_back( + {{"doId", zoneDoId}, {"clsName", clsName}}); + } } WebPanel::Send(client, {