include relay name in JSON
This commit is contained in:
parent
c12ae7a50f
commit
65507f96a7
@ -134,6 +134,10 @@ public:
|
|||||||
return millis() - stateMillis;
|
return millis() - stateMillis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getName() const {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -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) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user