Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

673 lines
21 KiB

7 years ago
7 years ago
7 years ago
  1. /*
  2. SENSOR MODULE
  3. Copyright (C) 2016-2017 by Xose Pérez <xose dot perez at gmail dot com>
  4. */
  5. #include <vector>
  6. #include "filters/MaxFilter.h"
  7. #include "filters/MedianFilter.h"
  8. #include "filters/MovingAverageFilter.h"
  9. #include "sensors/BaseSensor.h"
  10. typedef struct {
  11. BaseSensor * sensor;
  12. unsigned char local; // Local index in its provider
  13. magnitude_t type; // Type of measurement
  14. unsigned char global; // Global index in its type
  15. double current; // Current (last) value, unfiltered
  16. double filtered; // Filtered (averaged) value
  17. double reported; // Last reported value
  18. double min_change; // Minimum value change to report
  19. BaseFilter * filter; // Filter object
  20. } sensor_magnitude_t;
  21. std::vector<BaseSensor *> _sensors;
  22. std::vector<sensor_magnitude_t> _magnitudes;
  23. unsigned char _counts[MAGNITUDE_MAX];
  24. bool _sensor_realtime = API_REAL_TIME_VALUES;
  25. unsigned long _sensor_read_interval = 1000 * SENSOR_READ_INTERVAL;
  26. unsigned int _sensor_report_every = SENSOR_REPORT_EVERY;
  27. unsigned char _sensor_temperature_units = SENSOR_TEMPERATURE_UNITS;
  28. double _sensor_temperature_correction = SENSOR_TEMPERATURE_CORRECTION;
  29. // -----------------------------------------------------------------------------
  30. // Private
  31. // -----------------------------------------------------------------------------
  32. String _magnitudeTopic(magnitude_t type) {
  33. char buffer[16] = {0};
  34. if (type < MAGNITUDE_MAX) strncpy_P(buffer, magnitude_topics[type], sizeof(buffer));
  35. return String(buffer);
  36. }
  37. unsigned char _magnitudeDecimals(magnitude_t type) {
  38. if (type < MAGNITUDE_MAX) return pgm_read_byte(magnitude_decimals + type);
  39. return 0;
  40. }
  41. String _magnitudeUnits(magnitude_t type) {
  42. char buffer[8] = {0};
  43. if (type < MAGNITUDE_MAX) {
  44. if ((type == MAGNITUDE_TEMPERATURE) && (_sensor_temperature_units == TMP_FAHRENHEIT)) {
  45. strncpy_P(buffer, magnitude_fahrenheit, sizeof(buffer));
  46. } else {
  47. strncpy_P(buffer, magnitude_units[type], sizeof(buffer));
  48. }
  49. }
  50. return String(buffer);
  51. }
  52. double _magnitudeProcess(magnitude_t type, double value) {
  53. if (type == MAGNITUDE_TEMPERATURE) {
  54. if (_sensor_temperature_units == TMP_FAHRENHEIT) value = value * 1.8 + 32;
  55. value = value + _sensor_temperature_correction;
  56. }
  57. return roundTo(value, _magnitudeDecimals(type));
  58. }
  59. // -----------------------------------------------------------------------------
  60. #if WEB_SUPPORT
  61. void _sensorWebSocketSendData(JsonObject& root) {
  62. char buffer[10];
  63. bool hasTemperature = false;
  64. JsonArray& list = root.createNestedArray("magnitudes");
  65. for (unsigned char i=0; i<_magnitudes.size(); i++) {
  66. sensor_magnitude_t magnitude = _magnitudes[i];
  67. unsigned char decimals = _magnitudeDecimals(magnitude.type);
  68. dtostrf(magnitude.current, 1-sizeof(buffer), decimals, buffer);
  69. JsonObject& element = list.createNestedObject();
  70. element["index"] = int(magnitude.global);
  71. element["type"] = int(magnitude.type);
  72. element["value"] = String(buffer);
  73. element["units"] = _magnitudeUnits(magnitude.type);
  74. element["description"] = magnitude.sensor->slot(magnitude.local);
  75. element["error"] = magnitude.sensor->error();
  76. if (magnitude.type == MAGNITUDE_TEMPERATURE) hasTemperature = true;
  77. }
  78. if (hasTemperature) root["temperatureVisible"] = 1;
  79. }
  80. void _sensorWebSocketStart(JsonObject& root) {
  81. for (unsigned char i=0; i<_sensors.size(); i++) {
  82. BaseSensor * sensor = _sensors[i];
  83. #if EMON_ANALOG_SUPPORT
  84. if (sensor->getID() == SENSOR_EMON_ANALOG_ID) {
  85. root["emonVisible"] = 1;
  86. root["pwrVoltage"] = ((EmonAnalogSensor *) sensor)->getVoltage();
  87. }
  88. #endif
  89. #if HLW8012_SUPPORT
  90. if (sensor->getID() == SENSOR_HLW8012_ID) {
  91. root["hlwVisible"] = 1;
  92. }
  93. #endif
  94. }
  95. if (_magnitudes.size() > 0) {
  96. root["sensorsVisible"] = 1;
  97. //root["apiRealTime"] = _sensor_realtime;
  98. root["tmpUnits"] = _sensor_temperature_units;
  99. root["tmpCorrection"] = _sensor_temperature_correction;
  100. root["snsRead"] = _sensor_read_interval / 1000;
  101. root["snsReport"] = _sensor_report_every;
  102. }
  103. /*
  104. // Sensors manifest
  105. JsonArray& manifest = root.createNestedArray("manifest");
  106. #if BMX280_SUPPORT
  107. BMX280Sensor::manifest(manifest);
  108. #endif
  109. // Sensors configuration
  110. JsonArray& sensors = root.createNestedArray("sensors");
  111. for (unsigned char i; i<_sensors.size(); i++) {
  112. JsonObject& sensor = sensors.createNestedObject();
  113. sensor["index"] = i;
  114. sensor["id"] = _sensors[i]->getID();
  115. _sensors[i]->getConfig(sensor);
  116. }
  117. */
  118. }
  119. void _sensorAPISetup() {
  120. for (unsigned char magnitude_id=0; magnitude_id<_magnitudes.size(); magnitude_id++) {
  121. sensor_magnitude_t magnitude = _magnitudes[magnitude_id];
  122. String topic = _magnitudeTopic(magnitude.type);
  123. if (SENSOR_USE_INDEX || (_counts[magnitude.type] > 1)) topic = topic + "/" + String(magnitude.global);
  124. apiRegister(topic.c_str(), topic.c_str(), [magnitude_id](char * buffer, size_t len) {
  125. sensor_magnitude_t magnitude = _magnitudes[magnitude_id];
  126. unsigned char decimals = _magnitudeDecimals(magnitude.type);
  127. double value = _sensor_realtime ? magnitude.current : magnitude.filtered;
  128. dtostrf(value, 1-len, decimals, buffer);
  129. });
  130. }
  131. }
  132. #endif
  133. void _sensorTick() {
  134. for (unsigned char i=0; i<_sensors.size(); i++) {
  135. _sensors[i]->tick();
  136. }
  137. }
  138. void _sensorPre() {
  139. for (unsigned char i=0; i<_sensors.size(); i++) {
  140. _sensors[i]->pre();
  141. if (!_sensors[i]->status()) {
  142. DEBUG_MSG("[SENSOR] Error reading data from %s (error: %d)\n",
  143. _sensors[i]->description().c_str(),
  144. _sensors[i]->error()
  145. );
  146. }
  147. }
  148. }
  149. void _sensorPost() {
  150. for (unsigned char i=0; i<_sensors.size(); i++) {
  151. _sensors[i]->post();
  152. }
  153. }
  154. // -----------------------------------------------------------------------------
  155. // Sensor initialization
  156. // -----------------------------------------------------------------------------
  157. void _sensorInit() {
  158. #if ANALOG_SUPPORT
  159. {
  160. AnalogSensor * sensor = new AnalogSensor();
  161. _sensors.push_back(sensor);
  162. }
  163. #endif
  164. #if BMX280_SUPPORT
  165. {
  166. BMX280Sensor * sensor = new BMX280Sensor();
  167. sensor->setAddress(BMX280_ADDRESS);
  168. _sensors.push_back(sensor);
  169. }
  170. #endif
  171. #if DALLAS_SUPPORT
  172. {
  173. DallasSensor * sensor = new DallasSensor();
  174. sensor->setGPIO(DALLAS_PIN);
  175. _sensors.push_back(sensor);
  176. }
  177. #endif
  178. #if DHT_SUPPORT
  179. {
  180. DHTSensor * sensor = new DHTSensor();
  181. sensor->setGPIO(DHT_PIN);
  182. sensor->setType(DHT_TYPE);
  183. _sensors.push_back(sensor);
  184. }
  185. #endif
  186. #if DIGITAL_SUPPORT
  187. {
  188. DigitalSensor * sensor = new DigitalSensor();
  189. sensor->setGPIO(DIGITAL_PIN);
  190. sensor->setMode(DIGITAL_PIN_MODE);
  191. sensor->setDefault(DIGITAL_DEFAULT_STATE);
  192. _sensors.push_back(sensor);
  193. }
  194. #endif
  195. #if ECH1560_SUPPORT
  196. {
  197. ECH1560Sensor * sensor = new ECH1560Sensor();
  198. sensor->setCLK(ECH1560_CLK_PIN);
  199. sensor->setMISO(ECH1560_MISO_PIN);
  200. sensor->setInverted(ECH1560_INVERTED);
  201. _sensors.push_back(sensor);
  202. }
  203. #endif
  204. #if EMON_ADC121_SUPPORT
  205. {
  206. EmonADC121Sensor * sensor = new EmonADC121Sensor();
  207. sensor->setAddress(EMON_ADC121_I2C_ADDRESS);
  208. sensor->setVoltage(EMON_MAINS_VOLTAGE);
  209. sensor->setReference(EMON_REFERENCE_VOLTAGE);
  210. sensor->setCurrentRatio(0, EMON_CURRENT_RATIO);
  211. _sensors.push_back(sensor);
  212. }
  213. #endif
  214. #if EMON_ADS1X15_SUPPORT
  215. {
  216. EmonADS1X15Sensor * sensor = new EmonADS1X15Sensor();
  217. sensor->setAddress(EMON_ADS1X15_I2C_ADDRESS);
  218. sensor->setType(EMON_ADS1X15_TYPE);
  219. sensor->setMask(EMON_ADS1X15_MASK);
  220. sensor->setGain(EMON_ADS1X15_GAIN);
  221. sensor->setVoltage(EMON_MAINS_VOLTAGE);
  222. sensor->setCurrentRatio(0, EMON_CURRENT_RATIO);
  223. sensor->setCurrentRatio(1, EMON_CURRENT_RATIO);
  224. sensor->setCurrentRatio(2, EMON_CURRENT_RATIO);
  225. sensor->setCurrentRatio(3, EMON_CURRENT_RATIO);
  226. _sensors.push_back(sensor);
  227. }
  228. #endif
  229. #if EMON_ANALOG_SUPPORT
  230. {
  231. EmonAnalogSensor * sensor = new EmonAnalogSensor();
  232. sensor->setVoltage(EMON_MAINS_VOLTAGE);
  233. sensor->setReference(EMON_REFERENCE_VOLTAGE);
  234. sensor->setCurrentRatio(0, EMON_CURRENT_RATIO);
  235. _sensors.push_back(sensor);
  236. }
  237. #endif
  238. #if EVENTS_SUPPORT
  239. {
  240. EventSensor * sensor = new EventSensor();
  241. sensor->setGPIO(EVENTS_PIN);
  242. sensor->setMode(EVENTS_PIN_MODE);
  243. sensor->setDebounceTime(EVENTS_DEBOUNCE);
  244. sensor->setInterruptMode(EVENTS_INTERRUPT_MODE);
  245. _sensors.push_back(sensor);
  246. }
  247. #endif
  248. #if HLW8012_SUPPORT
  249. {
  250. HLW8012Sensor * sensor = new HLW8012Sensor();
  251. sensor->setSEL(HLW8012_SEL_PIN);
  252. sensor->setCF(HLW8012_CF_PIN);
  253. sensor->setCF1(HLW8012_CF1_PIN);
  254. sensor->setSELCurrent(HLW8012_SEL_CURRENT);
  255. _sensors.push_back(sensor);
  256. }
  257. #endif
  258. #if MHZ19_SUPPORT
  259. {
  260. MHZ19Sensor * sensor = new MHZ19Sensor();
  261. sensor->setRX(MHZ19_RX_PIN);
  262. sensor->setTX(MHZ19_TX_PIN);
  263. _sensors.push_back(sensor);
  264. }
  265. #endif
  266. #if PMSX003_SUPPORT
  267. {
  268. PMSX003Sensor * sensor = new PMSX003Sensor();
  269. sensor->setRX(PMS_RX_PIN);
  270. sensor->setTX(PMS_TX_PIN);
  271. _sensors.push_back(sensor);
  272. }
  273. #endif
  274. #if SHT3X_I2C_SUPPORT
  275. {
  276. SHT3XI2CSensor * sensor = new SHT3XI2CSensor();
  277. sensor->setAddress(SHT3X_I2C_ADDRESS);
  278. _sensors.push_back(sensor);
  279. }
  280. #endif
  281. #if SI7021_SUPPORT
  282. {
  283. SI7021Sensor * sensor = new SI7021Sensor();
  284. sensor->setAddress(SI7021_ADDRESS);
  285. _sensors.push_back(sensor);
  286. }
  287. #endif
  288. #if V9261F_SUPPORT
  289. {
  290. V9261FSensor * sensor = new V9261FSensor();
  291. sensor->setRX(V9261F_PIN);
  292. sensor->setInverted(V9261F_PIN_INVERSE);
  293. _sensors.push_back(sensor);
  294. }
  295. #endif
  296. }
  297. void _sensorConfigure() {
  298. double value;
  299. for (unsigned char i=0; i<_sensors.size(); i++) {
  300. #if EMON_ANALOG_SUPPORT
  301. if (_sensors[i]->getID() == SENSOR_EMON_ANALOG_ID) {
  302. EmonAnalogSensor * sensor = (EmonAnalogSensor *) _sensors[i];
  303. if (value = getSetting("pwrExpectedP", 0).toInt() == 0) {
  304. value = getSetting("pwrRatioC", EMON_CURRENT_RATIO).toFloat();
  305. if (value > 0) sensor->setCurrentRatio(0, value);
  306. } else {
  307. sensor->expectedPower(0, value);
  308. setSetting("pwrRatioC", sensor->getCurrentRatio(0));
  309. }
  310. if (getSetting("pwrResetCalibration", 0).toInt() == 1) {
  311. sensor->setCurrentRatio(0, EMON_CURRENT_RATIO);
  312. delSetting("pwrRatioC");
  313. }
  314. sensor->setVoltage(getSetting("pwrVoltage", EMON_MAINS_VOLTAGE).toInt());
  315. }
  316. #endif // EMON_ANALOG_SUPPORT
  317. // Force sensor to reload config
  318. _sensors[i]->begin();
  319. #if HLW8012_SUPPORT
  320. if (_sensors[i]->getID() == SENSOR_HLW8012_ID) {
  321. HLW8012Sensor * sensor = (HLW8012Sensor *) _sensors[i];
  322. if (value = getSetting("pwrExpectedC", 0).toFloat()) {
  323. sensor->expectedCurrent(value);
  324. setSetting("pwrRatioC", sensor->getCurrentRatio());
  325. } else {
  326. value = getSetting("pwrRatioC", 0).toFloat();
  327. if (value > 0) sensor->setCurrentRatio(value);
  328. }
  329. if (value = getSetting("pwrExpectedV", 0).toInt()) {
  330. sensor->expectedVoltage(value);
  331. setSetting("pwrRatioV", sensor->getVoltageRatio());
  332. } else {
  333. value = getSetting("pwrRatioV", 0).toFloat();
  334. if (value > 0) sensor->setVoltageRatio(value);
  335. }
  336. if (value = getSetting("pwrExpectedP", 0).toInt()) {
  337. sensor->expectedPower(value);
  338. setSetting("pwrRatioP", sensor->getPowerRatio());
  339. } else {
  340. value = getSetting("pwrRatioP", 0).toFloat();
  341. if (value > 0) sensor->setPowerRatio(value);
  342. }
  343. if (getSetting("pwrResetCalibration", 0).toInt() == 1) {
  344. sensor->resetRatios();
  345. delSetting("pwrRatioC");
  346. delSetting("pwrRatioV");
  347. delSetting("pwrRatioP");
  348. }
  349. }
  350. #endif // HLW8012_SUPPORT
  351. }
  352. // General sensor settings
  353. _sensor_read_interval = 1000 * constrain(getSetting("snsRead", SENSOR_READ_INTERVAL).toInt(), SENSOR_READ_MIN_INTERVAL, SENSOR_READ_MAX_INTERVAL);
  354. _sensor_report_every = constrain(getSetting("snsReport", SENSOR_REPORT_EVERY).toInt(), SENSOR_REPORT_MIN_EVERY, SENSOR_REPORT_MAX_EVERY);
  355. _sensor_realtime = getSetting("apiRealTime", API_REAL_TIME_VALUES).toInt() == 1;
  356. _sensor_temperature_units = getSetting("tmpUnits", SENSOR_TEMPERATURE_UNITS).toInt();
  357. _sensor_temperature_correction = getSetting("tmpCorrection", SENSOR_TEMPERATURE_CORRECTION).toFloat();
  358. // Save settings
  359. delSetting("pwrExpectedP");
  360. delSetting("pwrExpectedC");
  361. delSetting("pwrExpectedV");
  362. delSetting("pwrResetCalibration");
  363. //saveSettings();
  364. }
  365. void _magnitudesInit() {
  366. for (unsigned char i=0; i<_sensors.size(); i++) {
  367. BaseSensor * sensor = _sensors[i];
  368. DEBUG_MSG("[SENSOR] %s\n", sensor->description().c_str());
  369. if (sensor->error() != 0) DEBUG_MSG("[SENSOR] -> ERROR %d\n", sensor->error());
  370. for (unsigned char k=0; k<sensor->count(); k++) {
  371. magnitude_t type = sensor->type(k);
  372. sensor_magnitude_t new_magnitude;
  373. new_magnitude.sensor = sensor;
  374. new_magnitude.local = k;
  375. new_magnitude.type = type;
  376. new_magnitude.global = _counts[type];
  377. new_magnitude.current = 0;
  378. new_magnitude.filtered = 0;
  379. new_magnitude.reported = 0;
  380. new_magnitude.min_change = 0;
  381. if (type == MAGNITUDE_DIGITAL) {
  382. new_magnitude.filter = new MaxFilter();
  383. } else if (type == MAGNITUDE_EVENTS) {
  384. new_magnitude.filter = new MovingAverageFilter();
  385. } else {
  386. new_magnitude.filter = new MedianFilter();
  387. }
  388. _magnitudes.push_back(new_magnitude);
  389. DEBUG_MSG("[SENSOR] -> %s:%d\n", _magnitudeTopic(type).c_str(), _counts[type]);
  390. _counts[type] = _counts[type] + 1;
  391. }
  392. }
  393. }
  394. // -----------------------------------------------------------------------------
  395. // Public
  396. // -----------------------------------------------------------------------------
  397. unsigned char sensorCount() {
  398. return _sensors.size();
  399. }
  400. unsigned char magnitudeCount() {
  401. return _magnitudes.size();
  402. }
  403. String magnitudeName(unsigned char index) {
  404. if (index < _magnitudes.size()) {
  405. sensor_magnitude_t magnitude = _magnitudes[index];
  406. return magnitude.sensor->slot(magnitude.local);
  407. }
  408. return String();
  409. }
  410. unsigned char magnitudeType(unsigned char index) {
  411. if (index < _magnitudes.size()) {
  412. return int(_magnitudes[index].type);
  413. }
  414. return MAGNITUDE_NONE;
  415. }
  416. unsigned char magnitudeIndex(unsigned char index) {
  417. if (index < _magnitudes.size()) {
  418. return int(_magnitudes[index].global);
  419. }
  420. return 0;
  421. }
  422. // -----------------------------------------------------------------------------
  423. void sensorSetup() {
  424. // Load sensors
  425. _sensorInit();
  426. // Configure stored values
  427. _sensorConfigure();
  428. // Load magnitudes
  429. _magnitudesInit();
  430. #if WEB_SUPPORT
  431. // Websockets
  432. wsOnSendRegister(_sensorWebSocketStart);
  433. wsOnSendRegister(_sensorWebSocketSendData);
  434. wsOnAfterParseRegister(_sensorConfigure);
  435. // API
  436. _sensorAPISetup();
  437. #endif
  438. }
  439. void sensorLoop() {
  440. static unsigned long last_update = 0;
  441. static unsigned long report_count = 0;
  442. if (_magnitudes.size() == 0) return;
  443. // Tick hook
  444. _sensorTick();
  445. // Check if we should read new data
  446. if (millis() - last_update > _sensor_read_interval) {
  447. last_update = millis();
  448. report_count = (report_count + 1) % _sensor_report_every;
  449. double current;
  450. double filtered;
  451. char buffer[64];
  452. // Pre-read hook
  453. _sensorPre();
  454. // Get readings
  455. for (unsigned char i=0; i<_magnitudes.size(); i++) {
  456. sensor_magnitude_t magnitude = _magnitudes[i];
  457. if (magnitude.sensor->status()) {
  458. unsigned char decimals = _magnitudeDecimals(magnitude.type);
  459. current = magnitude.sensor->value(magnitude.local);
  460. magnitude.filter->add(current);
  461. // Special case
  462. if (magnitude.type == MAGNITUDE_EVENTS) current = magnitude.filter->result();
  463. current = _magnitudeProcess(magnitude.type, current);
  464. _magnitudes[i].current = current;
  465. // Debug
  466. #if SENSOR_DEBUG
  467. {
  468. dtostrf(current, 1-sizeof(buffer), decimals, buffer);
  469. DEBUG_MSG("[SENSOR] %s - %s: %s%s\n",
  470. magnitude.sensor->slot(magnitude.local).c_str(),
  471. _magnitudeTopic(magnitude.type).c_str(),
  472. buffer,
  473. _magnitudeUnits(magnitude.type).c_str()
  474. );
  475. }
  476. #endif // SENSOR_DEBUG
  477. // Time to report (we do it every _sensor_report_every readings)
  478. if (report_count == 0) {
  479. filtered = magnitude.filter->result();
  480. magnitude.filter->reset();
  481. filtered = _magnitudeProcess(magnitude.type, filtered);
  482. _magnitudes[i].filtered = filtered;
  483. // Check if there is a minimum change threshold to report
  484. if (fabs(filtered - magnitude.reported) >= magnitude.min_change) {
  485. _magnitudes[i].reported = filtered;
  486. dtostrf(filtered, 1-sizeof(buffer), decimals, buffer);
  487. #if MQTT_SUPPORT
  488. if (SENSOR_USE_INDEX || (_counts[magnitude.type] > 1)) {
  489. mqttSend(_magnitudeTopic(magnitude.type).c_str(), magnitude.global, buffer);
  490. } else {
  491. mqttSend(_magnitudeTopic(magnitude.type).c_str(), buffer);
  492. }
  493. #endif // MQTT_SUPPORT
  494. #if INFLUXDB_SUPPORT
  495. if (SENSOR_USE_INDEX || (_counts[magnitude.type] > 1)) {
  496. idbSend(_magnitudeTopic(magnitude.type).c_str(), magnitude.global, buffer);
  497. } else {
  498. idbSend(_magnitudeTopic(magnitude.type).c_str(), buffer);
  499. }
  500. #endif // INFLUXDB_SUPPORT
  501. #if DOMOTICZ_SUPPORT
  502. {
  503. char key[15];
  504. snprintf_P(key, sizeof(key), PSTR("dczMagnitude%d"), i);
  505. if (magnitude.type == MAGNITUDE_HUMIDITY) {
  506. int status;
  507. if (filtered > 70) {
  508. status = HUMIDITY_WET;
  509. } else if (filtered > 45) {
  510. status = HUMIDITY_COMFORTABLE;
  511. } else if (filtered > 30) {
  512. status = HUMIDITY_NORMAL;
  513. } else {
  514. status = HUMIDITY_DRY;
  515. }
  516. char status_buf[5];
  517. itoa(status, status_buf, 10);
  518. domoticzSend(key, buffer, status_buf);
  519. } else {
  520. domoticzSend(key, 0, buffer);
  521. }
  522. }
  523. #endif // DOMOTICZ_SUPPORT
  524. } // if (fabs(filtered - magnitude.reported) >= magnitude.min_change)
  525. } // if (report_count == 0)
  526. } // if (magnitude.sensor->status())
  527. } // for (unsigned char i=0; i<_magnitudes.size(); i++)
  528. // Post-read hook
  529. _sensorPost();
  530. #if WEB_SUPPORT
  531. wsSend(_sensorWebSocketSendData);
  532. #endif
  533. }
  534. }