mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 11:59:12 +03:00
добавление pretty времени в gate mysensors
This commit is contained in:
@@ -613,7 +613,33 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "42. Расширитель портов Pcf8574",
|
"name": "42. MySensorsGate",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "MySensorsGate",
|
||||||
|
"id": "gt",
|
||||||
|
"widget": "nil",
|
||||||
|
"page": "",
|
||||||
|
"descr": "",
|
||||||
|
"num": 42
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "43. MySensorsNode",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "MySensorsNode",
|
||||||
|
"id": "n",
|
||||||
|
"widget": "anydataTmp",
|
||||||
|
"page": "MySensors",
|
||||||
|
"descr": "Температура",
|
||||||
|
"orange": 60,
|
||||||
|
"red": 120,
|
||||||
|
"offline": 180,
|
||||||
|
"round": 1,
|
||||||
|
"num": 43
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "44. Расширитель портов Pcf8574",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Pcf8574",
|
"subtype": "Pcf8574",
|
||||||
"id": "Pcf",
|
"id": "Pcf",
|
||||||
@@ -623,27 +649,29 @@
|
|||||||
"int": "0",
|
"int": "0",
|
||||||
"addr": "0x20",
|
"addr": "0x20",
|
||||||
"index": 1,
|
"index": 1,
|
||||||
"num": 42
|
"num": 44
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "43. PWM ESP8266",
|
"name": "45. PWM ESP32",
|
||||||
"type": "Writing",
|
"type": "Writing",
|
||||||
"subtype": "Pwm8266",
|
"subtype": "Pwm32",
|
||||||
"id": "pwm",
|
"id": "pwm",
|
||||||
"widget": "range",
|
"widget": "range",
|
||||||
"page": "Кнопки",
|
"page": "Кнопки",
|
||||||
"descr": "PWM",
|
"descr": "PWM",
|
||||||
"int": 0,
|
"int": 0,
|
||||||
"pin": 15,
|
"pin": 2,
|
||||||
"freq": 5000,
|
"freq": 5000,
|
||||||
|
"ledChannel": 2,
|
||||||
|
"PWM_resolution": 10,
|
||||||
"val": 0,
|
"val": 0,
|
||||||
"apin": -1,
|
"apin": -1,
|
||||||
"num": 43
|
"num": 45
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "44. Телеграм-Лайт",
|
"name": "46. Телеграм-Лайт",
|
||||||
"type": "Writing",
|
"type": "Writing",
|
||||||
"subtype": "TelegramLT",
|
"subtype": "TelegramLT",
|
||||||
"id": "tg",
|
"id": "tg",
|
||||||
@@ -652,14 +680,14 @@
|
|||||||
"descr": "",
|
"descr": "",
|
||||||
"token": "",
|
"token": "",
|
||||||
"chatID": "",
|
"chatID": "",
|
||||||
"num": 44
|
"num": 46
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"header": "Экраны"
|
"header": "Экраны"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "45. LCD экран 2004",
|
"name": "47. LCD экран 2004",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Lcd2004",
|
"subtype": "Lcd2004",
|
||||||
"id": "Lcd",
|
"id": "Lcd",
|
||||||
@@ -671,10 +699,10 @@
|
|||||||
"size": "20,4",
|
"size": "20,4",
|
||||||
"coord": "0,0",
|
"coord": "0,0",
|
||||||
"id2show": "id датчика",
|
"id2show": "id датчика",
|
||||||
"num": 45
|
"num": 47
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "46. LCD экран 1602",
|
"name": "48. LCD экран 1602",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Lcd2004",
|
"subtype": "Lcd2004",
|
||||||
"id": "Lcd",
|
"id": "Lcd",
|
||||||
@@ -686,6 +714,6 @@
|
|||||||
"size": "16,2",
|
"size": "16,2",
|
||||||
"coord": "0,0",
|
"coord": "0,0",
|
||||||
"id2show": "id датчика",
|
"id2show": "id датчика",
|
||||||
"num": 46
|
"num": 48
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -3,3 +3,4 @@
|
|||||||
|
|
||||||
extern const String prettySeconds(unsigned long time_s);
|
extern const String prettySeconds(unsigned long time_s);
|
||||||
extern const String prettyMillis(unsigned long time_ms);
|
extern const String prettyMillis(unsigned long time_ms);
|
||||||
|
extern const String prettyMinutsTimeout(unsigned long time_m);
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
},
|
},
|
||||||
"projectProp": {
|
"projectProp": {
|
||||||
"platformio": {
|
"platformio": {
|
||||||
"default_envs": "esp8266_4mb",
|
"default_envs": "esp32_4mb",
|
||||||
"comments_default_envs": "choose from: esp8266_4mb or esp32_4mb or esp8266_1mb or esp8266_1mb_ota or esp8285_1mb or esp8285_1mb_ota"
|
"comments_default_envs": "choose from: esp8266_4mb or esp32_4mb or esp8266_1mb or esp8266_1mb_ota or esp8285_1mb or esp8285_1mb_ota"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[platformio]
|
[platformio]
|
||||||
default_envs = esp8266_4mb
|
default_envs = esp32_4mb
|
||||||
data_dir = data_svelte
|
data_dir = data_svelte
|
||||||
|
|
||||||
[common_env_data]
|
[common_env_data]
|
||||||
|
|||||||
@@ -24,8 +24,9 @@ void* getAPI_IoTServo(String subtype, String params);
|
|||||||
void* getAPI_Mcp23017(String subtype, String params);
|
void* getAPI_Mcp23017(String subtype, String params);
|
||||||
void* getAPI_Mp3(String subtype, String params);
|
void* getAPI_Mp3(String subtype, String params);
|
||||||
void* getAPI_Multitouch(String subtype, String params);
|
void* getAPI_Multitouch(String subtype, String params);
|
||||||
|
void* getAPI_MySensorsGate(String subtype, String params);
|
||||||
void* getAPI_Pcf8574(String subtype, String params);
|
void* getAPI_Pcf8574(String subtype, String params);
|
||||||
void* getAPI_Pwm8266(String subtype, String params);
|
void* getAPI_Pwm32(String subtype, String params);
|
||||||
void* getAPI_TelegramLT(String subtype, String params);
|
void* getAPI_TelegramLT(String subtype, String params);
|
||||||
void* getAPI_Lcd2004(String subtype, String params);
|
void* getAPI_Lcd2004(String subtype, String params);
|
||||||
|
|
||||||
@@ -55,8 +56,9 @@ if ((tmpAPI = getAPI_IoTServo(subtype, params)) != nullptr) return tmpAPI;
|
|||||||
if ((tmpAPI = getAPI_Mcp23017(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Mcp23017(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_Mp3(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Mp3(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_Multitouch(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Multitouch(subtype, params)) != nullptr) return tmpAPI;
|
||||||
|
if ((tmpAPI = getAPI_MySensorsGate(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_Pcf8574(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Pcf8574(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_Pwm8266(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Pwm32(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_TelegramLT(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_TelegramLT(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_Lcd2004(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Lcd2004(subtype, params)) != nullptr) return tmpAPI;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
@@ -394,7 +394,7 @@ class MySensorsNode : public IoTItem {
|
|||||||
|
|
||||||
void setNewWidgetAttributes() {
|
void setNewWidgetAttributes() {
|
||||||
if (dataFromNode) {
|
if (dataFromNode) {
|
||||||
jsonWriteStr(json, F("info"), String(_minutesPassed) + " min");
|
jsonWriteStr(json, F("info"), prettyMinutsTimeout(_minutesPassed));
|
||||||
if (orange != 0 && red != 0 && offline != 0) {
|
if (orange != 0 && red != 0 && offline != 0) {
|
||||||
if (_minutesPassed < orange) {
|
if (_minutesPassed < orange) {
|
||||||
jsonWriteStr(json, F("color"), "");
|
jsonWriteStr(json, F("color"), "");
|
||||||
|
|||||||
@@ -41,7 +41,10 @@
|
|||||||
"moduleDesc": "Устройство состоит из esp32 и подключенному к нему радиомодулю NRF24L01. Вместе в связке они образуют гейт, способный принимать данные датчиков. Датчики способны работать до нескольких лет на батарейках. Датчики делаются на базе nrf52832 от holyiot. Батарейки подключаются напрямик к nrf52832",
|
"moduleDesc": "Устройство состоит из esp32 и подключенному к нему радиомодулю NRF24L01. Вместе в связке они образуют гейт, способный принимать данные датчиков. Датчики способны работать до нескольких лет на батарейках. Датчики делаются на базе nrf52832 от holyiot. Батарейки подключаются напрямик к nrf52832",
|
||||||
"retInfo": "",
|
"retInfo": "",
|
||||||
"propInfo": {
|
"propInfo": {
|
||||||
"id": "Для настройки следует выбрать один раз MySensorsGate и выбрать сколько необходимо раз MySensorsNode. Вместо ID нужно указать например - n100s1. Это значит что мы будем получать данные с ноды 100 и с сенсора этой ноды под номером 1"
|
"id": "Для настройки следует выбрать один раз MySensorsGate и выбрать сколько необходимо раз MySensorsNode. Вместо ID нужно указать например - n100s1. Это значит что мы будем получать данные с ноды 100 и с сенсора этой ноды под номером 1",
|
||||||
|
"orange": "количество минут после которого окрасить виджет в оранжевый цвет",
|
||||||
|
"red": "количество минут после которого окрасить виджет в красный цвет",
|
||||||
|
"offline": "количество минут после которого отобразить что устройство offline, если все три orange red и offline поставить в ноль - то функция окраски выключится"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"defActive": false,
|
"defActive": false,
|
||||||
|
|||||||
@@ -33,3 +33,30 @@ const String prettySeconds(unsigned long time_s) {
|
|||||||
const String prettyMillis(unsigned long time_ms) {
|
const String prettyMillis(unsigned long time_ms) {
|
||||||
return prettySeconds(time_ms / 1000);
|
return prettySeconds(time_ms / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const String prettyMinutsTimeout(unsigned long time_m) {
|
||||||
|
unsigned long tmp = time_m * 60;
|
||||||
|
unsigned long seconds;
|
||||||
|
unsigned long minutes;
|
||||||
|
unsigned long hours;
|
||||||
|
unsigned long days;
|
||||||
|
seconds = tmp % 60;
|
||||||
|
tmp = tmp / 60;
|
||||||
|
|
||||||
|
minutes = tmp % 60;
|
||||||
|
tmp = tmp / 60;
|
||||||
|
|
||||||
|
hours = tmp % 24;
|
||||||
|
days = tmp / 24;
|
||||||
|
|
||||||
|
char buf[32];
|
||||||
|
|
||||||
|
if (days) {
|
||||||
|
sprintf_P(buf, "%d day %d hr %d min", days, hours, minutes, seconds);
|
||||||
|
} else if (hours && !days) {
|
||||||
|
sprintf_P(buf, "%d hr %d min", hours, minutes);
|
||||||
|
} else {
|
||||||
|
sprintf_P(buf, "%d min", minutes);
|
||||||
|
}
|
||||||
|
return String(buf);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user