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());