Controller.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. "use strict";
  2. var __assign = (this && this.__assign) || function () {
  3. __assign = Object.assign || function(t) {
  4. for (var s, i = 1, n = arguments.length; i < n; i++) {
  5. s = arguments[i];
  6. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  7. t[p] = s[p];
  8. }
  9. return t;
  10. };
  11. return __assign.apply(this, arguments);
  12. };
  13. var __importDefault = (this && this.__importDefault) || function (mod) {
  14. return (mod && mod.__esModule) ? mod : { "default": mod };
  15. };
  16. Object.defineProperty(exports, "__esModule", { value: true });
  17. var lodash_1 = __importDefault(require("lodash"));
  18. var CloudDeviceController_1 = __importDefault(require("./CloudDeviceController"));
  19. var CloudSwitchController_1 = __importDefault(require("./CloudSwitchController"));
  20. var CloudTandHModificationController_1 = __importDefault(require("./CloudTandHModificationController"));
  21. var DiyDeviceController_1 = __importDefault(require("./DiyDeviceController"));
  22. var dataUtil_1 = require("../utils/dataUtil");
  23. var LanDeviceController_1 = __importDefault(require("./LanDeviceController"));
  24. var CloudRGBBulbController_1 = __importDefault(require("./CloudRGBBulbController"));
  25. var CloudPowerDetectionSwitchController_1 = __importDefault(require("./CloudPowerDetectionSwitchController"));
  26. var CloudMultiChannelSwitchController_1 = __importDefault(require("./CloudMultiChannelSwitchController"));
  27. var CloudRGBLightStripController_1 = __importDefault(require("./CloudRGBLightStripController"));
  28. var formatLanDevice_1 = __importDefault(require("../utils/formatLanDevice"));
  29. var LanSwitchController_1 = __importDefault(require("./LanSwitchController"));
  30. var LanMultiChannelSwitchController_1 = __importDefault(require("./LanMultiChannelSwitchController"));
  31. var uiid_1 = require("../config/uiid");
  32. var CloudDoubleColorBulbController_1 = __importDefault(require("./CloudDoubleColorBulbController"));
  33. var UnsupportDeviceController_1 = __importDefault(require("./UnsupportDeviceController"));
  34. var CloudDualR3Controller_1 = __importDefault(require("./CloudDualR3Controller"));
  35. var LanDualR3Controller_1 = __importDefault(require("./LanDualR3Controller"));
  36. var LanTandHModificationController_1 = __importDefault(require("./LanTandHModificationController"));
  37. var LanPowerDetectionSwitchController_1 = __importDefault(require("./LanPowerDetectionSwitchController"));
  38. var CloudDW2WiFiController_1 = __importDefault(require("./CloudDW2WiFiController"));
  39. var CloudUIID104Controller_1 = __importDefault(require("./CloudUIID104Controller"));
  40. var CloudZigbeeUIID1770Controller_1 = __importDefault(require("./CloudZigbeeUIID1770Controller"));
  41. var CloudZigbeeUIID2026Controller_1 = __importDefault(require("./CloudZigbeeUIID2026Controller"));
  42. var CloudZigbeeUIID3026Controller_1 = __importDefault(require("./CloudZigbeeUIID3026Controller"));
  43. var CloudZigbeeUIID4026Controller_1 = __importDefault(require("./CloudZigbeeUIID4026Controller"));
  44. var CloudZigbeeUIID1000Controller_1 = __importDefault(require("./CloudZigbeeUIID1000Controller"));
  45. var mergeDeviceParams_1 = __importDefault(require("../utils/mergeDeviceParams"));
  46. var CloudCoverController_1 = __importDefault(require("./CloudCoverController"));
  47. var CloudRFBridgeController_1 = __importDefault(require("./CloudRFBridgeController"));
  48. var LanRFBridgeController_1 = __importDefault(require("./LanRFBridgeController"));
  49. var CloudUIID44Controller_1 = __importDefault(require("./CloudUIID44Controller"));
  50. var CloudUIID34Controller_1 = __importDefault(require("./CloudUIID34Controller"));
  51. var LanUIID34Controller_1 = __importDefault(require("./LanUIID34Controller"));
  52. var ELanType_1 = __importDefault(require("../ts/enum/ELanType"));
  53. var CloudNSPanelController_1 = __importDefault(require("./CloudNSPanelController"));
  54. var logger_1 = require("../utils/logger");
  55. var CloudUIID181Controller_1 = __importDefault(require("./CloudUIID181Controller"));
  56. var CloudUIID190Controller_1 = __importDefault(require("./CloudUIID190Controller"));
  57. var CloudZigbeeMultiSwitchController_1 = __importDefault(require("./CloudZigbeeMultiSwitchController"));
  58. var CloudZigbeeDoubleColorBulbController_1 = __importDefault(require("./CloudZigbeeDoubleColorBulbController"));
  59. var CloudZigbeeFiveColorBulbController_1 = __importDefault(require("./CloudZigbeeFiveColorBulbController"));
  60. var CloudUIID137Controller_1 = __importDefault(require("./CloudUIID137Controller"));
  61. var CloudUIID173Controller_1 = __importDefault(require("./CloudUIID173Controller"));
  62. var CloudUIID130Controller_1 = __importDefault(require("./CloudUIID130Controller"));
  63. var CloudUIID182Controller_1 = __importDefault(require("./CloudUIID182Controller"));
  64. var Controller = (function () {
  65. function Controller() {
  66. }
  67. Controller.getDevice = function (id) {
  68. if (id) {
  69. var tmp = id.replace(/.*(?=\.)\./, '');
  70. return Controller.deviceMap.get(tmp);
  71. }
  72. return null;
  73. };
  74. Controller.getDeviceName = function (id) {
  75. var tmp = id.replace(/.*(?=\.)\./, '');
  76. return Controller.deviceMap.get(tmp).deviceName || '';
  77. };
  78. Controller.setDevice = function (params) {
  79. var id = params.id, type = params.type, data = params.data, lanType = params.lanType, index = params.index;
  80. var _index = index || this.count++;
  81. if (lodash_1.default.isEmpty(id)) {
  82. return null;
  83. }
  84. var disabled = (0, dataUtil_1.getDataSync)('disabled.json', [id]) || false;
  85. if (type === 1) {
  86. var tmp = data;
  87. if (!tmp.a) {
  88. return;
  89. }
  90. var diyDevice = new DiyDeviceController_1.default({
  91. ip: tmp.a,
  92. port: tmp.srv.port,
  93. deviceId: id,
  94. disabled: disabled,
  95. txt: tmp.txt,
  96. });
  97. Controller.deviceMap.set(id, diyDevice);
  98. return diyDevice;
  99. }
  100. if (type === 2) {
  101. var params_1 = (0, formatLanDevice_1.default)(data);
  102. if (!params_1 || (!params_1.ip && !params_1.target)) {
  103. logger_1.logger.info("This device is not LAN support, deviceId: ".concat(params_1 === null || params_1 === void 0 ? void 0 : params_1.deviceId));
  104. return;
  105. }
  106. var old = Controller.getDevice(id);
  107. if (old instanceof LanDeviceController_1.default) {
  108. if (params_1.iv && params_1.encryptedData) {
  109. old.iv = params_1 === null || params_1 === void 0 ? void 0 : params_1.iv;
  110. old.encryptedData = params_1 === null || params_1 === void 0 ? void 0 : params_1.encryptedData;
  111. }
  112. if (old.iv && old.devicekey && old.encryptedData) {
  113. var tmpParams = old.parseEncryptedData();
  114. tmpParams && (old.params = (0, mergeDeviceParams_1.default)(old.params, tmpParams));
  115. }
  116. return old;
  117. }
  118. var oldDeviceParams = {};
  119. if (old instanceof CloudDeviceController_1.default) {
  120. oldDeviceParams = {
  121. index: old.index,
  122. devicekey: old.devicekey,
  123. selfApikey: old.apikey,
  124. deviceName: old.deviceName,
  125. extra: old.extra,
  126. params: old.params,
  127. uiid: old.uiid,
  128. };
  129. if (uiid_1.unsupportedLanModeModelSet.has(old.extra.model)) {
  130. return old;
  131. }
  132. }
  133. if (old instanceof CloudMultiChannelSwitchController_1.default) {
  134. oldDeviceParams.maxChannel = old.maxChannel;
  135. }
  136. if (uiid_1.unsupportedLanModeUiidSet.has(oldDeviceParams.uiid)) {
  137. return null;
  138. }
  139. if (lanType === ELanType_1.default.Plug) {
  140. var lanDevice = new LanSwitchController_1.default(__assign(__assign(__assign({}, params_1), oldDeviceParams), { disabled: disabled }));
  141. Controller.deviceMap.set(id, lanDevice);
  142. return lanDevice;
  143. }
  144. else if (lanType === ELanType_1.default.Strip) {
  145. var lanDevice = new LanMultiChannelSwitchController_1.default(__assign(__assign(__assign({}, params_1), oldDeviceParams), { disabled: disabled }));
  146. Controller.deviceMap.set(id, lanDevice);
  147. return lanDevice;
  148. }
  149. else if (lanType === ELanType_1.default.MultifunSwitch) {
  150. var lanDevice = new LanDualR3Controller_1.default(__assign(__assign(__assign({}, params_1), oldDeviceParams), { disabled: disabled }));
  151. Controller.deviceMap.set(id, lanDevice);
  152. return lanDevice;
  153. }
  154. else if (lanType === ELanType_1.default.THPlug) {
  155. var lanDevice = new LanTandHModificationController_1.default(__assign(__assign(__assign({}, params_1), oldDeviceParams), { disabled: disabled }));
  156. Controller.deviceMap.set(id, lanDevice);
  157. return lanDevice;
  158. }
  159. else if (lanType === ELanType_1.default.EnhancedPlug) {
  160. var lanDevice = new LanPowerDetectionSwitchController_1.default(__assign(__assign(__assign({}, params_1), oldDeviceParams), { disabled: disabled }));
  161. Controller.deviceMap.set(id, lanDevice);
  162. return lanDevice;
  163. }
  164. else if (lanType === ELanType_1.default.RF) {
  165. var lanDevice = new LanRFBridgeController_1.default(__assign(__assign(__assign({}, params_1), oldDeviceParams), { disabled: disabled }));
  166. Controller.deviceMap.set(id, lanDevice);
  167. return lanDevice;
  168. }
  169. else if (lanType === ELanType_1.default.FanLight) {
  170. var lanDevice = new LanUIID34Controller_1.default(__assign(__assign(__assign({}, params_1), oldDeviceParams), { disabled: disabled }));
  171. Controller.deviceMap.set(id, lanDevice);
  172. return lanDevice;
  173. }
  174. }
  175. if (type >= 4) {
  176. if (uiid_1.switchUiidSet.has(data.extra.uiid)) {
  177. var tmp = data;
  178. var switchDevice = new CloudSwitchController_1.default({
  179. deviceId: tmp.deviceid,
  180. deviceName: tmp.name,
  181. apikey: tmp.apikey,
  182. extra: tmp.extra,
  183. params: tmp.params,
  184. online: tmp.online,
  185. devicekey: tmp.devicekey,
  186. disabled: disabled,
  187. index: _index,
  188. });
  189. Controller.deviceMap.set(id, switchDevice);
  190. return switchDevice;
  191. }
  192. if (uiid_1.multiChannelSwitchUiidSet.has(data.extra.uiid)) {
  193. var tmp = data;
  194. var device = new CloudMultiChannelSwitchController_1.default({
  195. deviceId: tmp.deviceid,
  196. deviceName: tmp.name,
  197. apikey: tmp.apikey,
  198. extra: tmp.extra,
  199. params: tmp.params,
  200. tags: tmp.tags,
  201. online: tmp.online,
  202. devicekey: tmp.devicekey,
  203. disabled: disabled,
  204. index: _index,
  205. });
  206. Controller.deviceMap.set(id, device);
  207. return device;
  208. }
  209. if (uiid_1.zigbeeMultiSwitchSet.has(data.extra.uiid)) {
  210. var tmp = data;
  211. var device = new CloudZigbeeMultiSwitchController_1.default({
  212. deviceId: tmp.deviceid,
  213. deviceName: tmp.name,
  214. apikey: tmp.apikey,
  215. extra: tmp.extra,
  216. params: tmp.params,
  217. tags: tmp.tags,
  218. online: tmp.online,
  219. devicekey: tmp.devicekey,
  220. disabled: disabled,
  221. index: _index,
  222. });
  223. Controller.deviceMap.set(id, device);
  224. return device;
  225. }
  226. if (data.extra.uiid === 11) {
  227. var tmp = data;
  228. var device = new CloudCoverController_1.default({
  229. deviceId: tmp.deviceid,
  230. deviceName: tmp.name,
  231. apikey: tmp.apikey,
  232. extra: tmp.extra,
  233. params: tmp.params,
  234. online: tmp.online,
  235. devicekey: tmp.devicekey,
  236. disabled: disabled,
  237. index: _index,
  238. });
  239. Controller.deviceMap.set(id, device);
  240. return device;
  241. }
  242. if (data.extra.uiid === 15) {
  243. var tmp = data;
  244. var thmDevice = new CloudTandHModificationController_1.default({
  245. deviceId: tmp.deviceid,
  246. deviceName: tmp.name,
  247. apikey: tmp.apikey,
  248. extra: tmp.extra,
  249. params: tmp.params,
  250. online: tmp.online,
  251. devicekey: tmp.devicekey,
  252. disabled: disabled,
  253. index: _index,
  254. });
  255. Controller.deviceMap.set(id, thmDevice);
  256. return thmDevice;
  257. }
  258. if (data.extra.uiid === 22) {
  259. var tmp = data;
  260. var rgbLight = new CloudRGBBulbController_1.default({
  261. deviceId: tmp.deviceid,
  262. devicekey: tmp.devicekey,
  263. deviceName: tmp.name,
  264. apikey: tmp.apikey,
  265. extra: tmp.extra,
  266. params: tmp.params,
  267. online: tmp.online,
  268. disabled: disabled,
  269. index: _index,
  270. });
  271. Controller.deviceMap.set(id, rgbLight);
  272. return rgbLight;
  273. }
  274. if (data.extra.uiid === 28) {
  275. var tmp = data;
  276. var rfBirdge = new CloudRFBridgeController_1.default({
  277. deviceId: tmp.deviceid,
  278. devicekey: tmp.devicekey,
  279. deviceName: tmp.name,
  280. apikey: tmp.apikey,
  281. extra: tmp.extra,
  282. params: tmp.params,
  283. online: tmp.online,
  284. disabled: disabled,
  285. index: _index,
  286. tags: tmp.tags,
  287. });
  288. Controller.deviceMap.set(id, rfBirdge);
  289. return rfBirdge;
  290. }
  291. if (data.extra.uiid === 32 || data.extra.uiid === 5) {
  292. var tmp = data;
  293. var switchDevice = new CloudPowerDetectionSwitchController_1.default({
  294. deviceId: tmp.deviceid,
  295. deviceName: tmp.name,
  296. apikey: tmp.apikey,
  297. extra: tmp.extra,
  298. params: tmp.params,
  299. online: tmp.online,
  300. devicekey: tmp.devicekey,
  301. disabled: disabled,
  302. index: _index,
  303. });
  304. Controller.deviceMap.set(id, switchDevice);
  305. return switchDevice;
  306. }
  307. if (data.extra.uiid === 34) {
  308. var tmp = data;
  309. var fanLight = new CloudUIID34Controller_1.default({
  310. deviceId: tmp.deviceid,
  311. devicekey: tmp.devicekey,
  312. deviceName: tmp.name,
  313. apikey: tmp.apikey,
  314. extra: tmp.extra,
  315. params: tmp.params,
  316. online: tmp.online,
  317. disabled: disabled,
  318. index: _index,
  319. });
  320. Controller.deviceMap.set(id, fanLight);
  321. return fanLight;
  322. }
  323. if (data.extra.uiid === 44) {
  324. var tmp = data;
  325. var dimming = new CloudUIID44Controller_1.default({
  326. deviceId: tmp.deviceid,
  327. devicekey: tmp.devicekey,
  328. deviceName: tmp.name,
  329. apikey: tmp.apikey,
  330. extra: tmp.extra,
  331. params: tmp.params,
  332. online: tmp.online,
  333. disabled: disabled,
  334. index: _index,
  335. });
  336. Controller.deviceMap.set(id, dimming);
  337. return dimming;
  338. }
  339. if (data.extra.uiid === 59) {
  340. var tmp = data;
  341. var device = new CloudRGBLightStripController_1.default({
  342. deviceId: tmp.deviceid,
  343. devicekey: tmp.devicekey,
  344. deviceName: tmp.name,
  345. apikey: tmp.apikey,
  346. extra: tmp.extra,
  347. params: tmp.params,
  348. online: tmp.online,
  349. disabled: disabled,
  350. index: _index,
  351. });
  352. Controller.deviceMap.set(id, device);
  353. return device;
  354. }
  355. if (data.extra.uiid === 102) {
  356. var tmp = data;
  357. var device = new CloudDW2WiFiController_1.default({
  358. deviceId: tmp.deviceid,
  359. deviceName: tmp.name,
  360. apikey: tmp.apikey,
  361. extra: tmp.extra,
  362. params: tmp.params,
  363. devicekey: tmp.devicekey,
  364. disabled: disabled,
  365. online: tmp.online,
  366. index: _index,
  367. devConfig: tmp.devConfig,
  368. });
  369. Controller.deviceMap.set(id, device);
  370. return device;
  371. }
  372. if (data.extra.uiid === 103) {
  373. var tmp = data;
  374. var device = new CloudDoubleColorBulbController_1.default({
  375. devicekey: tmp.devicekey,
  376. deviceId: tmp.deviceid,
  377. deviceName: tmp.name,
  378. params: tmp.params,
  379. online: tmp.online,
  380. apikey: tmp.apikey,
  381. extra: tmp.extra,
  382. index: _index,
  383. disabled: disabled,
  384. });
  385. Controller.deviceMap.set(id, device);
  386. return device;
  387. }
  388. if (data.extra.uiid === 104) {
  389. var tmp = data;
  390. var device = new CloudUIID104Controller_1.default({
  391. devicekey: tmp.devicekey,
  392. deviceId: tmp.deviceid,
  393. deviceName: tmp.name,
  394. params: tmp.params,
  395. online: tmp.online,
  396. apikey: tmp.apikey,
  397. extra: tmp.extra,
  398. index: _index,
  399. disabled: disabled,
  400. });
  401. Controller.deviceMap.set(id, device);
  402. return device;
  403. }
  404. if (data.extra.uiid === 126) {
  405. var tmp = data;
  406. var device = new CloudDualR3Controller_1.default({
  407. deviceId: tmp.deviceid,
  408. deviceName: tmp.name,
  409. apikey: tmp.apikey,
  410. extra: tmp.extra,
  411. params: tmp.params,
  412. devicekey: tmp.devicekey,
  413. disabled: disabled,
  414. online: tmp.online,
  415. index: _index,
  416. });
  417. Controller.deviceMap.set(id, device);
  418. return device;
  419. }
  420. if (data.extra.uiid === 130) {
  421. var tmp = data;
  422. var device = new CloudUIID130Controller_1.default({
  423. deviceId: tmp.deviceid,
  424. deviceName: tmp.name,
  425. apikey: tmp.apikey,
  426. extra: tmp.extra,
  427. params: tmp.params,
  428. devicekey: tmp.devicekey,
  429. disabled: disabled,
  430. tags: tmp.tags,
  431. online: tmp.online,
  432. index: _index,
  433. });
  434. Controller.deviceMap.set(id, device);
  435. return device;
  436. }
  437. if (data.extra.uiid === 137) {
  438. var tmp = data;
  439. var device = new CloudUIID137Controller_1.default({
  440. deviceId: tmp.deviceid,
  441. deviceName: tmp.name,
  442. apikey: tmp.apikey,
  443. extra: tmp.extra,
  444. params: tmp.params,
  445. devicekey: tmp.devicekey,
  446. disabled: disabled,
  447. online: tmp.online,
  448. index: _index,
  449. });
  450. Controller.deviceMap.set(id, device);
  451. return device;
  452. }
  453. if (data.extra.uiid === 173) {
  454. var tmp = data;
  455. var device = new CloudUIID173Controller_1.default({
  456. deviceId: tmp.deviceid,
  457. deviceName: tmp.name,
  458. apikey: tmp.apikey,
  459. extra: tmp.extra,
  460. params: tmp.params,
  461. devicekey: tmp.devicekey,
  462. disabled: disabled,
  463. online: tmp.online,
  464. index: _index,
  465. });
  466. Controller.deviceMap.set(id, device);
  467. return device;
  468. }
  469. if (data.extra.uiid === 182) {
  470. var tmp = data;
  471. var device = new CloudUIID182Controller_1.default({
  472. deviceId: tmp.deviceid,
  473. deviceName: tmp.name,
  474. apikey: tmp.apikey,
  475. extra: tmp.extra,
  476. params: tmp.params,
  477. devicekey: tmp.devicekey,
  478. disabled: disabled,
  479. tags: tmp.tags,
  480. online: tmp.online,
  481. index: _index,
  482. });
  483. Controller.deviceMap.set(id, device);
  484. return device;
  485. }
  486. if (data.extra.uiid === 1000) {
  487. var tmp = data;
  488. var device = new CloudZigbeeUIID1000Controller_1.default({
  489. devicekey: tmp.devicekey,
  490. deviceId: tmp.deviceid,
  491. deviceName: tmp.name,
  492. apikey: tmp.apikey,
  493. params: tmp.params,
  494. online: tmp.online,
  495. extra: tmp.extra,
  496. index: _index,
  497. disabled: disabled,
  498. });
  499. Controller.deviceMap.set(id, device);
  500. return device;
  501. }
  502. if (data.extra.uiid === 1770) {
  503. var tmp = data;
  504. var device = new CloudZigbeeUIID1770Controller_1.default({
  505. devicekey: tmp.devicekey,
  506. deviceId: tmp.deviceid,
  507. deviceName: tmp.name,
  508. apikey: tmp.apikey,
  509. params: tmp.params,
  510. online: tmp.online,
  511. extra: tmp.extra,
  512. index: _index,
  513. disabled: disabled,
  514. });
  515. Controller.deviceMap.set(id, device);
  516. return device;
  517. }
  518. if (data.extra.uiid === 2026) {
  519. var tmp = data;
  520. var device = new CloudZigbeeUIID2026Controller_1.default({
  521. devicekey: tmp.devicekey,
  522. deviceId: tmp.deviceid,
  523. deviceName: tmp.name,
  524. apikey: tmp.apikey,
  525. params: tmp.params,
  526. online: tmp.online,
  527. extra: tmp.extra,
  528. index: _index,
  529. disabled: disabled,
  530. });
  531. Controller.deviceMap.set(id, device);
  532. return device;
  533. }
  534. if (data.extra.uiid === 3026) {
  535. var tmp = data;
  536. var device = new CloudZigbeeUIID3026Controller_1.default({
  537. devicekey: tmp.devicekey,
  538. deviceId: tmp.deviceid,
  539. deviceName: tmp.name,
  540. params: tmp.params,
  541. apikey: tmp.apikey,
  542. online: tmp.online,
  543. extra: tmp.extra,
  544. index: _index,
  545. disabled: disabled,
  546. });
  547. Controller.deviceMap.set(id, device);
  548. return device;
  549. }
  550. if (data.extra.uiid === 4026) {
  551. var tmp = data;
  552. var device = new CloudZigbeeUIID4026Controller_1.default({
  553. devicekey: tmp.devicekey,
  554. deviceId: tmp.deviceid,
  555. deviceName: tmp.name,
  556. params: tmp.params,
  557. apikey: tmp.apikey,
  558. online: tmp.online,
  559. extra: tmp.extra,
  560. index: _index,
  561. disabled: disabled,
  562. });
  563. Controller.deviceMap.set(id, device);
  564. return device;
  565. }
  566. if (data.extra.uiid === 133) {
  567. var tmp = data;
  568. var device = new CloudNSPanelController_1.default({
  569. devicekey: tmp.devicekey,
  570. deviceId: tmp.deviceid,
  571. deviceName: tmp.name,
  572. params: tmp.params,
  573. apikey: tmp.apikey,
  574. online: tmp.online,
  575. extra: tmp.extra,
  576. index: _index,
  577. tags: tmp.tags,
  578. disabled: disabled
  579. });
  580. Controller.deviceMap.set(id, device);
  581. return device;
  582. }
  583. if (data.extra.uiid === 181) {
  584. var tmp = data;
  585. var device = new CloudUIID181Controller_1.default({
  586. devicekey: tmp.devicekey,
  587. deviceId: tmp.deviceid,
  588. deviceName: tmp.name,
  589. params: tmp.params,
  590. apikey: tmp.apikey,
  591. online: tmp.online,
  592. extra: tmp.extra,
  593. index: _index,
  594. tags: tmp.tags,
  595. disabled: disabled
  596. });
  597. Controller.deviceMap.set(id, device);
  598. return device;
  599. }
  600. if (data.extra.uiid === 190) {
  601. var tmp = data;
  602. var device = new CloudUIID190Controller_1.default({
  603. devicekey: tmp.devicekey,
  604. deviceId: tmp.deviceid,
  605. deviceName: tmp.name,
  606. params: tmp.params,
  607. apikey: tmp.apikey,
  608. online: tmp.online,
  609. extra: tmp.extra,
  610. index: _index,
  611. tags: tmp.tags,
  612. disabled: disabled
  613. });
  614. Controller.deviceMap.set(id, device);
  615. return device;
  616. }
  617. if (data.extra.uiid === 1258) {
  618. var tmp = data;
  619. var device = new CloudZigbeeDoubleColorBulbController_1.default({
  620. devicekey: tmp.devicekey,
  621. deviceId: tmp.deviceid,
  622. deviceName: tmp.name,
  623. params: tmp.params,
  624. apikey: tmp.apikey,
  625. online: tmp.online,
  626. extra: tmp.extra,
  627. index: _index,
  628. disabled: disabled,
  629. });
  630. Controller.deviceMap.set(id, device);
  631. return device;
  632. }
  633. if (data.extra.uiid === 3258) {
  634. var tmp = data;
  635. var device = new CloudZigbeeFiveColorBulbController_1.default({
  636. devicekey: tmp.devicekey,
  637. deviceId: tmp.deviceid,
  638. deviceName: tmp.name,
  639. params: tmp.params,
  640. apikey: tmp.apikey,
  641. online: tmp.online,
  642. extra: tmp.extra,
  643. index: _index,
  644. disabled: disabled,
  645. });
  646. Controller.deviceMap.set(id, device);
  647. return device;
  648. }
  649. if (!Controller.deviceMap.has(id)) {
  650. var unsupportDevice = new UnsupportDeviceController_1.default({
  651. deviceId: data.deviceid,
  652. deviceName: data.name,
  653. apikey: data.apikey,
  654. extra: data.extra,
  655. params: data.params,
  656. online: data.online,
  657. devicekey: data.devicekey,
  658. disabled: disabled,
  659. index: -_index,
  660. });
  661. Controller.unsupportDeviceMap.set(id, unsupportDevice);
  662. }
  663. }
  664. };
  665. Controller.deviceMap = new Map();
  666. Controller.unsupportDeviceMap = new Map();
  667. Controller.count = 999;
  668. return Controller;
  669. }());
  670. exports.default = Controller;