From 65507f96a72e7c8d47ed370ee0ba90dddea5ab94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Ha=C3=9Fel?= Date: Thu, 28 Aug 2025 12:16:15 +0200 Subject: [PATCH] include relay name in JSON --- src/Output.h | 4 ++++ src/Relay.h | 2 +- src/http.cpp | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Output.h b/src/Output.h index 3d8c320..87c83e6 100644 --- a/src/Output.h +++ b/src/Output.h @@ -134,6 +134,10 @@ public: return millis() - stateMillis; } + String getName() const { + return name; + } + }; #endif diff --git a/src/Relay.h b/src/Relay.h index 097aefc..ca357f2 100644 --- a/src/Relay.h +++ b/src/Relay.h @@ -12,7 +12,7 @@ class Relay final : public Output { public: - Relay(const uint8_t index, const char *name, const uint8_t pin, const bool inverted, const bool logState) : nameFallback(String("relay") + index), Output(nameFallback, pin, inverted, logState), index(index) { + Relay(const uint8_t index, const char *name, const uint8_t pin, const bool inverted, const bool logState) : Output(name, pin, inverted, logState), nameFallback(name), index(index) { // } diff --git a/src/http.cpp b/src/http.cpp index 5f53a88..76ffbf0 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -68,6 +68,7 @@ void httpRelay(const int index, Output &relay) { } void httpRelayJson(const Output &relay, const JsonObject json) { + json["name"] = relay.getName(); json["state"] = relay.get(); json["stateMillis"] = relay.getStateMillis(); json["initial"] = initialToString(relay.getInitial());