Добавляем переменным возможность хранить время по шаблону

This commit is contained in:
2022-04-25 23:30:56 +03:00
parent 934173f8cc
commit 094bb44ed6
3 changed files with 21 additions and 5 deletions

View File

@@ -55,8 +55,9 @@
"widget": "",
"page": "",
"descr": "",
"int": "0",
"val": "0"
"int": "1",
"val": "0",
"dtFormat": ""
},
{
"header": "Модули управления"

View File

@@ -1,15 +1,29 @@
#include "Global.h"
#include "classes/IoTItem.h"
#include "classes/IoTRTC.h"
extern IoTRTC *watch;
class Variable : public IoTItem {
private:
String _dtFormat;
public:
Variable(String parameters): IoTItem(parameters) { }
Variable(String parameters): IoTItem(parameters) {
jsonRead(parameters, "dtFormat", _dtFormat);
_dtFormat = _dtFormat;
}
// особенность данного модуля - просто хранение значения для сценария, нет событий
// void setValue(IoTValue Value) {
// value = Value;
// }
void doByInterval() {
if (_dtFormat != "") {
value.isDecimal = false;
value.valS = watch->gettime(_dtFormat + " ");
}
}
};
void* getAPI_Variable(String subtype, String param) {

View File

@@ -9,7 +9,8 @@
"page": "",
"descr": "",
"int": "0",
"val": "0"
"int": "1",
"val": "0",
"dtFormat": ""
}
]