include relay name in JSON

This commit is contained in:
Patrick Haßel 2025-08-28 12:16:15 +02:00
parent c12ae7a50f
commit 65507f96a7
3 changed files with 6 additions and 1 deletions

View File

@ -134,6 +134,10 @@ public:
return millis() - stateMillis; return millis() - stateMillis;
} }
String getName() const {
return name;
}
}; };
#endif #endif

View File

@ -12,7 +12,7 @@ class Relay final : public Output {
public: 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) {
// //
} }

View File

@ -68,6 +68,7 @@ void httpRelay(const int index, Output &relay) {
} }
void httpRelayJson(const Output &relay, const JsonObject json) { void httpRelayJson(const Output &relay, const JsonObject json) {
json["name"] = relay.getName();
json["state"] = relay.get(); json["state"] = relay.get();
json["stateMillis"] = relay.getStateMillis(); json["stateMillis"] = relay.getStateMillis();
json["initial"] = initialToString(relay.getInitial()); json["initial"] = initialToString(relay.getInitial());