1#ifndef SENSESP_SENSORS_CONSTANT_SENSOR_H_
2#define SENSESP_SENSORS_CONSTANT_SENSOR_H_
64 virtual bool to_json(JsonObject& doc)
override {
68 virtual bool from_json(
const JsonObject& config)
override {
70 if (config[
"value"].is<T>()) {
71 value_ = config[
"value"].as<T>();
106 String schema = R
"###({"type":"object","properties":{"value":{"title":"Constant Value","type":"%TYPE%","description":"Constant value"}} })###";
109 return schema.c_str();
ConstantSensor is the base class for virtual sensors that periodically emit a constant value.
virtual bool from_json(const JsonObject &config) override
ConstantSensor(T value, int send_interval=30, String config_path="")
virtual bool to_json(JsonObject &doc) override
virtual bool load() override
Load and populate the object from a persistent storage.
Sensor template class for any sensor producing actual values.
void emit(const T &new_value)
const String ConfigSchema(const SmartSwitchController &obj)
std::shared_ptr< reactesp::EventLoop > event_loop()
const String ConfigSchemaSensorType< String >(const String &obj)
ConstantSensor< int > IntConstantSensor
ConstantSensor< String > StringConstantSensor
const String ConfigSchemaSensorType(const T &obj)
const String ConfigSchemaSensorType< int >(const int &obj)
const String ConfigSchemaSensorType< bool >(const bool &obj)
ConstantSensor< float > FloatConstantSensor
const String ConfigSchemaSensorType< float >(const float &obj)
ConstantSensor< bool > BoolConstantSensor