1#ifndef SENSESP_SRC_TRANSFORMS_TIME_COUNTER_H_
2#define SENSESP_SRC_TRANSFORMS_TIME_COUNTER_H_
9inline uint64_t ARDUINO_ISR_ATTR
millis64() {
return esp_timer_get_time() / 1000ULL; }
28 virtual void set(
const T& input)
override {
63 virtual bool to_json(JsonObject& root)
override {
68 virtual bool from_json(
const JsonObject& config)
override {
69 ESP_LOGD(__FILENAME__,
"Setting TimeCounter configuration");
70 if (config[
"duration_s"].is<double>()) {
72 config[
"duration_s"].as<
double>() * 1000;
73 }
else if (!config[
"duration"].is<double>()) {
81 ESP_LOGD(__FILENAME__,
"duration_at_start_ms_ = %ld",
96 return R
"({"type":"object","properties":{"duration_s":{"type":"number","displayMultiplier":0.0002777777777777778,"title":"Total Duration [hours]"}},"required":["duration_s"]})";
virtual bool load() override
Load and populate the object from a persistent storage.
virtual bool save() override
Save the object to a persistent storage.
A transform that outputs the duration of the input value being true or non-null.
virtual bool from_json(const JsonObject &config) override
uint64_t duration_at_start_ms_
virtual bool to_json(JsonObject &root) override
TimeCounter(String config_path)
virtual void set(const T &input) override
void emit(const double &new_value)
const String ConfigSchema(const SmartSwitchController &obj)
uint64_t ARDUINO_ISR_ATTR millis64()