SensESP 3.0.1
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
signalk_time.cpp
Go to the documentation of this file.
1
2#include "signalk_time.h"
3
4namespace sensesp {
5
6SKOutputTime::SKOutputTime(const String& sk_path, const String& config_path)
7 : TimeString(config_path), SKEmitter(sk_path) {
8 load();
9}
10
11void SKOutputTime::as_signalk_json(JsonDocument& doc){
12 doc["path"] = this->sk_path_;
13 doc["value"] = output_;
14}
15
16bool SKOutputTime::to_json(JsonObject& doc) {
17 doc["sk_path"] = sk_path_;
18 return true;
19}
20
21bool SKOutputTime::from_json(const JsonObject& config) {
22 const String expected[] = {"sk_path"};
23 for (auto str : expected) {
24 if (!config[str].is<JsonVariant>()) {
25 return false;
26 }
27 }
28 sk_path_ = config["sk_path"].as<String>();
29 return true;
30}
31
32const String ConfigSchema(const SKOutputTime& obj) {
33 return R"({"type":"object","properties":{"sk_path":{"title":"Signal K Path","type":"string"}}})";
34}
35
36} // namespace sensesp
virtual bool load() override
Load and populate the object from a persistent storage.
Definition saveable.cpp:8
A class that produces Signal K output to be forwarded to the Signal K server (if the system is connec...
SKOutputTime(const String &sk_path, const String &config_path="")
virtual bool from_json(const JsonObject &config) override
virtual bool to_json(JsonObject &doc) override
virtual void as_signalk_json(JsonDocument &doc) override
Consumes a time_t time object and produces a human readable string of the time for UTC in ISO 8601 fo...
Definition timestring.h:15
const String ConfigSchema(const SmartSwitchController &obj)