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.

989 lines
35 KiB

7 years ago
6 years ago
  1. /*
  2. MIGRATE MODULE
  3. Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
  4. */
  5. void _cmpMoveIndexDown(const char * key, int offset = 0) {
  6. if (hasSetting(key, 0)) return;
  7. for (unsigned char index = 1; index < SETTINGS_MAX_LIST_COUNT; index++) {
  8. if (hasSetting(key, index)) {
  9. setSetting(key, index - 1, getSetting(key, index).toInt() + offset);
  10. } else {
  11. delSetting(key, index - 1);
  12. }
  13. }
  14. }
  15. // Configuration versions
  16. //
  17. // 1: based on Embedis, no board definitions
  18. // 2: based on Embedis, with board definitions 1-based
  19. // 3: based on Embedis, with board definitions 0-based
  20. void migrate() {
  21. // Get config version
  22. unsigned int board = getSetting("board", 0).toInt();
  23. unsigned int config_version = getSetting("cfg", board > 0 ? 2 : 1).toInt();
  24. // Update if not on latest version
  25. if (config_version == CFG_VERSION) return;
  26. setSetting("cfg", CFG_VERSION);
  27. if (config_version == 2) {
  28. _cmpMoveIndexDown("ledGPIO");
  29. _cmpMoveIndexDown("ledLogic");
  30. _cmpMoveIndexDown("btnGPIO");
  31. _cmpMoveIndexDown("btnRelay", -1);
  32. _cmpMoveIndexDown("relayGPIO");
  33. _cmpMoveIndexDown("relayType");
  34. }
  35. if (config_version == 1) {
  36. #if defined(NODEMCU_LOLIN)
  37. setSetting("board", 2);
  38. setSetting("ledGPIO", 0, 2);
  39. setSetting("ledLogic", 0, 1);
  40. setSetting("btnGPIO", 0, 0);
  41. setSetting("btnRelay", 0, 0);
  42. setSetting("relayGPIO", 0, 12);
  43. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  44. #elif defined(WEMOS_D1_MINI_RELAYSHIELD)
  45. setSetting("board", 3);
  46. setSetting("ledGPIO", 0, 2);
  47. setSetting("ledLogic", 0, 1);
  48. setSetting("btnGPIO", 0, 0);
  49. setSetting("btnRelay", 0, 0);
  50. setSetting("relayGPIO", 0, 5);
  51. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  52. #elif defined(ITEAD_SONOFF_BASIC)
  53. setSetting("board", 4);
  54. setSetting("ledGPIO", 0, 13);
  55. setSetting("ledLogic", 0, 1);
  56. setSetting("btnGPIO", 0, 0);
  57. setSetting("btnRelay", 0, 0);
  58. setSetting("relayGPIO", 0, 12);
  59. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  60. #elif defined(ITEAD_SONOFF_TH)
  61. setSetting("board", 5);
  62. setSetting("ledGPIO", 0, 13);
  63. setSetting("ledLogic", 0, 1);
  64. setSetting("btnGPIO", 0, 0);
  65. setSetting("btnRelay", 0, 0);
  66. setSetting("relayGPIO", 0, 12);
  67. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  68. #elif defined(ITEAD_SONOFF_SV)
  69. setSetting("board", 6);
  70. setSetting("ledGPIO", 0, 13);
  71. setSetting("ledLogic", 0, 1);
  72. setSetting("btnGPIO", 0, 0);
  73. setSetting("btnRelay", 0, 0);
  74. setSetting("relayGPIO", 0, 12);
  75. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  76. #elif defined(ITEAD_SONOFF_TOUCH)
  77. setSetting("board", 7);
  78. setSetting("ledGPIO", 0, 13);
  79. setSetting("ledLogic", 0, 1);
  80. setSetting("btnGPIO", 0, 0);
  81. setSetting("btnRelay", 0, 0);
  82. setSetting("relayGPIO", 0, 12);
  83. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  84. #elif defined(ITEAD_SONOFF_POW)
  85. setSetting("board", 8);
  86. setSetting("ledGPIO", 0, 15);
  87. setSetting("ledLogic", 0, 1);
  88. setSetting("btnGPIO", 0, 0);
  89. setSetting("btnRelay", 0, 0);
  90. setSetting("relayGPIO", 0, 12);
  91. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  92. setSetting("selGPIO", 5);
  93. setSetting("cf1GPIO", 13);
  94. setSetting("cfGPIO", 14);
  95. #elif defined(ITEAD_SONOFF_DUAL)
  96. setSetting("board", 9);
  97. setSetting("ledGPIO", 0, 13);
  98. setSetting("ledLogic", 0, 1);
  99. setSetting("btnRelay", 0, 0xFF);
  100. setSetting("btnRelay", 1, 0xFF);
  101. setSetting("btnRelay", 2, 0);
  102. setSetting("relayProvider", RELAY_PROVIDER_DUAL);
  103. setSetting("relays", 2);
  104. #elif defined(ITEAD_1CH_INCHING)
  105. setSetting("board", 10);
  106. setSetting("ledGPIO", 0, 13);
  107. setSetting("ledLogic", 0, 1);
  108. setSetting("btnGPIO", 0, 0);
  109. setSetting("btnRelay", 0, 0);
  110. setSetting("relayGPIO", 0, 12);
  111. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  112. #elif defined(ITEAD_SONOFF_4CH)
  113. setSetting("board", 11);
  114. setSetting("ledGPIO", 0, 13);
  115. setSetting("ledLogic", 0, 1);
  116. setSetting("btnGPIO", 0, 0);
  117. setSetting("btnGPIO", 1, 9);
  118. setSetting("btnGPIO", 2, 10);
  119. setSetting("btnGPIO", 3, 14);
  120. setSetting("btnRelay", 0, 0);
  121. setSetting("btnRelay", 1, 1);
  122. setSetting("btnRelay", 2, 2);
  123. setSetting("btnRelay", 3, 3);
  124. setSetting("relayGPIO", 0, 12);
  125. setSetting("relayGPIO", 1, 5);
  126. setSetting("relayGPIO", 2, 4);
  127. setSetting("relayGPIO", 3, 15);
  128. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  129. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  130. setSetting("relayType", 2, RELAY_TYPE_NORMAL);
  131. setSetting("relayType", 3, RELAY_TYPE_NORMAL);
  132. #elif defined(ITEAD_SLAMPHER)
  133. setSetting("board", 12);
  134. setSetting("ledGPIO", 0, 13);
  135. setSetting("ledLogic", 0, 1);
  136. setSetting("btnGPIO", 0, 0);
  137. setSetting("btnRelay", 0, 0);
  138. setSetting("relayGPIO", 0, 12);
  139. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  140. #elif defined(ITEAD_S20)
  141. setSetting("board", 13);
  142. setSetting("ledGPIO", 0, 13);
  143. setSetting("ledLogic", 0, 1);
  144. setSetting("btnGPIO", 0, 0);
  145. setSetting("btnRelay", 0, 0);
  146. setSetting("relayGPIO", 0, 12);
  147. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  148. #elif defined(ELECTRODRAGON_WIFI_IOT)
  149. setSetting("board", 14);
  150. setSetting("ledGPIO", 0, 16);
  151. setSetting("ledLogic", 0, 0);
  152. setSetting("btnGPIO", 0, 0);
  153. setSetting("btnGPIO", 1, 2);
  154. setSetting("btnRelay", 0, 0);
  155. setSetting("btnRelay", 1, 1);
  156. setSetting("relayGPIO", 0, 12);
  157. setSetting("relayGPIO", 1, 13);
  158. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  159. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  160. #elif defined(WORKCHOICE_ECOPLUG)
  161. setSetting("board", 15);
  162. setSetting("ledGPIO", 0, 2);
  163. setSetting("ledLogic", 0, 0);
  164. setSetting("btnGPIO", 0, 13);
  165. setSetting("btnRelay", 0, 0);
  166. setSetting("relayGPIO", 0, 15);
  167. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  168. #elif defined(JANGOE_WIFI_RELAY_NC)
  169. setSetting("board", 16);
  170. setSetting("btnGPIO", 0, 12);
  171. setSetting("btnGPIO", 1, 13);
  172. setSetting("btnRelay", 0, 0);
  173. setSetting("btnRelay", 1, 1);
  174. setSetting("relayGPIO", 0, 2);
  175. setSetting("relayGPIO", 1, 14);
  176. setSetting("relayType", 0, RELAY_TYPE_INVERSE);
  177. setSetting("relayType", 1, RELAY_TYPE_INVERSE);
  178. #elif defined(JANGOE_WIFI_RELAY_NO)
  179. setSetting("board", 17);
  180. setSetting("btnGPIO", 0, 12);
  181. setSetting("btnGPIO", 1, 13);
  182. setSetting("btnRelay", 0, 0);
  183. setSetting("btnRelay", 1, 1);
  184. setSetting("relayGPIO", 0, 2);
  185. setSetting("relayGPIO", 1, 14);
  186. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  187. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  188. #elif defined(OPENENERGYMONITOR_MQTT_RELAY)
  189. setSetting("board", 18);
  190. setSetting("ledGPIO", 0, 16);
  191. setSetting("ledLogic", 0, 1);
  192. setSetting("btnGPIO", 0, 0);
  193. setSetting("btnRelay", 0, 0);
  194. setSetting("relayGPIO", 0, 12);
  195. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  196. #elif defined(JORGEGARCIA_WIFI_RELAYS)
  197. setSetting("board", 19);
  198. setSetting("relayGPIO", 0, 0);
  199. setSetting("relayGPIO", 1, 2);
  200. setSetting("relayType", 0, RELAY_TYPE_INVERSE);
  201. setSetting("relayType", 1, RELAY_TYPE_INVERSE);
  202. #elif defined(AITHINKER_AI_LIGHT)
  203. setSetting("board", 20);
  204. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  205. setSetting("lightProvider", LIGHT_PROVIDER_MY92XX);
  206. setSetting("myModel", MY92XX_MODEL_MY9291);
  207. setSetting("myChips", 1);
  208. setSetting("myDIGPIO", 13);
  209. setSetting("myDCKIGPIO", 15);
  210. setSetting("relays", 1);
  211. #elif defined(MAGICHOME_LED_CONTROLLER)
  212. setSetting("board", 21);
  213. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  214. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  215. setSetting("ledGPIO", 0, 2);
  216. setSetting("ledLogic", 0, 1);
  217. setSetting("chGPIO", 0, 14);
  218. setSetting("chGPIO", 1, 5);
  219. setSetting("chGPIO", 2, 12);
  220. setSetting("chGPIO", 3, 13);
  221. setSetting("chLogic", 0, 0);
  222. setSetting("chLogic", 1, 0);
  223. setSetting("chLogic", 2, 0);
  224. setSetting("chLogic", 3, 0);
  225. setSetting("relays", 1);
  226. #elif defined(MAGICHOME_LED_CONTROLLER_IR)
  227. setSetting("board", 21);
  228. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  229. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  230. setSetting("ledGPIO", 0, 2);
  231. setSetting("ledLogic", 0, 1);
  232. setSetting("chGPIO", 0, 5);
  233. setSetting("chGPIO", 1, 12);
  234. setSetting("chGPIO", 2, 13);
  235. setSetting("chGPIO", 3, 14);
  236. setSetting("chLogic", 0, 0);
  237. setSetting("chLogic", 1, 0);
  238. setSetting("chLogic", 2, 0);
  239. setSetting("chLogic", 3, 0);
  240. setSetting("relays", 1);
  241. #elif defined(ITEAD_MOTOR)
  242. setSetting("board", 22);
  243. setSetting("ledGPIO", 0, 13);
  244. setSetting("ledLogic", 0, 1);
  245. setSetting("btnGPIO", 0, 0);
  246. setSetting("btnRelay", 0, 0);
  247. setSetting("relayGPIO", 0, 12);
  248. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  249. #elif defined(TINKERMAN_ESPURNA_H06)
  250. setSetting("board", 23);
  251. setSetting("ledGPIO", 0, 5);
  252. setSetting("ledLogic", 0, 0);
  253. setSetting("btnGPIO", 0, 4);
  254. setSetting("btnRelay", 0, 0);
  255. setSetting("relayGPIO", 0, 12);
  256. setSetting("relayType", 0, RELAY_TYPE_INVERSE);
  257. setSetting("selGPIO", 2);
  258. setSetting("cf1GPIO", 13);
  259. setSetting("cfGPIO", 14);
  260. #elif defined(HUACANXING_H801)
  261. setSetting("board", 24);
  262. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  263. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  264. setSetting("ledGPIO", 0, 5);
  265. setSetting("ledLogic", 0, 1);
  266. setSetting("chGPIO", 0, 15);
  267. setSetting("chGPIO", 1, 13);
  268. setSetting("chGPIO", 2, 12);
  269. setSetting("chGPIO", 3, 14);
  270. setSetting("chGPIO", 4, 4);
  271. setSetting("chLogic", 0, 0);
  272. setSetting("chLogic", 1, 0);
  273. setSetting("chLogic", 2, 0);
  274. setSetting("chLogic", 3, 0);
  275. setSetting("chLogic", 4, 0);
  276. setSetting("relays", 1);
  277. #elif defined(ITEAD_BNSZ01)
  278. setSetting("board", 25);
  279. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  280. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  281. setSetting("ledGPIO", 0, 13);
  282. setSetting("ledLogic", 0, 1);
  283. setSetting("chGPIO", 0, 12);
  284. setSetting("chLogic", 0, 0);
  285. setSetting("relays", 1);
  286. #elif defined(ITEAD_SONOFF_RFBRIDGE)
  287. setSetting("board", 26);
  288. setSetting("ledGPIO", 0, 13);
  289. setSetting("ledLogic", 0, 1);
  290. setSetting("btnGPIO", 0, 0);
  291. setSetting("relayProvider", RELAY_PROVIDER_RFBRIDGE);
  292. setSetting("relays", 6);
  293. #elif defined(ITEAD_SONOFF_4CH_PRO)
  294. setSetting("board", 27);
  295. setSetting("ledGPIO", 0, 13);
  296. setSetting("ledLogic", 0, 1);
  297. setSetting("btnGPIO", 0, 0);
  298. setSetting("btnGPIO", 1, 9);
  299. setSetting("btnGPIO", 2, 10);
  300. setSetting("btnGPIO", 3, 14);
  301. setSetting("btnRelay", 0, 0);
  302. setSetting("btnRelay", 1, 1);
  303. setSetting("btnRelay", 2, 2);
  304. setSetting("btnRelay", 3, 3);
  305. setSetting("relayGPIO", 0, 12);
  306. setSetting("relayGPIO", 1, 5);
  307. setSetting("relayGPIO", 2, 4);
  308. setSetting("relayGPIO", 3, 15);
  309. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  310. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  311. setSetting("relayType", 2, RELAY_TYPE_NORMAL);
  312. setSetting("relayType", 3, RELAY_TYPE_NORMAL);
  313. #elif defined(ITEAD_SONOFF_B1)
  314. setSetting("board", 28);
  315. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  316. setSetting("lightProvider", LIGHT_PROVIDER_MY92XX);
  317. setSetting("myModel", MY92XX_MODEL_MY9231);
  318. setSetting("myChips", 2);
  319. setSetting("myDIGPIO", 12);
  320. setSetting("myDCKIGPIO", 14);
  321. setSetting("relays", 1);
  322. #elif defined(ITEAD_SONOFF_LED)
  323. setSetting("board", 29);
  324. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  325. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  326. setSetting("ledGPIO", 0, 13);
  327. setSetting("ledLogic", 0, 1);
  328. setSetting("chGPIO", 0, 12);
  329. setSetting("chLogic", 0, 0);
  330. setSetting("chGPIO", 1, 14);
  331. setSetting("chLogic", 1, 0);
  332. setSetting("relays", 1);
  333. #elif defined(ITEAD_SONOFF_T1_1CH)
  334. setSetting("board", 30);
  335. setSetting("ledGPIO", 0, 13);
  336. setSetting("ledLogic", 0, 1);
  337. setSetting("btnGPIO", 0, 9);
  338. setSetting("btnRelay", 0, 0);
  339. setSetting("relayGPIO", 0, 5);
  340. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  341. #elif defined(ITEAD_SONOFF_T1_2CH)
  342. setSetting("board", 31);
  343. setSetting("ledGPIO", 0, 13);
  344. setSetting("ledLogic", 0, 1);
  345. setSetting("btnGPIO", 0, 0);
  346. setSetting("btnGPIO", 1, 10);
  347. setSetting("btnRelay", 0, 0);
  348. setSetting("btnRelay", 1, 1);
  349. setSetting("relayGPIO", 0, 12);
  350. setSetting("relayGPIO", 1, 4);
  351. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  352. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  353. #elif defined(ITEAD_SONOFF_T1_3CH)
  354. setSetting("board", 32);
  355. setSetting("ledGPIO", 0, 13);
  356. setSetting("ledLogic", 0, 1);
  357. setSetting("btnGPIO", 0, 0);
  358. setSetting("btnGPIO", 1, 9);
  359. setSetting("btnGPIO", 2, 10);
  360. setSetting("btnRelay", 0, 0);
  361. setSetting("btnRelay", 1, 1);
  362. setSetting("btnRelay", 2, 2);
  363. setSetting("relayGPIO", 0, 12);
  364. setSetting("relayGPIO", 1, 5);
  365. setSetting("relayGPIO", 2, 4);
  366. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  367. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  368. setSetting("relayType", 2, RELAY_TYPE_NORMAL);
  369. #elif defined(ITEAD_SONOFF_RF)
  370. setSetting("board", 33);
  371. setSetting("ledGPIO", 0, 13);
  372. setSetting("ledLogic", 0, 1);
  373. setSetting("btnGPIO", 0, 0);
  374. setSetting("btnRelay", 0, 0);
  375. setSetting("relayGPIO", 0, 12);
  376. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  377. #elif defined(WION_50055)
  378. setSetting("board", 34);
  379. setSetting("ledGPIO", 0, 2);
  380. setSetting("ledLogic", 0, 0);
  381. setSetting("btnGPIO", 0, 13);
  382. setSetting("btnRelay", 0, 0);
  383. setSetting("relayGPIO", 0, 15);
  384. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  385. #elif defined(EXS_WIFI_RELAY_V31)
  386. setSetting("board", 35);
  387. setSetting("btnGPIO", 0, 0);
  388. setSetting("btnRelay", 0, 0);
  389. setSetting("relayGPIO", 0, 13);
  390. setSetting("relayResetGPIO", 0, 12);
  391. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  392. #elif defined(HUACANXING_H802)
  393. setSetting("board", 36);
  394. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  395. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  396. setSetting("chGPIO", 0, 12);
  397. setSetting("chGPIO", 1, 14);
  398. setSetting("chGPIO", 2, 13);
  399. setSetting("chGPIO", 3, 15);
  400. setSetting("chLogic", 0, 0);
  401. setSetting("chLogic", 1, 0);
  402. setSetting("chLogic", 2, 0);
  403. setSetting("chLogic", 3, 0);
  404. setSetting("relays", 1);
  405. #elif defined(GENERIC_V9261F)
  406. setSetting("board", 37);
  407. #elif defined(GENERIC_ECH1560)
  408. setSetting("board", 38);
  409. #elif defined(TINKERMAN_ESPURNA_H08)
  410. setSetting("board", 39);
  411. setSetting("ledGPIO", 0, 2);
  412. setSetting("ledLogic", 0, 0);
  413. setSetting("btnGPIO", 0, 4);
  414. setSetting("btnRelay", 0, 0);
  415. setSetting("relayGPIO", 0, 12);
  416. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  417. setSetting("selGPIO", 5);
  418. setSetting("cf1GPIO", 13);
  419. setSetting("cfGPIO", 14);
  420. #elif defined(MANCAVEMADE_ESPLIVE)
  421. setSetting("board", 40);
  422. setSetting("btnGPIO", 0, 4);
  423. setSetting("btnGPIO", 1, 5);
  424. setSetting("btnRelay", 0, 0);
  425. setSetting("btnRelay", 1, 1);
  426. setSetting("relayGPIO", 0, 12);
  427. setSetting("relayGPIO", 1, 13);
  428. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  429. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  430. #elif defined(INTERMITTECH_QUINLED)
  431. setSetting("board", 41);
  432. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  433. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  434. setSetting("ledGPIO", 0, 1);
  435. setSetting("ledLogic", 0, 1);
  436. setSetting("chGPIO", 0, 0);
  437. setSetting("chGPIO", 1, 2);
  438. setSetting("chLogic", 0, 0);
  439. setSetting("chLogic", 1, 0);
  440. setSetting("relays", 1);
  441. #elif defined(MAGICHOME_LED_CONTROLLER_20)
  442. setSetting("board", 42);
  443. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  444. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  445. setSetting("chGPIO", 0, 5);
  446. setSetting("chGPIO", 1, 12);
  447. setSetting("chGPIO", 2, 13);
  448. setSetting("chGPIO", 3, 15);
  449. setSetting("chLogic", 0, 0);
  450. setSetting("chLogic", 1, 0);
  451. setSetting("chLogic", 2, 0);
  452. setSetting("chLogic", 3, 0);
  453. setSetting("relays", 1);
  454. #elif defined(ARILUX_AL_LC06)
  455. setSetting("board", 43);
  456. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  457. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  458. setSetting("chGPIO", 0, 12);
  459. setSetting("chGPIO", 1, 14);
  460. setSetting("chGPIO", 2, 13);
  461. setSetting("chGPIO", 3, 15);
  462. setSetting("chGPIO", 4, 5);
  463. setSetting("chLogic", 0, 0);
  464. setSetting("chLogic", 1, 0);
  465. setSetting("chLogic", 2, 0);
  466. setSetting("chLogic", 3, 0);
  467. setSetting("chLogic", 4, 0);
  468. setSetting("relays", 1);
  469. #elif defined(XENON_SM_PW702U)
  470. setSetting("board", 44);
  471. setSetting("ledGPIO", 0, 4);
  472. setSetting("ledLogic", 0, 0);
  473. setSetting("btnGPIO", 0, 13);
  474. setSetting("btnRelay", 0, 0);
  475. setSetting("relayGPIO", 0, 12);
  476. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  477. #elif defined(AUTHOMETION_LYT8266)
  478. setSetting("board", 45);
  479. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  480. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  481. setSetting("chGPIO", 0, 13);
  482. setSetting("chGPIO", 1, 12);
  483. setSetting("chGPIO", 2, 14);
  484. setSetting("chGPIO", 3, 2);
  485. setSetting("chLogic", 0, 0);
  486. setSetting("chLogic", 1, 0);
  487. setSetting("chLogic", 2, 0);
  488. setSetting("chLogic", 3, 0);
  489. setSetting("relays", 1);
  490. setSetting("enGPIO", 15);
  491. #elif defined(ARILUX_E27)
  492. setSetting("board", 46);
  493. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  494. setSetting("lightProvider", LIGHT_PROVIDER_MY92XX);
  495. setSetting("myModel", MY92XX_MODEL_MY9291);
  496. setSetting("myChips", 1);
  497. setSetting("myDIGPIO", 13);
  498. setSetting("myDCKIGPIO", 15);
  499. setSetting("relays", 1);
  500. #elif defined(YJZK_SWITCH_2CH)
  501. setSetting("board", 47);
  502. setSetting("ledGPIO", 0, 13);
  503. setSetting("ledLogic", 0, 0);
  504. setSetting("ledWifi", 0);
  505. setSetting("btnGPIO", 0, 0);
  506. setSetting("btnGPIO", 1, 9);
  507. setSetting("btnRelay", 0, 0);
  508. setSetting("btnRelay", 1, 1);
  509. setSetting("relayGPIO", 0, 12);
  510. setSetting("relayGPIO", 1, 5);
  511. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  512. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  513. #elif defined(ITEAD_SONOFF_DUAL_R2)
  514. setSetting("board", 48);
  515. setSetting("ledGPIO", 0, 13);
  516. setSetting("ledLogic", 0, 1);
  517. setSetting("btnGPIO", 0, 0);
  518. setSetting("btnGPIO", 1, 9);
  519. setSetting("btnGPIO", 2, 10);
  520. setSetting("btnRelay", 0, 0);
  521. setSetting("btnRelay", 1, 1);
  522. setSetting("btnRelay", 2, 0);
  523. setSetting("relayGPIO", 0, 12);
  524. setSetting("relayGPIO", 1, 5);
  525. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  526. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  527. #elif defined(GENERIC_8CH)
  528. setSetting("board", 49);
  529. setSetting("relayGPIO", 0, 0);
  530. setSetting("relayGPIO", 1, 2);
  531. setSetting("relayGPIO", 2, 4);
  532. setSetting("relayGPIO", 3, 5);
  533. setSetting("relayGPIO", 4, 12);
  534. setSetting("relayGPIO", 5, 13);
  535. setSetting("relayGPIO", 6, 14);
  536. setSetting("relayGPIO", 7, 15);
  537. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  538. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  539. setSetting("relayType", 2, RELAY_TYPE_NORMAL);
  540. setSetting("relayType", 3, RELAY_TYPE_NORMAL);
  541. setSetting("relayType", 4, RELAY_TYPE_NORMAL);
  542. setSetting("relayType", 5, RELAY_TYPE_NORMAL);
  543. setSetting("relayType", 6, RELAY_TYPE_NORMAL);
  544. setSetting("relayType", 7, RELAY_TYPE_NORMAL);
  545. #elif defined(ARILUX_AL_LC01)
  546. setSetting("board", 50);
  547. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  548. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  549. setSetting("chGPIO", 0, 5);
  550. setSetting("chGPIO", 1, 12);
  551. setSetting("chGPIO", 2, 13);
  552. setSetting("chGPIO", 3, 14);
  553. setSetting("chLogic", 0, 0);
  554. setSetting("chLogic", 1, 0);
  555. setSetting("chLogic", 2, 0);
  556. setSetting("chLogic", 3, 0);
  557. setSetting("relays", 1);
  558. #elif defined(ARILUX_AL_LC11)
  559. setSetting("board", 51);
  560. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  561. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  562. setSetting("chGPIO", 0, 5);
  563. setSetting("chGPIO", 1, 4);
  564. setSetting("chGPIO", 2, 14);
  565. setSetting("chGPIO", 3, 13);
  566. setSetting("chGPIO", 4, 12);
  567. setSetting("chLogic", 0, 0);
  568. setSetting("chLogic", 1, 0);
  569. setSetting("chLogic", 2, 0);
  570. setSetting("chLogic", 3, 0);
  571. setSetting("chLogic", 4, 0);
  572. setSetting("relays", 1);
  573. #elif defined(ARILUX_AL_LC02)
  574. setSetting("board", 52);
  575. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  576. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  577. setSetting("chGPIO", 0, 12);
  578. setSetting("chGPIO", 1, 5);
  579. setSetting("chGPIO", 2, 13);
  580. setSetting("chGPIO", 3, 15);
  581. setSetting("chLogic", 0, 0);
  582. setSetting("chLogic", 1, 0);
  583. setSetting("chLogic", 2, 0);
  584. setSetting("chLogic", 3, 0);
  585. setSetting("relays", 1);
  586. #elif defined(KMC_70011)
  587. setSetting("board", 53);
  588. setSetting("ledGPIO", 0, 13);
  589. setSetting("ledLogic", 0, 0);
  590. setSetting("btnGPIO", 0, 0);
  591. setSetting("btnRelay", 0, 0);
  592. setSetting("relayGPIO", 0, 14);
  593. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  594. setSetting("selGPIO", 12);
  595. setSetting("cf1GPIO", 5);
  596. setSetting("cfGPIO", 4);
  597. #elif defined(GIZWITS_WITTY_CLOUD)
  598. setSetting("board", 54);
  599. setSetting("ledGPIO", 0, 2);
  600. setSetting("ledLogic", 0, 1);
  601. setSetting("btnGPIO", 0, 4);
  602. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  603. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  604. setSetting("chGPIO", 0, 15);
  605. setSetting("chGPIO", 1, 12);
  606. setSetting("chGPIO", 2, 13);
  607. setSetting("chLogic", 0, 0);
  608. setSetting("chLogic", 1, 0);
  609. setSetting("chLogic", 2, 0);
  610. setSetting("relays", 1);
  611. #elif defined(EUROMATE_WIFI_STECKER_SCHUKO)
  612. setSetting("board", 55);
  613. setSetting("ledGPIO", 0, 4);
  614. setSetting("ledLogic", 0, 0);
  615. setSetting("ledGPIO", 1, 12);
  616. setSetting("ledLogic", 1, 0);
  617. setSetting("btnGPIO", 0, 14);
  618. setSetting("btnRelay", 0, 0);
  619. setSetting("relayGPIO", 0, 5);
  620. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  621. #elif defined(TONBUX_POWERSTRIP02)
  622. setSetting("board", 56);
  623. setSetting("relayGPIO", 0, 4);
  624. setSetting("relayGPIO", 1, 13);
  625. setSetting("relayGPIO", 2, 12);
  626. setSetting("relayGPIO", 3, 14);
  627. setSetting("relayGPIO", 4, 16);
  628. setSetting("relayType", 0, RELAY_TYPE_INVERSE);
  629. setSetting("relayType", 1, RELAY_TYPE_INVERSE);
  630. setSetting("relayType", 2, RELAY_TYPE_INVERSE);
  631. setSetting("relayType", 3, RELAY_TYPE_INVERSE);
  632. setSetting("relayType", 4, RELAY_TYPE_NORMAL); // Not a relay. USB ports on/off
  633. setSetting("ledGPIO", 0, 0); // 1 blue led
  634. setSetting("ledLogic", 0, 1);
  635. setSetting("ledGPIO", 1, 3); // 3 red leds
  636. setSetting("ledLogic", 1, 1);
  637. setSetting("btnGPIO", 0, 5);
  638. setSetting("btnRelay", 0, 1);
  639. #elif defined(LINGAN_SWA1)
  640. setSetting("board", 57);
  641. setSetting("ledGPIO", 0, 4);
  642. setSetting("ledLogic", 0, 1);
  643. setSetting("btnGPIO", 0, 13);
  644. setSetting("btnRelay", 0, 0);
  645. setSetting("relayGPIO", 0, 5);
  646. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  647. #elif defined(HEYGO_HY02)
  648. setSetting("board", 58);
  649. setSetting("ledGPIO", 0, 0);
  650. setSetting("ledLogic", 0, 1);
  651. setSetting("ledGPIO", 1, 15);
  652. setSetting("ledLogic", 1, 0);
  653. setSetting("btnGPIO", 0, 13);
  654. setSetting("btnRelay", 0, 0);
  655. setSetting("relayGPIO", 0, 15);
  656. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  657. setSetting("selGPIO", 3);
  658. setSetting("cf1GPIO", 14);
  659. setSetting("cfGPIO", 5);
  660. #elif defined(MAXCIO_WUS002S)
  661. setSetting("board", 59);
  662. setSetting("ledGPIO", 0, 3);
  663. setSetting("ledLogic", 0, 0);
  664. setSetting("btnGPIO", 0, 2);
  665. setSetting("btnRelay", 0, 0);
  666. setSetting("relayGPIO", 0, 13);
  667. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  668. setSetting("selGPIO", 12);
  669. setSetting("cf1GPIO", 5);
  670. setSetting("cfGPIO", 4);
  671. #elif defined(YIDIAN_XSSSA05)
  672. setSetting("board", 60);
  673. setSetting("ledGPIO", 0, 0);
  674. setSetting("ledLogic", 0, 0);
  675. setSetting("ledGPIO", 1, 5);
  676. setSetting("ledLogic", 1, 0);
  677. setSetting("ledGPIO", 2, 2);
  678. setSetting("ledLogic", 2, 0);
  679. setSetting("btnGPIO", 0, 13);
  680. setSetting("btnRelay", 0, 0);
  681. setSetting("relayGPIO", 0, 15);
  682. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  683. #elif defined(TONBUX_XSSSA06)
  684. setSetting("board", 61);
  685. setSetting("ledGPIO", 0, 4);
  686. setSetting("ledLogic", 0, 1);
  687. setSetting("btnGPIO", 0, 13);
  688. setSetting("btnRelay", 0, 0);
  689. setSetting("relayGPIO", 0, 5);
  690. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  691. #elif defined(GREEN_ESP8266RELAY)
  692. setSetting("board", 62);
  693. setSetting("ledGPIO", 0, 2);
  694. setSetting("ledLogic", 0, 1);
  695. setSetting("btnGPIO", 0, 5);
  696. setSetting("btnRelay", 0, 0);
  697. setSetting("relayGPIO", 0, 4);
  698. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  699. #elif defined(IKE_ESPIKE)
  700. setSetting("board", 63);
  701. setSetting("ledGPIO", 0, 2);
  702. setSetting("ledLogic", 0, 1);
  703. setSetting("btnGPIO", 0, 13);
  704. setSetting("btnRelay", 0, 0);
  705. setSetting("btnGPIO", 1, 12);
  706. setSetting("btnRelay", 1, 1);
  707. setSetting("btnGPIO", 2, 13);
  708. setSetting("btnRelay", 2, 2);
  709. setSetting("relayGPIO", 0, 4);
  710. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  711. setSetting("relayGPIO", 1, 5);
  712. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  713. setSetting("relayGPIO", 2, 16);
  714. setSetting("relayType", 2, RELAY_TYPE_NORMAL);
  715. #elif defined(ARNIEX_SWIFITCH)
  716. setSetting("board", 64);
  717. setSetting("ledGPIO", 0, 12);
  718. setSetting("ledLogic", 0, 1);
  719. setSetting("btnGPIO", 0, 4);
  720. setSetting("btnRelay", 0, 1);
  721. setSetting("relayGPIO", 0, 5);
  722. setSetting("relayType", 0, RELAY_TYPE_INVERSE);
  723. #elif defined(GENERIC_ESP01S_RELAY_V40)
  724. setSetting("board", 65);
  725. setSetting("ledGPIO", 0, 2);
  726. setSetting("ledLogic", 0, 0);
  727. setSetting("relayGPIO", 0, 0);
  728. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  729. #elif defined(GENERIC_ESP01S_RGBLED_V10)
  730. setSetting("board", 66);
  731. setSetting("ledGPIO", 0, 2);
  732. #elif defined(HELTEC_TOUCHRELAY)
  733. setSetting("board", 67);
  734. setSetting("btnGPIO", 0, 14);
  735. setSetting("btnRelay", 0, 1);
  736. setSetting("relayGPIO", 0, 12);
  737. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  738. #elif defined(GENERIC_ESP01S_DHT11_V10)
  739. setSetting("board", 68);
  740. #elif defined(GENERIC_ESP01S_DS18B20_V10)
  741. setSetting("board", 69);
  742. #elif defined(ZHILDE_EU44_W)
  743. setSetting("board", 70);
  744. setSetting("btnGPIO", 0, 3);
  745. setSetting("ledGPIO", 0, 1);
  746. setSetting("ledLogic", 0, 1);
  747. setSetting("relayGPIO", 0, 5);
  748. setSetting("relayGPIO", 1, 4);
  749. setSetting("relayGPIO", 2, 12);
  750. setSetting("relayGPIO", 3, 13);
  751. setSetting("relayGPIO", 4, 14);
  752. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  753. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  754. setSetting("relayType", 2, RELAY_TYPE_NORMAL);
  755. setSetting("relayType", 3, RELAY_TYPE_NORMAL);
  756. setSetting("relayType", 4, RELAY_TYPE_NORMAL);
  757. #elif defined(ITEAD_SONOFF_POW_R2)
  758. setSetting("board", 71);
  759. setSetting("ledGPIO", 0, 15);
  760. setSetting("ledLogic", 0, 1);
  761. setSetting("btnGPIO", 0, 0);
  762. setSetting("btnRelay", 0, 0);
  763. setSetting("relayGPIO", 0, 12);
  764. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  765. setSetting("selGPIO", 5);
  766. setSetting("cf1GPIO", 13);
  767. setSetting("cfGPIO", 14);
  768. #elif defined(LUANI_HVIO)
  769. setSetting("board", 72);
  770. setSetting("ledGPIO", 0, 15);
  771. setSetting("ledLogic", 0, 0);
  772. setSetting("btnGPIO", 0, 12);
  773. setSetting("btnRelay", 0, 0);
  774. setSetting("relayGPIO", 0, 4);
  775. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  776. setSetting("relayGPIO", 1, 5);
  777. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  778. #elif defined(ALLNET_4DUINO_IOT_WLAN_RELAIS)
  779. setSetting("board", 73);
  780. setSetting("relayGPIO", 0, 14);
  781. setSetting("relayResetGPIO", 0, 12);
  782. setSetting("relayType", 0, RELAY_TYPE_LATCHED);
  783. #elif defined(TONBUX_MOSQUITO_KILLER)
  784. setSetting("board", 74);
  785. setSetting("ledGPIO", 0, 15);
  786. setSetting("ledLogic", 0, 1);
  787. setSetting("ledGPIO", 1, 14);
  788. setSetting("ledLogic", 1, 1);
  789. setSetting("ledGPIO", 2, 12);
  790. setSetting("ledLogic", 2, 0);
  791. setSetting("ledGPIO", 3, 16);
  792. setSetting("ledLogic", 3, 0);
  793. setSetting("btnGPIO", 0, 2);
  794. setSetting("btnRelay", 0, 0);
  795. setSetting("relayGPIO", 0, 5);
  796. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  797. #elif defined(NEO_COOLCAM_POWER_PLUG_WIFI)
  798. setSetting("board", 75);
  799. setSetting("ledGPIO", 0, 4);
  800. setSetting("ledLogic", 0, 1);
  801. setSetting("btnGPIO", 0, 13);
  802. setSetting("btnRelay", 0, 0);
  803. setSetting("relayGPIO", 0, 12);
  804. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  805. #elif defined(PILOTAK_ESP_DIN_V1)
  806. setSetting("board", 76);
  807. setSetting("ledGPIO", 0, 16);
  808. setSetting("ledLogic", 0, 0);
  809. setSetting("btnGPIO", 0, 0);
  810. setSetting("btnRelay", 0, 0);
  811. setSetting("relayGPIO", 0, 4);
  812. setSetting("relayGPIO", 1, 5);
  813. setSetting("relayType", 0, RELAY_TYPE_NORMAL);
  814. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  815. #else
  816. // Allow users to define new settings without migration config
  817. //#error "UNSUPPORTED HARDWARE!"
  818. #endif
  819. }
  820. saveSettings();
  821. }