diff --git a/src/ESPDash.cpp b/src/ESPDash.cpp index a0960f7c..544d755a 100644 --- a/src/ESPDash.cpp +++ b/src/ESPDash.cpp @@ -163,7 +163,7 @@ void ESPDash::remove(Statistic *statistic) { } // generates the layout JSON string to the frontend -size_t ESPDash::generateLayoutJSON(AsyncWebSocketClient *client, bool changes_only) { +size_t ESPDash::generateLayoutJSON(AsyncWebSocketClient *client, bool changes_only, Card *onlyCard) { String buf = ""; buf.reserve(DASH_LAYOUT_JSON_SIZE); @@ -183,7 +183,7 @@ size_t ESPDash::generateLayoutJSON(AsyncWebSocketClient *client, bool changes_on if (changes_only) { if (c->_changed) { c->_changed = false; - } else { + } else if (onlyCard == nullptr || onlyCard->_id != c->_id) { continue; } } @@ -461,6 +461,10 @@ void ESPDash::refreshStatistics() { generateLayoutJSON(nullptr, true); } +void ESPDash::refreshCard(Card *card) { + generateLayoutJSON(nullptr, true, card); +} + /* Destructor diff --git a/src/ESPDash.h b/src/ESPDash.h index 02f4b918..f4c45ea6 100644 --- a/src/ESPDash.h +++ b/src/ESPDash.h @@ -80,7 +80,7 @@ class ESPDash{ char password[64]; // Generate layout json - size_t generateLayoutJSON(AsyncWebSocketClient *client, bool changes_only = false); + size_t generateLayoutJSON(AsyncWebSocketClient *client, bool changes_only = false, Card *onlyCard = nullptr); // Generate Component JSON void generateComponentJSON(JsonObject& obj, Card* card, bool change_only = false); @@ -117,6 +117,7 @@ class ESPDash{ void sendUpdates(bool force = false); void refreshStatistics(); + void refreshCard(Card *card); ~ESPDash(); };