mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 20:09:14 +03:00
Merge pull request #254 from avaksru/ver4dev
Модуль Погода (Weather) и ExternalMQTT и VariableColor
This commit is contained in:
@@ -162,7 +162,21 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "11. Виртуальная кнопка",
|
"name": "11. Цветной текст",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "VariableColor",
|
||||||
|
"id": "color",
|
||||||
|
"needSave": 0,
|
||||||
|
"widget": "anydataDef",
|
||||||
|
"page": "Вывод",
|
||||||
|
"descr": "Цветной текст",
|
||||||
|
"val": "...",
|
||||||
|
"round": 0,
|
||||||
|
"num": 11
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "12. Виртуальная кнопка",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "VButton",
|
"subtype": "VButton",
|
||||||
"id": "vbtn",
|
"id": "vbtn",
|
||||||
@@ -172,13 +186,13 @@
|
|||||||
"descr": "Кнопка",
|
"descr": "Кнопка",
|
||||||
"int": "0",
|
"int": "0",
|
||||||
"val": "0",
|
"val": "0",
|
||||||
"num": 11
|
"num": 12
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"header": "Сенсоры"
|
"header": "Сенсоры"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "12. Acs712 Ток",
|
"name": "13. Acs712 Ток",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Acs712",
|
"subtype": "Acs712",
|
||||||
"id": "amp",
|
"id": "amp",
|
||||||
@@ -188,11 +202,11 @@
|
|||||||
"round": 3,
|
"round": 3,
|
||||||
"pin": 39,
|
"pin": 39,
|
||||||
"int": 5,
|
"int": 5,
|
||||||
"num": 12
|
"num": 13
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "13. AHTXX Температура",
|
"name": "14. AHTXX Температура",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "AhtXXt",
|
"subtype": "AhtXXt",
|
||||||
"id": "Temp20",
|
"id": "Temp20",
|
||||||
@@ -203,11 +217,11 @@
|
|||||||
"addr": "0x38",
|
"addr": "0x38",
|
||||||
"shtType": 1,
|
"shtType": 1,
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 13
|
"num": 14
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "14. AHTXX Влажность",
|
"name": "15. AHTXX Влажность",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "AhtXXh",
|
"subtype": "AhtXXh",
|
||||||
"id": "Hum20",
|
"id": "Hum20",
|
||||||
@@ -218,11 +232,11 @@
|
|||||||
"addr": "0x38",
|
"addr": "0x38",
|
||||||
"shtType": 1,
|
"shtType": 1,
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 14
|
"num": 15
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "15. Аналоговый сенсор",
|
"name": "16. Аналоговый сенсор",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "AnalogAdc",
|
"subtype": "AnalogAdc",
|
||||||
"id": "t",
|
"id": "t",
|
||||||
@@ -236,11 +250,11 @@
|
|||||||
"pin": 0,
|
"pin": 0,
|
||||||
"int": 15,
|
"int": 15,
|
||||||
"avgSteps": 1,
|
"avgSteps": 1,
|
||||||
"num": 15
|
"num": 16
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "16. BME280 Температура",
|
"name": "17. BME280 Температура",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Bme280t",
|
"subtype": "Bme280t",
|
||||||
"id": "tmp3",
|
"id": "tmp3",
|
||||||
@@ -250,11 +264,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0x77",
|
"addr": "0x77",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 16
|
"num": 17
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "17. BME280 Давление",
|
"name": "18. BME280 Давление",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Bme280p",
|
"subtype": "Bme280p",
|
||||||
"id": "Press3",
|
"id": "Press3",
|
||||||
@@ -264,11 +278,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0x77",
|
"addr": "0x77",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 17
|
"num": 18
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "18. BME280 Влажность",
|
"name": "19. BME280 Влажность",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Bme280h",
|
"subtype": "Bme280h",
|
||||||
"id": "Hum3",
|
"id": "Hum3",
|
||||||
@@ -278,11 +292,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0x77",
|
"addr": "0x77",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 18
|
"num": 19
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "19. BMP280 Температура",
|
"name": "20. BMP280 Температура",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Bmp280t",
|
"subtype": "Bmp280t",
|
||||||
"id": "tmp3",
|
"id": "tmp3",
|
||||||
@@ -292,11 +306,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0x77",
|
"addr": "0x77",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 19
|
"num": 20
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "20. BMP280 Давление",
|
"name": "21. BMP280 Давление",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Bmp280p",
|
"subtype": "Bmp280p",
|
||||||
"id": "Press3",
|
"id": "Press3",
|
||||||
@@ -306,11 +320,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0x77",
|
"addr": "0x77",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 20
|
"num": 21
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "21. DHT11 Температура",
|
"name": "22. DHT11 Температура",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Dht1122t",
|
"subtype": "Dht1122t",
|
||||||
"id": "tmp3",
|
"id": "tmp3",
|
||||||
@@ -320,11 +334,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"pin": 0,
|
"pin": 0,
|
||||||
"senstype": "dht11",
|
"senstype": "dht11",
|
||||||
"num": 21
|
"num": 22
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "22. DHT11 Влажность",
|
"name": "23. DHT11 Влажность",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Dht1122h",
|
"subtype": "Dht1122h",
|
||||||
"id": "Hum3",
|
"id": "Hum3",
|
||||||
@@ -334,11 +348,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"pin": 0,
|
"pin": 0,
|
||||||
"senstype": "dht11",
|
"senstype": "dht11",
|
||||||
"num": 22
|
"num": 23
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "23. DS18B20 Температура",
|
"name": "24. DS18B20 Температура",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Ds18b20",
|
"subtype": "Ds18b20",
|
||||||
"id": "dstmp",
|
"id": "dstmp",
|
||||||
@@ -350,11 +364,11 @@
|
|||||||
"index": 0,
|
"index": 0,
|
||||||
"addr": "",
|
"addr": "",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 23
|
"num": 24
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "24. PZEM 004t Напряжение",
|
"name": "25. PZEM 004t Напряжение",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Pzem004v",
|
"subtype": "Pzem004v",
|
||||||
"id": "v",
|
"id": "v",
|
||||||
@@ -364,11 +378,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0xF8",
|
"addr": "0xF8",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 24
|
"num": 25
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "25. PZEM 004t Сила тока",
|
"name": "26. PZEM 004t Сила тока",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Pzem004a",
|
"subtype": "Pzem004a",
|
||||||
"id": "a",
|
"id": "a",
|
||||||
@@ -378,11 +392,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0xF8",
|
"addr": "0xF8",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 25
|
"num": 26
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "26. PZEM 004t Мощность",
|
"name": "27. PZEM 004t Мощность",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Pzem004w",
|
"subtype": "Pzem004w",
|
||||||
"id": "w",
|
"id": "w",
|
||||||
@@ -392,11 +406,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0xF8",
|
"addr": "0xF8",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 26
|
"num": 27
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "27. PZEM 004t Энергия",
|
"name": "28. PZEM 004t Энергия",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Pzem004wh",
|
"subtype": "Pzem004wh",
|
||||||
"id": "wh",
|
"id": "wh",
|
||||||
@@ -406,11 +420,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0xF8",
|
"addr": "0xF8",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 27
|
"num": 28
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "28. PZEM 004t Частота",
|
"name": "29. PZEM 004t Частота",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Pzem004hz",
|
"subtype": "Pzem004hz",
|
||||||
"id": "hz",
|
"id": "hz",
|
||||||
@@ -420,11 +434,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0xF8",
|
"addr": "0xF8",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 28
|
"num": 29
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "29. PZEM 004t Косинус",
|
"name": "30. PZEM 004t Косинус",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Pzem004pf",
|
"subtype": "Pzem004pf",
|
||||||
"id": "pf",
|
"id": "pf",
|
||||||
@@ -434,11 +448,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0xF8",
|
"addr": "0xF8",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 29
|
"num": 30
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "30. PZEM настройка",
|
"name": "31. PZEM настройка",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Pzem004cmd",
|
"subtype": "Pzem004cmd",
|
||||||
"id": "set",
|
"id": "set",
|
||||||
@@ -450,11 +464,11 @@
|
|||||||
"changeaddr": 0,
|
"changeaddr": 0,
|
||||||
"setaddr": "0x01",
|
"setaddr": "0x01",
|
||||||
"reset": 0,
|
"reset": 0,
|
||||||
"num": 30
|
"num": 31
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "31. Sht20 Температура",
|
"name": "32. Sht20 Температура",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Sht20t",
|
"subtype": "Sht20t",
|
||||||
"id": "tmp2",
|
"id": "tmp2",
|
||||||
@@ -463,11 +477,11 @@
|
|||||||
"descr": "Температура",
|
"descr": "Температура",
|
||||||
"int": 15,
|
"int": 15,
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 31
|
"num": 32
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "32. Sht20 Влажность",
|
"name": "33. Sht20 Влажность",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Sht20h",
|
"subtype": "Sht20h",
|
||||||
"id": "Hum2",
|
"id": "Hum2",
|
||||||
@@ -476,11 +490,11 @@
|
|||||||
"descr": "Влажность",
|
"descr": "Влажность",
|
||||||
"int": 15,
|
"int": 15,
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 32
|
"num": 33
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "33. Sht30 Температура",
|
"name": "34. Sht30 Температура",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Sht30t",
|
"subtype": "Sht30t",
|
||||||
"id": "tmp30",
|
"id": "tmp30",
|
||||||
@@ -489,11 +503,11 @@
|
|||||||
"descr": "SHT30 Температура",
|
"descr": "SHT30 Температура",
|
||||||
"int": 15,
|
"int": 15,
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 33
|
"num": 34
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "34. Sht30 Влажность",
|
"name": "35. Sht30 Влажность",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Sht30h",
|
"subtype": "Sht30h",
|
||||||
"id": "Hum30",
|
"id": "Hum30",
|
||||||
@@ -502,12 +516,12 @@
|
|||||||
"descr": "SHT30 Влажность",
|
"descr": "SHT30 Влажность",
|
||||||
"int": 15,
|
"int": 15,
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 34
|
"num": 35
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "35. HC-SR04 Ультразвуковой дальномер",
|
"name": "36. HC-SR04 Ультразвуковой дальномер",
|
||||||
"num": 35,
|
"num": 36,
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Sonar",
|
"subtype": "Sonar",
|
||||||
"id": "sonar",
|
"id": "sonar",
|
||||||
@@ -519,7 +533,7 @@
|
|||||||
"int": 5
|
"int": 5
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "36. UART",
|
"name": "37. UART",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "UART",
|
"subtype": "UART",
|
||||||
"page": "",
|
"page": "",
|
||||||
@@ -531,14 +545,14 @@
|
|||||||
"line": 2,
|
"line": 2,
|
||||||
"speed": 9600,
|
"speed": 9600,
|
||||||
"eventFormat": 0,
|
"eventFormat": 0,
|
||||||
"num": 36
|
"num": 37
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"header": "Исполнительные устройства"
|
"header": "Исполнительные устройства"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "37. Кнопка подключенная к пину",
|
"name": "38. Кнопка подключенная к пину",
|
||||||
"type": "Writing",
|
"type": "Writing",
|
||||||
"subtype": "ButtonIn",
|
"subtype": "ButtonIn",
|
||||||
"id": "btn",
|
"id": "btn",
|
||||||
@@ -552,11 +566,11 @@
|
|||||||
"pinMode": "INPUT",
|
"pinMode": "INPUT",
|
||||||
"debounceDelay": 50,
|
"debounceDelay": 50,
|
||||||
"fixState": 0,
|
"fixState": 0,
|
||||||
"num": 37
|
"num": 38
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "38. Управление пином",
|
"name": "39. Управление пином",
|
||||||
"type": "Writing",
|
"type": "Writing",
|
||||||
"subtype": "ButtonOut",
|
"subtype": "ButtonOut",
|
||||||
"needSave": 0,
|
"needSave": 0,
|
||||||
@@ -567,11 +581,11 @@
|
|||||||
"int": 0,
|
"int": 0,
|
||||||
"inv": 0,
|
"inv": 0,
|
||||||
"pin": 2,
|
"pin": 2,
|
||||||
"num": 38
|
"num": 39
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "39. Сервопривод",
|
"name": "40. Сервопривод",
|
||||||
"type": "Writing",
|
"type": "Writing",
|
||||||
"subtype": "IoTServo",
|
"subtype": "IoTServo",
|
||||||
"id": "servo",
|
"id": "servo",
|
||||||
@@ -582,11 +596,11 @@
|
|||||||
"pin": 12,
|
"pin": 12,
|
||||||
"apin": -1,
|
"apin": -1,
|
||||||
"amap": "0, 4096, 0, 180",
|
"amap": "0, 4096, 0, 180",
|
||||||
"num": 39
|
"num": 40
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "40. Расширитель портов Mcp23017",
|
"name": "41. Расширитель портов Mcp23017",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Mcp23017",
|
"subtype": "Mcp23017",
|
||||||
"id": "Mcp",
|
"id": "Mcp",
|
||||||
@@ -596,11 +610,11 @@
|
|||||||
"int": "0",
|
"int": "0",
|
||||||
"addr": "0x20",
|
"addr": "0x20",
|
||||||
"index": 1,
|
"index": 1,
|
||||||
"num": 40
|
"num": 41
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "41. MP3 плеер",
|
"name": "42. MP3 плеер",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Mp3",
|
"subtype": "Mp3",
|
||||||
"id": "mp3",
|
"id": "mp3",
|
||||||
@@ -610,11 +624,11 @@
|
|||||||
"int": 1,
|
"int": 1,
|
||||||
"pins": "14,12",
|
"pins": "14,12",
|
||||||
"volume": 20,
|
"volume": 20,
|
||||||
"num": 41
|
"num": 42
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "42. Сенсорная кнопка",
|
"name": "43. Сенсорная кнопка",
|
||||||
"type": "Writing",
|
"type": "Writing",
|
||||||
"subtype": "Multitouch",
|
"subtype": "Multitouch",
|
||||||
"id": "impulse",
|
"id": "impulse",
|
||||||
@@ -628,11 +642,11 @@
|
|||||||
"pinMode": "INPUT",
|
"pinMode": "INPUT",
|
||||||
"debounceDelay": 50,
|
"debounceDelay": 50,
|
||||||
"PWMDelay": 500,
|
"PWMDelay": 500,
|
||||||
"num": 42
|
"num": 43
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "43. Расширитель портов Pcf8574",
|
"name": "44. Расширитель портов Pcf8574",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Pcf8574",
|
"subtype": "Pcf8574",
|
||||||
"id": "Pcf",
|
"id": "Pcf",
|
||||||
@@ -642,11 +656,11 @@
|
|||||||
"int": "0",
|
"int": "0",
|
||||||
"addr": "0x20",
|
"addr": "0x20",
|
||||||
"index": 1,
|
"index": 1,
|
||||||
"num": 43
|
"num": 44
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "44. PWM ESP8266",
|
"name": "45. PWM ESP8266",
|
||||||
"type": "Writing",
|
"type": "Writing",
|
||||||
"subtype": "Pwm8266",
|
"subtype": "Pwm8266",
|
||||||
"id": "pwm",
|
"id": "pwm",
|
||||||
@@ -658,11 +672,11 @@
|
|||||||
"freq": 5000,
|
"freq": 5000,
|
||||||
"val": 0,
|
"val": 0,
|
||||||
"apin": -1,
|
"apin": -1,
|
||||||
"num": 44
|
"num": 45
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "45. Телеграм-Лайт",
|
"name": "46. Телеграм-Лайт",
|
||||||
"type": "Writing",
|
"type": "Writing",
|
||||||
"subtype": "TelegramLT",
|
"subtype": "TelegramLT",
|
||||||
"id": "tg",
|
"id": "tg",
|
||||||
@@ -671,14 +685,14 @@
|
|||||||
"descr": "",
|
"descr": "",
|
||||||
"token": "",
|
"token": "",
|
||||||
"chatID": "",
|
"chatID": "",
|
||||||
"num": 45
|
"num": 46
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"header": "Экраны"
|
"header": "Экраны"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "46. LCD экран 2004",
|
"name": "47. LCD экран 2004",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Lcd2004",
|
"subtype": "Lcd2004",
|
||||||
"id": "Lcd",
|
"id": "Lcd",
|
||||||
@@ -690,10 +704,10 @@
|
|||||||
"size": "20,4",
|
"size": "20,4",
|
||||||
"coord": "0,0",
|
"coord": "0,0",
|
||||||
"id2show": "id датчика",
|
"id2show": "id датчика",
|
||||||
"num": 46
|
"num": 47
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "47. LCD экран 1602",
|
"name": "48. LCD экран 1602",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Lcd2004",
|
"subtype": "Lcd2004",
|
||||||
"id": "Lcd",
|
"id": "Lcd",
|
||||||
@@ -705,6 +719,6 @@
|
|||||||
"size": "16,2",
|
"size": "16,2",
|
||||||
"coord": "0,0",
|
"coord": "0,0",
|
||||||
"id2show": "id датчика",
|
"id2show": "id датчика",
|
||||||
"num": 47
|
"num": 48
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -50,9 +50,17 @@
|
|||||||
"path": "src/modules/virtual/Variable",
|
"path": "src/modules/virtual/Variable",
|
||||||
"active": true
|
"active": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "src/modules/virtual/VariableColor",
|
||||||
|
"active": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "src/modules/virtual/VButton",
|
"path": "src/modules/virtual/VButton",
|
||||||
"active": true
|
"active": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "src/modules/virtual/Weather",
|
||||||
|
"active": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Сенсоры": [
|
"Сенсоры": [
|
||||||
@@ -182,6 +190,10 @@
|
|||||||
"path": "src/modules/exec/IoTServo",
|
"path": "src/modules/exec/IoTServo",
|
||||||
"active": true
|
"active": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "src/modules/exec/Mcp23008",
|
||||||
|
"active": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "src/modules/exec/Mcp23017",
|
"path": "src/modules/exec/Mcp23017",
|
||||||
"active": true
|
"active": true
|
||||||
|
|||||||
@@ -264,6 +264,7 @@ build_src_filter =
|
|||||||
+<modules/virtual/LogingDaily>
|
+<modules/virtual/LogingDaily>
|
||||||
+<modules/virtual/Timer>
|
+<modules/virtual/Timer>
|
||||||
+<modules/virtual/Variable>
|
+<modules/virtual/Variable>
|
||||||
|
+<modules/virtual/VariableColor>
|
||||||
+<modules/virtual/VButton>
|
+<modules/virtual/VButton>
|
||||||
+<modules/sensors/Acs712>
|
+<modules/sensors/Acs712>
|
||||||
+<modules/sensors/AhtXX>
|
+<modules/sensors/AhtXX>
|
||||||
|
|||||||
@@ -110,8 +110,8 @@ void mqttSubscribe() {
|
|||||||
mqtt.subscribe((mqttRootDevice + "/update").c_str());
|
mqtt.subscribe((mqttRootDevice + "/update").c_str());
|
||||||
|
|
||||||
if (jsonReadBool(settingsFlashJson, "mqttin")) {
|
if (jsonReadBool(settingsFlashJson, "mqttin")) {
|
||||||
mqtt.subscribe((mqttPrefix + "/+/+/event").c_str());
|
mqtt.subscribe((mqttPrefix + "/+/+/event/#").c_str());
|
||||||
mqtt.subscribe((mqttPrefix + "/+/+/order").c_str());
|
mqtt.subscribe((mqttPrefix + "/+/+/order/#").c_str());
|
||||||
mqtt.subscribe((mqttPrefix + "/+/+/info").c_str());
|
mqtt.subscribe((mqttPrefix + "/+/+/info").c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ void* getAPI_Loging(String subtype, String params);
|
|||||||
void* getAPI_LogingDaily(String subtype, String params);
|
void* getAPI_LogingDaily(String subtype, String params);
|
||||||
void* getAPI_Timer(String subtype, String params);
|
void* getAPI_Timer(String subtype, String params);
|
||||||
void* getAPI_Variable(String subtype, String params);
|
void* getAPI_Variable(String subtype, String params);
|
||||||
|
void* getAPI_VariableColor(String subtype, String params);
|
||||||
void* getAPI_VButton(String subtype, String params);
|
void* getAPI_VButton(String subtype, String params);
|
||||||
void* getAPI_Acs712(String subtype, String params);
|
void* getAPI_Acs712(String subtype, String params);
|
||||||
void* getAPI_AhtXX(String subtype, String params);
|
void* getAPI_AhtXX(String subtype, String params);
|
||||||
@@ -36,6 +37,7 @@ if ((tmpAPI = getAPI_Loging(subtype, params)) != nullptr) return tmpAPI;
|
|||||||
if ((tmpAPI = getAPI_LogingDaily(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_LogingDaily(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_Timer(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Timer(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_Variable(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Variable(subtype, params)) != nullptr) return tmpAPI;
|
||||||
|
if ((tmpAPI = getAPI_VariableColor(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_VButton(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_VButton(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_Acs712(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Acs712(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_AhtXX(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_AhtXX(subtype, params)) != nullptr) return tmpAPI;
|
||||||
|
|||||||
133
src/modules/sensors/ExternalMQTT/ExternalMQTT.cpp
Normal file
133
src/modules/sensors/ExternalMQTT/ExternalMQTT.cpp
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
#include "Global.h"
|
||||||
|
#include "classes/IoTItem.h"
|
||||||
|
|
||||||
|
class ExternalMQTT : public IoTItem
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
String _MAC;
|
||||||
|
String _sensor;
|
||||||
|
IoTItem *tmp;
|
||||||
|
int _minutesPassed = 0;
|
||||||
|
String json = "{}";
|
||||||
|
int orange = 0;
|
||||||
|
int red = 0;
|
||||||
|
int offline = 0;
|
||||||
|
bool dataFromNode = false;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ExternalMQTT(String parameters) : IoTItem(parameters)
|
||||||
|
{
|
||||||
|
_MAC = jsonReadStr(parameters, "MAC");
|
||||||
|
_sensor = jsonReadStr(parameters, "sensor");
|
||||||
|
jsonRead(parameters, F("orange"), orange);
|
||||||
|
jsonRead(parameters, F("red"), red);
|
||||||
|
jsonRead(parameters, F("offline"), offline);
|
||||||
|
dataFromNode = false;
|
||||||
|
}
|
||||||
|
char *TimeToString(unsigned long t)
|
||||||
|
{
|
||||||
|
static char str[12];
|
||||||
|
long h = t / 3600;
|
||||||
|
t = t % 3600;
|
||||||
|
int m = t / 60;
|
||||||
|
int s = t % 60;
|
||||||
|
sprintf(str, "%02ld:%02d:%02d", h, m, s);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
void onMqttRecive(String &topic, String &msg)
|
||||||
|
{
|
||||||
|
if (msg.indexOf("HELLO") == -1)
|
||||||
|
{
|
||||||
|
|
||||||
|
// SerialPrint("i", "onMqttRecive", "Прилетело " + topic);
|
||||||
|
// SerialPrint("i", "onMqttRecive", "Прилетело " + msg);
|
||||||
|
String dev = selectToMarkerLast(topic, "/");
|
||||||
|
dev.toUpperCase();
|
||||||
|
dev.replace(":", "");
|
||||||
|
if (_MAC == "")
|
||||||
|
{
|
||||||
|
SerialPrint("i", "onMqttRecive", dev + " --> " + msg);
|
||||||
|
}
|
||||||
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
|
DeserializationError error = deserializeJson(doc, msg);
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
SerialPrint("E", F("onMqttRecive"), error.f_str());
|
||||||
|
}
|
||||||
|
JsonObject jsonObject = doc.as<JsonObject>();
|
||||||
|
|
||||||
|
for (JsonPair kv : jsonObject)
|
||||||
|
{
|
||||||
|
String key = kv.key().c_str();
|
||||||
|
String val = kv.value();
|
||||||
|
if (_MAC == dev && _sensor == key)
|
||||||
|
{
|
||||||
|
dataFromNode = true;
|
||||||
|
_minutesPassed = 0;
|
||||||
|
setValue(val);
|
||||||
|
// setNewWidgetAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Serial.println("Key: " + key);
|
||||||
|
// Serial.println("Value: " + val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void doByInterval()
|
||||||
|
{
|
||||||
|
_minutesPassed++;
|
||||||
|
setNewWidgetAttributes();
|
||||||
|
}
|
||||||
|
void onMqttWsAppConnectEvent()
|
||||||
|
{
|
||||||
|
setNewWidgetAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setNewWidgetAttributes()
|
||||||
|
{
|
||||||
|
|
||||||
|
jsonWriteStr(json, F("info"), prettyMinutsTimeout(_minutesPassed));
|
||||||
|
if (dataFromNode)
|
||||||
|
{
|
||||||
|
if (orange != 0 && red != 0 && offline != 0)
|
||||||
|
{
|
||||||
|
if (_minutesPassed < orange)
|
||||||
|
{
|
||||||
|
jsonWriteStr(json, F("color"), "");
|
||||||
|
}
|
||||||
|
if (_minutesPassed >= orange && _minutesPassed < red)
|
||||||
|
{
|
||||||
|
jsonWriteStr(json, F("color"), F("orange")); // сделаем виджет оранжевым
|
||||||
|
}
|
||||||
|
if (_minutesPassed >= red && _minutesPassed < offline)
|
||||||
|
{
|
||||||
|
jsonWriteStr(json, F("color"), F("red")); // сделаем виджет красным
|
||||||
|
}
|
||||||
|
if (_minutesPassed >= offline)
|
||||||
|
{
|
||||||
|
jsonWriteStr(json, F("info"), F("offline"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
jsonWriteStr(json, F("info"), F("awaiting"));
|
||||||
|
}
|
||||||
|
sendSubWidgetsValues(_id, json);
|
||||||
|
}
|
||||||
|
|
||||||
|
~ExternalMQTT(){};
|
||||||
|
};
|
||||||
|
|
||||||
|
void *getAPI_ExternalMQTT(String subtype, String param)
|
||||||
|
{
|
||||||
|
if (subtype == F("ExternalMQTT"))
|
||||||
|
{
|
||||||
|
return new ExternalMQTT(param);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
58
src/modules/sensors/ExternalMQTT/modinfo.json
Normal file
58
src/modules/sensors/ExternalMQTT/modinfo.json
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
{
|
||||||
|
"menuSection": "Сенсоры",
|
||||||
|
|
||||||
|
"configItem": [
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "MQTT парсер",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "ExternalMQTT",
|
||||||
|
"id": "MQTTin",
|
||||||
|
"widget": "",
|
||||||
|
"page": "",
|
||||||
|
"descr": "",
|
||||||
|
"MAC": "",
|
||||||
|
"sensor": "",
|
||||||
|
"round": "",
|
||||||
|
"orange": 60,
|
||||||
|
"red": 120,
|
||||||
|
"offline": 180,
|
||||||
|
"int": 60
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
"about": {
|
||||||
|
"authorName": "AVAKS",
|
||||||
|
"authorContact": "https://t.me/@avaks_dev",
|
||||||
|
"authorGit": "https://github.com/avaksru",
|
||||||
|
"specialThanks": "",
|
||||||
|
"moduleName": "ExternalMQTT",
|
||||||
|
"moduleVersion": "1",
|
||||||
|
"usedRam": {
|
||||||
|
"esp32_4mb": 15,
|
||||||
|
"esp8266_4mb": 15
|
||||||
|
},
|
||||||
|
"title": "ExternalMQTT",
|
||||||
|
"moduleDesc": "Модуль получения данных из OpenMQTTGateway, Zigbee2MQTT, SLS, Tasmota, NodeRead, HA, openHAB, Fhem, domotiz, EEdom",
|
||||||
|
"propInfo": {
|
||||||
|
"round": "Округление после запятой.",
|
||||||
|
"int": "Интервал для изменения цвета",
|
||||||
|
"orange": "количество минут после которого окрасить виджет в оранжевый цвет",
|
||||||
|
"red": "количество минут после которого окрасить виджет в красный цвет",
|
||||||
|
"offline": "количество минут после которого отобразить что устройство offline, если все три orange red и offline поставить в ноль - то функция окраски выключится",
|
||||||
|
"MAC": "MAC адрес беспроводного датчика",
|
||||||
|
"sensor": "Тип сенсора: температура / влажность / время / ... "
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"defActive": false,
|
||||||
|
|
||||||
|
"usedLibs": {
|
||||||
|
"esp32_4mb": [],
|
||||||
|
"esp8266_4mb": [],
|
||||||
|
"esp8266_1mb": [],
|
||||||
|
"esp8266_1mb_ota": [],
|
||||||
|
"esp8285_1mb": [],
|
||||||
|
"esp8285_1mb_ota": []
|
||||||
|
}
|
||||||
|
}
|
||||||
46
src/modules/virtual/VariableColor/VariableColor.cpp
Normal file
46
src/modules/virtual/VariableColor/VariableColor.cpp
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
#include "Global.h"
|
||||||
|
#include "classes/IoTItem.h"
|
||||||
|
|
||||||
|
// дочь - родитель
|
||||||
|
class VariableColor : public IoTItem
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
public:
|
||||||
|
VariableColor(String parameters) : IoTItem(parameters)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void doByInterval()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// событие когда пользователь подключается приложением или веб интерфейсом к усройству
|
||||||
|
void onMqttWsAppConnectEvent()
|
||||||
|
{
|
||||||
|
SerialPrint("i", "Connecting", "Dashbord open ");
|
||||||
|
regEvent(value.valS, "VariableColor", false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
IoTValue execute(String command, std::vector<IoTValue> ¶m)
|
||||||
|
{
|
||||||
|
if (command == "widget" && param.size() == 2)
|
||||||
|
{
|
||||||
|
String json = "{}";
|
||||||
|
jsonWriteStr(json, param[0].valS, param[1].valS);
|
||||||
|
sendSubWidgetsValues(_id, json);
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void *getAPI_VariableColor(String subtype, String param)
|
||||||
|
{
|
||||||
|
if (subtype == F("VariableColor"))
|
||||||
|
{
|
||||||
|
return new VariableColor(param);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
46
src/modules/virtual/VariableColor/modinfo.json
Normal file
46
src/modules/virtual/VariableColor/modinfo.json
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"menuSection": "Виртуальные элементы",
|
||||||
|
"configItem": [
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "Цветной текст",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "VariableColor",
|
||||||
|
"id": "color",
|
||||||
|
"needSave": 0,
|
||||||
|
"widget": "anydataDef",
|
||||||
|
"page": "Вывод",
|
||||||
|
"descr": "Цветной текст",
|
||||||
|
"val": "...",
|
||||||
|
"round": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"about": {
|
||||||
|
"authorName": "AVAKS",
|
||||||
|
"authorContact": "https://t.me/@avaks_dev",
|
||||||
|
"authorGit": "https://github.com/avaksru",
|
||||||
|
"specialThanks": "",
|
||||||
|
"moduleName": "VariableColor",
|
||||||
|
"moduleVersion": "1",
|
||||||
|
"usedRam": {
|
||||||
|
"esp32_4mb": 15,
|
||||||
|
"esp8266_4mb": 15
|
||||||
|
},
|
||||||
|
"title": "Цветной текст",
|
||||||
|
"moduleDesc": "Текст с возможностью динамического изменения цвета",
|
||||||
|
"propInfo": {
|
||||||
|
"val": "Значение при старте"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"defActive": true,
|
||||||
|
|
||||||
|
"usedLibs": {
|
||||||
|
"esp32_4mb": [],
|
||||||
|
"esp8266_4mb": [],
|
||||||
|
"esp8266_1mb": [],
|
||||||
|
"esp8266_1mb_ota": [],
|
||||||
|
"esp8285_1mb": [],
|
||||||
|
"esp8285_1mb_ota": []
|
||||||
|
}
|
||||||
|
}
|
||||||
153
src/modules/virtual/Weather/Weather.cpp
Normal file
153
src/modules/virtual/Weather/Weather.cpp
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
#include "Global.h"
|
||||||
|
#include "classes/IoTItem.h"
|
||||||
|
#include <ArduinoJson.h>
|
||||||
|
|
||||||
|
long prevWeatherMillis = millis() - 60001;
|
||||||
|
StaticJsonDocument<JSON_BUFFER_SIZE * 2> Weatherdoc;
|
||||||
|
|
||||||
|
extern IoTGpio IoTgpio;
|
||||||
|
class Weather : public IoTItem
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
String _location;
|
||||||
|
String _param;
|
||||||
|
long interval;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Weather(String parameters) : IoTItem(parameters)
|
||||||
|
{
|
||||||
|
_location = jsonReadStr(parameters, "location");
|
||||||
|
_param = jsonReadStr(parameters, "param");
|
||||||
|
jsonRead(parameters, F("int"), interval);
|
||||||
|
interval = interval * 1000 * 60 * 60; // интервал проверки погоды в часах
|
||||||
|
}
|
||||||
|
|
||||||
|
void getWeather()
|
||||||
|
{
|
||||||
|
String ret;
|
||||||
|
|
||||||
|
if (WiFi.status() == WL_CONNECTED)
|
||||||
|
{
|
||||||
|
// char c;
|
||||||
|
String payload;
|
||||||
|
WiFiClient client;
|
||||||
|
HTTPClient http;
|
||||||
|
http.begin(client, "http://live-control.com/iotm/weather.php");
|
||||||
|
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
String httpRequestData = "loc=" + _location;
|
||||||
|
int httpResponseCode = http.POST(httpRequestData);
|
||||||
|
if (httpResponseCode > 0)
|
||||||
|
{
|
||||||
|
ret = httpResponseCode;
|
||||||
|
|
||||||
|
if (httpResponseCode == HTTP_CODE_OK)
|
||||||
|
{
|
||||||
|
payload = http.getString();
|
||||||
|
|
||||||
|
deserializeJson(Weatherdoc, payload);
|
||||||
|
// ret += payload;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = http.errorToString(httpResponseCode).c_str();
|
||||||
|
}
|
||||||
|
SerialPrint("<-", F("getWeather"), httpRequestData);
|
||||||
|
SerialPrint("->", F("getWeather"), "server: " + ret);
|
||||||
|
|
||||||
|
http.end();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void doByInterval()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (prevWeatherMillis + 60000 < millis())
|
||||||
|
{
|
||||||
|
getWeather();
|
||||||
|
prevWeatherMillis = millis();
|
||||||
|
}
|
||||||
|
if (jsonReadStr(Weatherdoc["current_condition"][0], "temp_C", true) != "null")
|
||||||
|
{
|
||||||
|
if (_param == "temp_C")
|
||||||
|
{
|
||||||
|
value.valS = jsonReadStr(Weatherdoc["current_condition"][0], "temp_C", true);
|
||||||
|
}
|
||||||
|
if (_param == "avgtempC")
|
||||||
|
{
|
||||||
|
value.valS = jsonReadStr(Weatherdoc["weather"][0], "avgtempC", true);
|
||||||
|
}
|
||||||
|
if (_param == "humidity")
|
||||||
|
{
|
||||||
|
value.valS = jsonReadStr(Weatherdoc["current_condition"][0], "humidity", true);
|
||||||
|
}
|
||||||
|
if (_param == "weatherCode")
|
||||||
|
{
|
||||||
|
value.valS = jsonReadStr(Weatherdoc["current_condition"][0], "weatherCode", true);
|
||||||
|
}
|
||||||
|
if (_param == "sunrise")
|
||||||
|
{
|
||||||
|
|
||||||
|
value.valS = jsonReadStr(Weatherdoc["weather"][0]["astronomy"][0], "sunrise", true);
|
||||||
|
}
|
||||||
|
if (_param == "sunset")
|
||||||
|
{
|
||||||
|
value.valS = jsonReadStr(Weatherdoc["weather"][0]["astronomy"][0], "sunset", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_param == "rangetempC")
|
||||||
|
{
|
||||||
|
value.valS = jsonReadStr(Weatherdoc["weather"][0], "mintempC", true) + "..." + jsonReadStr(Weatherdoc["weather"][0], "maxtempC", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// погода на завтра
|
||||||
|
if (_param == "temp_C_tomorrow")
|
||||||
|
{
|
||||||
|
value.valS = jsonReadStr(Weatherdoc["weather"][1], "avgtempC", true);
|
||||||
|
}
|
||||||
|
if (_param == "rangetempC_tomorrow")
|
||||||
|
{
|
||||||
|
value.valS = jsonReadStr(Weatherdoc["weather"][1], "mintempC", true) + "..." + jsonReadStr(Weatherdoc["weather"][1], "maxtempC", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
regEvent(value.valS, "Weather");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
if (enableDoByInt)
|
||||||
|
{
|
||||||
|
currentMillis = millis();
|
||||||
|
difference = currentMillis - prevMillis;
|
||||||
|
if (difference >= interval)
|
||||||
|
{
|
||||||
|
prevMillis = millis();
|
||||||
|
this->doByInterval();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IoTValue execute(String command, std::vector<IoTValue> ¶m)
|
||||||
|
{
|
||||||
|
if (command == "get")
|
||||||
|
{
|
||||||
|
getWeather();
|
||||||
|
doByInterval();
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
~Weather(){};
|
||||||
|
};
|
||||||
|
|
||||||
|
void *getAPI_Weather(String subtype, String param)
|
||||||
|
{
|
||||||
|
if (subtype == F("Weather"))
|
||||||
|
{
|
||||||
|
return new Weather(param);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
53
src/modules/virtual/Weather/modinfo.json
Normal file
53
src/modules/virtual/Weather/modinfo.json
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
{
|
||||||
|
"menuSection": "Виртуальные элементы",
|
||||||
|
|
||||||
|
"configItem": [
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "Погода",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "Weather",
|
||||||
|
"id": "Weather",
|
||||||
|
"needSave": 0,
|
||||||
|
"widget": "anydataDef",
|
||||||
|
"page": "Погода",
|
||||||
|
"descr": "",
|
||||||
|
"int": 3,
|
||||||
|
"location": "Moscow",
|
||||||
|
"param": "temp_C",
|
||||||
|
"round": 0,
|
||||||
|
"val": "..."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
"about": {
|
||||||
|
"authorName": "AVAKS",
|
||||||
|
"authorContact": "https://t.me/@avaks_dev",
|
||||||
|
"authorGit": "https://github.com/avaksru",
|
||||||
|
"specialThanks": "",
|
||||||
|
"moduleName": "Weather",
|
||||||
|
"moduleVersion": "1",
|
||||||
|
"usedRam": {
|
||||||
|
"esp32_4mb": 15,
|
||||||
|
"esp8266_4mb": 15
|
||||||
|
},
|
||||||
|
"title": "Погода",
|
||||||
|
"moduleDesc": "Получение погоды из интернет",
|
||||||
|
"propInfo": {
|
||||||
|
"location": "Город.",
|
||||||
|
"param": "temp_C - температура, humidity - влажность, weatherCode - погодный код, sunrise - рассвет, sunset - закат, rangetempC - (-3...-10 C), temp_C_tomorrow - температура завтра, rangetempC_tomorrow - (-3...-10 C) на завтра",
|
||||||
|
"int": "Интервал запроса погоды в часах"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"defActive": false,
|
||||||
|
|
||||||
|
"usedLibs": {
|
||||||
|
"esp32_4mb": [],
|
||||||
|
"esp8266_4mb": [],
|
||||||
|
"esp8266_1mb": [],
|
||||||
|
"esp8266_1mb_ota": [],
|
||||||
|
"esp8285_1mb": [],
|
||||||
|
"esp8285_1mb_ota": []
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user