mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 14:12:16 +03:00
Выводим данные mysensors на dashboard!!!
This commit is contained in:
@@ -616,19 +616,27 @@
|
||||
"name": "42. MySensorsGate",
|
||||
"type": "Reading",
|
||||
"subtype": "MySensorsGate",
|
||||
"id": "t",
|
||||
"widget": "anydataTmp",
|
||||
"page": "Сенсоры",
|
||||
"descr": "Температура",
|
||||
"map": "1,1024,1,100",
|
||||
"plus": 0,
|
||||
"multiply": 1,
|
||||
"round": 1,
|
||||
"id": "gt",
|
||||
"widget": "nil",
|
||||
"page": "",
|
||||
"descr": "",
|
||||
"num": 42
|
||||
},
|
||||
{
|
||||
"global": 0,
|
||||
"name": "43. Расширитель портов Pcf8574",
|
||||
"name": "43. MySensorsNode",
|
||||
"type": "Reading",
|
||||
"subtype": "MySensorsNode",
|
||||
"id": "nd",
|
||||
"widget": "anydataTmp",
|
||||
"page": "MySensors",
|
||||
"descr": "Температура",
|
||||
"round": 1,
|
||||
"num": 43
|
||||
},
|
||||
{
|
||||
"global": 0,
|
||||
"name": "44. Расширитель портов Pcf8574",
|
||||
"type": "Reading",
|
||||
"subtype": "Pcf8574",
|
||||
"id": "Pcf",
|
||||
@@ -638,11 +646,11 @@
|
||||
"int": "0",
|
||||
"addr": "0x20",
|
||||
"index": 1,
|
||||
"num": 43
|
||||
"num": 44
|
||||
},
|
||||
{
|
||||
"global": 0,
|
||||
"name": "44. PWM ESP32",
|
||||
"name": "45. PWM ESP32",
|
||||
"type": "Writing",
|
||||
"subtype": "Pwm32",
|
||||
"id": "pwm",
|
||||
@@ -656,11 +664,11 @@
|
||||
"PWM_resolution": 10,
|
||||
"val": 0,
|
||||
"apin": -1,
|
||||
"num": 44
|
||||
"num": 45
|
||||
},
|
||||
{
|
||||
"global": 0,
|
||||
"name": "45. Телеграм-Лайт",
|
||||
"name": "46. Телеграм-Лайт",
|
||||
"type": "Writing",
|
||||
"subtype": "TelegramLT",
|
||||
"id": "tg",
|
||||
@@ -669,14 +677,14 @@
|
||||
"descr": "",
|
||||
"token": "",
|
||||
"chatID": "",
|
||||
"num": 45
|
||||
"num": 46
|
||||
},
|
||||
{
|
||||
"header": "Экраны"
|
||||
},
|
||||
{
|
||||
"global": 0,
|
||||
"name": "46. LCD экран 2004",
|
||||
"name": "47. LCD экран 2004",
|
||||
"type": "Reading",
|
||||
"subtype": "Lcd2004",
|
||||
"id": "Lcd",
|
||||
@@ -688,10 +696,10 @@
|
||||
"size": "20,4",
|
||||
"coord": "0,0",
|
||||
"id2show": "id датчика",
|
||||
"num": 46
|
||||
"num": 47
|
||||
},
|
||||
{
|
||||
"name": "47. LCD экран 1602",
|
||||
"name": "48. LCD экран 1602",
|
||||
"type": "Reading",
|
||||
"subtype": "Lcd2004",
|
||||
"id": "Lcd",
|
||||
@@ -703,6 +711,6 @@
|
||||
"size": "16,2",
|
||||
"coord": "0,0",
|
||||
"id2show": "id датчика",
|
||||
"num": 47
|
||||
"num": 48
|
||||
}
|
||||
]
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
//Версия прошивки
|
||||
#define FIRMWARE_VERSION 433
|
||||
#define FIRMWARE_VERSION 434
|
||||
|
||||
#ifdef esp8266_1mb_ota
|
||||
#define FIRMWARE_NAME "esp8266_1mb_ota"
|
||||
|
||||
@@ -113,6 +113,8 @@ build_src_filter =
|
||||
${env:esp8266_4mb_fromitems.build_src_filter}
|
||||
|
||||
[env:esp32_4mb]
|
||||
upload_port = COM8
|
||||
monitor_port = COM8
|
||||
lib_deps =
|
||||
${common_env_data.lib_deps_external}
|
||||
${env:esp32_4mb_fromitems.lib_deps}
|
||||
|
||||
@@ -50,12 +50,8 @@ String parseToString(const MyMessage& message) {
|
||||
|
||||
class MySensorsGate : public IoTItem {
|
||||
private:
|
||||
int _pin;
|
||||
|
||||
public:
|
||||
MySensorsGate(String parameters) : IoTItem(parameters) {
|
||||
jsonRead(parameters, "pin", _pin);
|
||||
// init place
|
||||
SerialPrint("i", "MySensors", "Gate initialized");
|
||||
}
|
||||
|
||||
@@ -66,12 +62,6 @@ class MySensorsGate : public IoTItem {
|
||||
loopMySensorsExecute();
|
||||
}
|
||||
|
||||
void setValue(const IoTValue& Value, bool genEvent = true) {
|
||||
value = Value;
|
||||
// set value place
|
||||
regEvent(value.valD, "MySensorsGate", false, genEvent);
|
||||
}
|
||||
|
||||
~MySensorsGate(){};
|
||||
|
||||
void loopMySensorsExecute() {
|
||||
@@ -92,16 +82,10 @@ class MySensorsGate : public IoTItem {
|
||||
if (childSensorId == "255") {
|
||||
if (command == "3") { //это особое внутреннее сообщение
|
||||
if (type == "11") { //название ноды
|
||||
SerialPrint("i", "MySensors", "Node name: " + value);
|
||||
//*
|
||||
// publishAnyJsonKey("MySensors", "Node name:", value);
|
||||
// publishAnyJsonKeyWS("MySensors", "Node name:", value);
|
||||
SerialPrint("i", "MySensors", "===================== " + value + " =====================");
|
||||
}
|
||||
if (type == "12") { //версия ноды
|
||||
SerialPrint("i", "MySensors", "Node version: " + value);
|
||||
//*
|
||||
// publishAnyJsonKey("MySensors", "Node version: ", value);
|
||||
// publishAnyJsonKeyWS("MySensors", "Node version: ", value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -111,48 +95,29 @@ class MySensorsGate : public IoTItem {
|
||||
String widget;
|
||||
String descr;
|
||||
sensorType(type.toInt(), num, widget, descr);
|
||||
// if (jsonReadBool(settingsFlashJson, "gateAuto")) {
|
||||
// if (!isItemAdded(key)) {
|
||||
// addItemAuto(num, key, widget, descr);
|
||||
// descr.replace("#", " ");
|
||||
// SerialPrint("i", "MySensors", "Add new item: " + key + ": " + descr);
|
||||
// //*
|
||||
// //publishAnyJsonKey("MySensors", key, descr);
|
||||
// //publishAnyJsonKeyWS("MySensors", key, descr);
|
||||
//
|
||||
// } else {
|
||||
// descr.replace("#", " ");
|
||||
// SerialPrint("i", "MySensors", "Item already exist: " + key + ": " + descr);
|
||||
//
|
||||
// //*
|
||||
// //publishAnyJsonKey("MySensors", key, descr);
|
||||
// //publishAnyJsonKeyWS("MySensors", key, descr);
|
||||
// }
|
||||
//} else {
|
||||
|
||||
descr.replace("#", " ");
|
||||
SerialPrint("i", "MySensors", "Presentation: " + key + ": " + descr);
|
||||
|
||||
//*
|
||||
// publishAnyJsonKey("MySensors", key, descr);
|
||||
// publishAnyJsonKeyWS("MySensors", key, descr);
|
||||
//}
|
||||
}
|
||||
if (command == "1") { //это данные
|
||||
if (value != "") {
|
||||
if (presentBeenStarted) {
|
||||
presentBeenStarted = false;
|
||||
SerialPrint("i", "MySensors", "!!!Presentation of node: " + nodeId + " completed successfully!!!");
|
||||
// myNotAsyncActions->make(do_deviceInit);
|
||||
SerialPrint("i", "MySensors", "===================== " + nodeId + " =====================");
|
||||
}
|
||||
// if (mySensorNode != nullptr) {
|
||||
// for (unsigned int i = 0; i < mySensorNode->size(); i++) {
|
||||
// mySensorNode->at(i).onChange(value, key); //вызываем поочередно все экземпляры, там где подойдет там и выполнится
|
||||
// //*
|
||||
// publishAnyJsonKey("MySensors", key, value);
|
||||
// publishAnyJsonKeyWS("MySensors", key, value);
|
||||
// }
|
||||
// }
|
||||
SerialPrint("i", "MySensors", "node: " + nodeId + ", sensor: " + childSensorId + ", command: " + command + ", type: " + type + ", val: " + value);
|
||||
|
||||
String incommingID = nodeId + "-" + childSensorId;
|
||||
|
||||
bool found = false;
|
||||
|
||||
for (std::list<IoTItem*>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) {
|
||||
if ((*it)->getID() == incommingID) {
|
||||
found = true;
|
||||
(*it)->setValue(value, true);
|
||||
}
|
||||
}
|
||||
|
||||
SerialPrint("i", "MySensors", "node: " + nodeId + ", sensor: " + childSensorId + ", command: " + command + ", type: " + type + ", val: " + value + ", found: " + String(found));
|
||||
}
|
||||
}
|
||||
if (command == "2") { //это запрос значения переменной
|
||||
@@ -377,23 +342,33 @@ class MySensorsGate : public IoTItem {
|
||||
}
|
||||
};
|
||||
|
||||
class MySensorsNode : public IoTItem {
|
||||
private:
|
||||
public:
|
||||
MySensorsNode(String parameters) : IoTItem(parameters) {
|
||||
SerialPrint("i", "MySensors", "Node initialized");
|
||||
}
|
||||
|
||||
void setValue(const IoTValue& Value, bool genEvent = true) {
|
||||
value = Value;
|
||||
regEvent(value.valD, "MySensorsNode", false, genEvent);
|
||||
}
|
||||
|
||||
void doByInterval() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
||||
|
||||
~MySensorsNode(){};
|
||||
};
|
||||
|
||||
void* getAPI_MySensorsGate(String subtype, String param) {
|
||||
if (subtype == F("MySensorsGate")) {
|
||||
return new MySensorsGate(param);
|
||||
} else if (subtype == F("MySensorsNode")) {
|
||||
return new MySensorsNode(param);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
//для того что бы выключить оригинальный лог нужно перейти в файл библиотеки MyGatewayTransportSerial.cpp
|
||||
//и заккоментировать строку 36 MY_SERIALDEVICE.print(protocolMyMessage2Serial(message))
|
||||
|
||||
// boolean publishAnyJsonKeyWS(const String& topic, const String& key, const String& data) {
|
||||
// String path = mqttRootDevice + "/" + topic + "/status";
|
||||
// String json = "{}";
|
||||
// jsonWriteStr(json, key, data);
|
||||
// //добавляем топик, выводим в ws
|
||||
// String MyJson = json;
|
||||
// jsonWriteStr(MyJson, "topic", path);
|
||||
// ws.textAll(MyJson);
|
||||
// }
|
||||
@@ -28,7 +28,7 @@
|
||||
// в файле MyGatewayTransportSerial.cpp в строчке 35
|
||||
#define MY_GATEWAY_SERIAL
|
||||
|
||||
#define CHILD_ID 1
|
||||
//#define CHILD_ID 1
|
||||
|
||||
#include <MySensors.h>
|
||||
|
||||
|
||||
@@ -6,13 +6,20 @@
|
||||
"name": "MySensorsGate",
|
||||
"type": "Reading",
|
||||
"subtype": "MySensorsGate",
|
||||
"id": "t",
|
||||
"id": "gt",
|
||||
"widget": "nil",
|
||||
"page": "",
|
||||
"descr": ""
|
||||
},
|
||||
{
|
||||
"global": 0,
|
||||
"name": "MySensorsNode",
|
||||
"type": "Reading",
|
||||
"subtype": "MySensorsNode",
|
||||
"id": "nd",
|
||||
"widget": "anydataTmp",
|
||||
"page": "Сенсоры",
|
||||
"page": "MySensors",
|
||||
"descr": "Температура",
|
||||
"map": "1,1024,1,100",
|
||||
"plus": 0,
|
||||
"multiply": 1,
|
||||
"round": 1
|
||||
}
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user