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.

1842 lines
64 KiB

  1. /*
  2. HARDWARE MODULE
  3. Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
  4. */
  5. void _hardwareMigrateMoveIndexDown(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. // 4: based on Embedis, added sensors and force resetting
  21. void _hardwareMigrate() {
  22. moveSetting("boardName", "device");
  23. moveSettings("relayGPIO", "rlyGPIO");
  24. moveSettings("relayResetGPIO", "rlyResetGPIO");
  25. moveSettings("relayType", "rlyType");
  26. moveSetting("selGPIO", "hlwSELGPIO");
  27. moveSetting("cfGPIO", "hlwCFGPIO");
  28. moveSetting("cf1GPIO", "hlwCF1GPIO");
  29. moveSetting("relayProvider", "rlyProvider");
  30. moveSetting("lightProvider", "litProvider");
  31. moveSetting("relays", "rlyDummy");
  32. moveSettings("chGPIO", "litChGPIO");
  33. moveSettings("chLogic", "litChLogic");
  34. moveSetting("enGPIO", "litEnableGPIO");
  35. moveSetting("hlwSelC", "hlwCurLevel");
  36. moveSetting("hlwIntM", "hlwInt");
  37. delSetting("ledWifi");
  38. // Get config version
  39. unsigned int board = getSetting("board", 0).toInt();
  40. unsigned int config_version = getSetting("cfg", board > 0 ? 2 : 1).toInt();
  41. setSetting("cfg", CFG_VERSION);
  42. if (config_version == 2) {
  43. _hardwareMigrateMoveIndexDown("ledGPIO");
  44. _hardwareMigrateMoveIndexDown("ledLogic");
  45. _hardwareMigrateMoveIndexDown("btnGPIO");
  46. _hardwareMigrateMoveIndexDown("btnRelay", -1);
  47. _hardwareMigrateMoveIndexDown("rlyGPIO");
  48. _hardwareMigrateMoveIndexDown("rlyType");
  49. }
  50. }
  51. /*
  52. void _hardwareLoad() {
  53. #ifndef ESPURNA_CORE
  54. char buffer[device_config_len+1];
  55. strncpy_P(buffer, (const char *) device_config, device_config_len);
  56. buffer[device_config_len] = 0;
  57. DynamicJsonBuffer jsonBuffer;
  58. JsonObject& json = jsonBuffer.parseObject(buffer);
  59. json["app"] = APP_NAME;
  60. settingsRestoreJson(json);
  61. #endif
  62. }
  63. */
  64. void _hardwareLoad() {
  65. // -------------------------------------------------------------------------
  66. // Board definitions
  67. // -------------------------------------------------------------------------
  68. #if defined(NODEMCU_LOLIN)
  69. setSetting("board", 2);
  70. setSetting("device", "NODEMCU_LOLIN");
  71. setSetting("btnGPIO", 0, 0);
  72. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  73. setSetting("btnRelay", 0, 0);
  74. setSetting("ledGPIO", 0, 2);
  75. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  76. setSetting("rlyGPIO", 0, 12);
  77. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  78. #elif defined(WEMOS_D1_MINI_RELAYSHIELD)
  79. setSetting("board", 3);
  80. setSetting("device", "WEMOS_D1_MINI_RELAYSHIELD");
  81. setSetting("btnGPIO", 0, 0);
  82. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  83. setSetting("btnRelay", 0, 0);
  84. setSetting("ledGPIO", 0, 2);
  85. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  86. setSetting("rlyGPIO", 0, 5);
  87. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  88. #elif defined(ITEAD_SONOFF_BASIC)
  89. setSetting("board", 4);
  90. setSetting("device", "ITEAD_SONOFF_BASIC");
  91. setSetting("btnGPIO", 0, 0);
  92. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  93. setSetting("btnRelay", 0, 0);
  94. setSetting("ledGPIO", 0, 13);
  95. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  96. setSetting("rlyGPIO", 0, 12);
  97. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  98. #elif defined(ITEAD_SONOFF_TH)
  99. setSetting("board", 5);
  100. setSetting("device", "ITEAD_SONOFF_TH");
  101. setSetting("btnGPIO", 0, 0);
  102. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  103. setSetting("btnRelay", 0, 0);
  104. setSetting("dhtEnabled", 1);
  105. setSetting("dhtGPIO", 0, 14);
  106. setSetting("dsEnabled", 1);
  107. setSetting("dsGPIO", 0, 14);
  108. setSetting("ledGPIO", 0, 13);
  109. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  110. setSetting("rlyGPIO", 0, 12);
  111. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  112. #elif defined(ITEAD_SONOFF_SV)
  113. setSetting("board", 6);
  114. setSetting("device", "ITEAD_SONOFF_SV");
  115. setSetting("btnGPIO", 0, 0);
  116. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  117. setSetting("btnRelay", 0, 0);
  118. setSetting("ledGPIO", 0, 13);
  119. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  120. setSetting("rlyGPIO", 0, 12);
  121. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  122. #elif defined(ITEAD_SONOFF_TOUCH)
  123. setSetting("board", 7);
  124. setSetting("device", "ITEAD_SONOFF_TOUCH");
  125. setSetting("btnGPIO", 0, 0);
  126. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  127. setSetting("btnRelay", 0, 0);
  128. setSetting("btnPress", 0, BUTTON_MODE_TOGGLE);
  129. setSetting("btnClick", 0, BUTTON_MODE_NONE);
  130. setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
  131. setSetting("btnLngClick", 0, BUTTON_MODE_NONE);
  132. setSetting("btnLngLngClick", 0, BUTTON_MODE_RESET);
  133. setSetting("ledGPIO", 0, 13);
  134. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  135. setSetting("rlyGPIO", 0, 12);
  136. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  137. #elif defined(ITEAD_SONOFF_POW)
  138. setSetting("board", 8);
  139. setSetting("device", "ITEAD_SONOFF_POW");
  140. setSetting("btnGPIO", 0, 0);
  141. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  142. setSetting("btnRelay", 0, 0);
  143. setSetting("ledGPIO", 0, 15);
  144. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  145. setSetting("rlyGPIO", 0, 12);
  146. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  147. setSetting("hlwEnabled", 1);
  148. setSetting("hlwSELGPIO", 5);
  149. setSetting("hlwCF1GPIO", 13);
  150. setSetting("hlwCFGPIO", 14);
  151. #elif defined(ITEAD_SONOFF_DUAL)
  152. setSetting("board", 9);
  153. setSetting("device", "ITEAD_SONOFF_DUAL");
  154. setSetting("btnRelay", 0, GPIO_INVALID);
  155. setSetting("btnRelay", 1, GPIO_INVALID);
  156. setSetting("btnRelay", 2, 0);
  157. setSetting("ledGPIO", 0, 13);
  158. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  159. setSetting("rlyProvider", RELAY_PROVIDER_DUAL);
  160. setSetting("rlyDummy", 2);
  161. setSetting("dbgSerial", 0);
  162. setSetting("dbgBaudrate", 19230);
  163. #elif defined(ITEAD_1CH_INCHING)
  164. // The inching functionality is managed by a misterious IC in the board.
  165. // You cannot control the inching button and functionality from the ESP8266
  166. // Besides, enabling the inching functionality using the hardware button
  167. // will result in the relay switching on and off continuously.
  168. // Fortunately the unkown IC keeps memory of the hardware inching status
  169. // so you can just disable it and forget. The inching LED must be lit.
  170. // You can still use the pulse options from the web interface
  171. // without problem.
  172. setSetting("board", 10);
  173. setSetting("device", "ITEAD_1CH_INCHING");
  174. setSetting("btnGPIO", 0, 0);
  175. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  176. setSetting("btnRelay", 0, 0);
  177. setSetting("ledGPIO", 0, 13);
  178. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  179. setSetting("rlyGPIO", 0, 12);
  180. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  181. #elif defined(ITEAD_SONOFF_4CH)
  182. setSetting("board", 11);
  183. setSetting("device", "ITEAD_SONOFF_4CH");
  184. setSetting("btnGPIO", 0, 0);
  185. setSetting("btnGPIO", 1, 9);
  186. setSetting("btnGPIO", 2, 10);
  187. setSetting("btnGPIO", 3, 14);
  188. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  189. setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  190. setSetting("btnMode", 2, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  191. setSetting("btnMode", 3, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  192. setSetting("btnRelay", 0, 0);
  193. setSetting("btnRelay", 1, 1);
  194. setSetting("btnRelay", 2, 2);
  195. setSetting("btnRelay", 3, 3);
  196. setSetting("ledGPIO", 0, 13);
  197. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  198. setSetting("rlyGPIO", 0, 12);
  199. setSetting("rlyGPIO", 1, 5);
  200. setSetting("rlyGPIO", 2, 4);
  201. setSetting("rlyGPIO", 3, 15);
  202. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  203. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  204. setSetting("rlyType", 2, RELAY_TYPE_NORMAL);
  205. setSetting("rlyType", 3, RELAY_TYPE_NORMAL);
  206. #elif defined(ITEAD_SLAMPHER)
  207. setSetting("board", 12);
  208. setSetting("device", "ITEAD_SLAMPHER");
  209. setSetting("btnGPIO", 0, 0);
  210. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  211. setSetting("btnRelay", 0, 0);
  212. setSetting("ledGPIO", 0, 13);
  213. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  214. setSetting("rlyGPIO", 0, 12);
  215. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  216. #elif defined(ITEAD_S20)
  217. setSetting("board", 13);
  218. setSetting("device", "ITEAD_S20");
  219. setSetting("btnGPIO", 0, 0);
  220. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  221. setSetting("btnRelay", 0, 0);
  222. setSetting("ledGPIO", 0, 13);
  223. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  224. setSetting("rlyGPIO", 0, 12);
  225. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  226. #elif defined(ELECTRODRAGON_WIFI_IOT)
  227. setSetting("board", 14);
  228. setSetting("device", "ELECTRODRAGON_WIFI_IOT");
  229. setSetting("btnGPIO", 0, 0);
  230. setSetting("btnGPIO", 1, 2);
  231. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  232. setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  233. setSetting("btnRelay", 0, 0);
  234. setSetting("btnRelay", 1, 1);
  235. setSetting("ledGPIO", 0, 16);
  236. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  237. setSetting("rlyGPIO", 0, 12);
  238. setSetting("rlyGPIO", 1, 13);
  239. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  240. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  241. #elif defined(WORKCHOICE_ECOPLUG)
  242. setSetting("board", 15);
  243. setSetting("device", "WORKCHOICE_ECOPLUG");
  244. setSetting("btnGPIO", 0, 13);
  245. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  246. setSetting("btnRelay", 0, 0);
  247. setSetting("ledGPIO", 0, 2);
  248. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  249. setSetting("rlyGPIO", 0, 15);
  250. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  251. #elif defined(JANGOE_WIFI_RELAY_NC)
  252. // Jan Goedeke Wifi Relay
  253. // https://github.com/JanGoe/esp8266-wifi-relay
  254. setSetting("board", 16);
  255. setSetting("device", "JANGOE_WIFI_RELAY_NC");
  256. setSetting("btnGPIO", 0, 12);
  257. setSetting("btnGPIO", 1, 13);
  258. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  259. setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  260. setSetting("btnRelay", 0, 0);
  261. setSetting("btnRelay", 1, 1);
  262. setSetting("rlyGPIO", 0, 2);
  263. setSetting("rlyGPIO", 1, 14);
  264. setSetting("rlyType", 0, RELAY_TYPE_INVERSE);
  265. setSetting("rlyType", 1, RELAY_TYPE_INVERSE);
  266. #elif defined(JANGOE_WIFI_RELAY_NO)
  267. setSetting("board", 17);
  268. setSetting("device", "JANGOE_WIFI_RELAY_NO");
  269. setSetting("btnGPIO", 0, 12);
  270. setSetting("btnGPIO", 1, 13);
  271. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  272. setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  273. setSetting("btnRelay", 0, 0);
  274. setSetting("btnRelay", 1, 1);
  275. setSetting("rlyGPIO", 0, 2);
  276. setSetting("rlyGPIO", 1, 14);
  277. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  278. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  279. #elif defined(OPENENERGYMONITOR_MQTT_RELAY)
  280. setSetting("board", 18);
  281. setSetting("device", "OPENENERGYMONITOR_MQTT_RELAY");
  282. setSetting("btnGPIO", 0, 0);
  283. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  284. setSetting("btnRelay", 0, 0);
  285. setSetting("ledGPIO", 0, 16);
  286. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  287. setSetting("rlyGPIO", 0, 12);
  288. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  289. #elif defined(JORGEGARCIA_WIFI_RELAYS)
  290. // Jorge García Wifi+Relays Board Kit
  291. // https://www.tindie.com/products/jorgegarciadev/wifi--relays-board-kit
  292. // https://github.com/jorgegarciadev/wifikit
  293. setSetting("board", 19);
  294. setSetting("device", "JORGEGARCIA_WIFI_RELAYS");
  295. setSetting("rlyGPIO", 0, 0);
  296. setSetting("rlyGPIO", 1, 2);
  297. setSetting("rlyType", 0, RELAY_TYPE_INVERSE);
  298. setSetting("rlyType", 1, RELAY_TYPE_INVERSE);
  299. #elif defined(AITHINKER_AI_LIGHT)
  300. setSetting("board", 20);
  301. setSetting("device", "AITHINKER_AI_LIGHT");
  302. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  303. setSetting("rlyDummy", 1);
  304. setSetting("litProvider", LIGHT_PROVIDER_MY92XX);
  305. setSetting("myModel", MY92XX_MODEL_MY9291); // 4 channels per chip
  306. setSetting("myChips", 1);
  307. setSetting("myDIGPIO", 13);
  308. setSetting("myDCKIGPIO", 15);
  309. setSetting("myMapping", "0123");
  310. #elif defined(MAGICHOME_LED_CONTROLLER)
  311. setSetting("board", 21);
  312. setSetting("device", "MAGICHOME_LED_CONTROLLER");
  313. setSetting("ledGPIO", 0, 2);
  314. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  315. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  316. setSetting("rlyDummy", 1);
  317. setSetting("irEnabled", 1);
  318. setSetting("irGPIO", 4);
  319. setSetting("irSet", 1);
  320. setSetting("litProvider", LIGHT_PROVIDER_DIMMER);
  321. setSetting("litChGPIO", 0, 14);
  322. setSetting("litChGPIO", 1, 5);
  323. setSetting("litChGPIO", 2, 12);
  324. setSetting("litChGPIO", 3, 13);
  325. setSetting("litChLogic", 0, GPIO_LOGIC_DIRECT);
  326. setSetting("litChLogic", 1, GPIO_LOGIC_DIRECT);
  327. setSetting("litChLogic", 2, GPIO_LOGIC_DIRECT);
  328. setSetting("litChLogic", 3, GPIO_LOGIC_DIRECT);
  329. #elif defined(ITEAD_MOTOR)
  330. setSetting("board", 22);
  331. setSetting("device", "ITEAD_MOTOR");
  332. setSetting("btnGPIO", 0, 0);
  333. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  334. setSetting("btnRelay", 0, 0);
  335. setSetting("ledGPIO", 0, 13);
  336. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  337. setSetting("rlyGPIO", 0, 12);
  338. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  339. #elif defined(TINKERMAN_ESPURNA_H06)
  340. setSetting("board", 23);
  341. setSetting("device", "TINKERMAN_ESPURNA_H06");
  342. setSetting("btnGPIO", 0, 4);
  343. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  344. setSetting("btnRelay", 0, 0);
  345. setSetting("ledGPIO", 0, 5);
  346. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  347. setSetting("rlyGPIO", 0, 12);
  348. setSetting("rlyType", 0, RELAY_TYPE_INVERSE);
  349. setSetting("hlwEnabled", 1);
  350. setSetting("hlwSELGPIO", 2);
  351. setSetting("hlwCF1GPIO", 13);
  352. setSetting("hlwCFGPIO", 14);
  353. #elif defined(HUACANXING_H801)
  354. setSetting("board", 24);
  355. setSetting("device", "HUACANXING_H801");
  356. setSetting("ledGPIO", 0, 5);
  357. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  358. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  359. setSetting("rlyDummy", 1);
  360. setSetting("dbgPort", 1);
  361. setSetting("dbgRXEnabled", 1);
  362. setSetting("litProvider", LIGHT_PROVIDER_DIMMER);
  363. setSetting("litChGPIO", 0, 15);
  364. setSetting("litChGPIO", 1, 13);
  365. setSetting("litChGPIO", 2, 12);
  366. setSetting("litChGPIO", 3, 14);
  367. setSetting("litChGPIO", 4, 4);
  368. setSetting("litChLogic", 0, GPIO_LOGIC_DIRECT);
  369. setSetting("litChLogic", 1, GPIO_LOGIC_DIRECT);
  370. setSetting("litChLogic", 2, GPIO_LOGIC_DIRECT);
  371. setSetting("litChLogic", 3, GPIO_LOGIC_DIRECT);
  372. setSetting("litChLogic", 4, GPIO_LOGIC_DIRECT);
  373. #elif defined(ITEAD_BNSZ01)
  374. setSetting("board", 25);
  375. setSetting("device", "ITEAD_BNSZ01");
  376. setSetting("ledGPIO", 0, 13);
  377. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  378. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  379. setSetting("rlyDummy", 1);
  380. setSetting("litProvider", LIGHT_PROVIDER_DIMMER);
  381. setSetting("litChGPIO", 0, 12);
  382. setSetting("litChLogic", 0, GPIO_LOGIC_DIRECT);
  383. #elif defined(ITEAD_SONOFF_RFBRIDGE)
  384. setSetting("board", 26);
  385. setSetting("device", "ITEAD_SONOFF_RFBRIDGE");
  386. setSetting("btnGPIO", 0, 0);
  387. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  388. setSetting("ledGPIO", 0, 13);
  389. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  390. setSetting("rlyProvider", RELAY_PROVIDER_RFBRIDGE);
  391. setSetting("rlyDummy", 8);
  392. // When using un-modified harware, ESPurna communicates with the secondary
  393. // MCU EFM8BB1 via UART at 19200 bps so we need to change the speed of
  394. // the port and remove UART noise on serial line
  395. setSetting("dbgSerial", 0);
  396. setSetting("dbgBaudrate", 19200);
  397. setSetting("rfbDirect", 0);
  398. setSetting("rfbRXGPIO", 4);
  399. setSetting("rfbTXGPIO", 5);
  400. #elif defined(ITEAD_SONOFF_4CH_PRO)
  401. setSetting("board", 27);
  402. setSetting("device", "ITEAD_SONOFF_4CH_PRO");
  403. setSetting("btnGPIO", 0, 0);
  404. setSetting("btnGPIO", 1, 9);
  405. setSetting("btnGPIO", 2, 10);
  406. setSetting("btnGPIO", 3, 14);
  407. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  408. setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  409. setSetting("btnMode", 2, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  410. setSetting("btnMode", 3, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  411. setSetting("btnRelay", 0, 0);
  412. setSetting("btnRelay", 1, 1);
  413. setSetting("btnRelay", 2, 2);
  414. setSetting("btnRelay", 3, 3);
  415. // Sonoff 4CH Pro uses a secondary STM32 microcontroller to handle
  416. // buttons and relays, but it also forwards button presses to the ESP8285.
  417. // This allows ESPurna to handle button presses -almost- the same way
  418. // as with other devices except:
  419. // * Double click seems to break/disable the button on the STM32 side
  420. // * With S6 switch to 1 (self-locking and inching modes) everything's OK
  421. // * With S6 switch to 0 (interlock mode) if there is a relay ON
  422. // and you click on another relay button, the STM32 sends a "press"
  423. // event for the button of the first relay (to turn it OFF) but it
  424. // does not send a "release" event. It's like it's holding the
  425. // button down since you can see it is still LOW.
  426. // Whatever reason the result is that it may actually perform a
  427. // long click or long-long click.
  428. // The configuration below make the button toggle the relay on press events
  429. // and disables any possibly harmful combination with S6 set to 0.
  430. // If you are sure you will only use S6 to 1 you can comment the
  431. // btnLngClick(0) and btnLngLngClick(0) options below to recover the
  432. // reset mode and factory reset functionalities, or link other actions like
  433. // AP mode in the commented line below.
  434. setSetting("btnPress", 0, BUTTON_MODE_TOGGLE);
  435. setSetting("btnClick", 0, BUTTON_MODE_NONE);
  436. setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
  437. setSetting("btnLngClick", 0, BUTTON_MODE_NONE); // or BUTTON_MODE_AP
  438. setSetting("btnLngLngClick", 0, BUTTON_MODE_NONE); // or BUTTON_MODE_FACTORY
  439. setSetting("btnPress", 1, BUTTON_MODE_TOGGLE);
  440. setSetting("btnClick", 1, BUTTON_MODE_NONE);
  441. setSetting("btnPress", 2, BUTTON_MODE_TOGGLE);
  442. setSetting("btnClick", 2, BUTTON_MODE_NONE);
  443. setSetting("btnPress", 3, BUTTON_MODE_TOGGLE);
  444. setSetting("btnClick", 3, BUTTON_MODE_NONE);
  445. setSetting("ledGPIO", 0, 13);
  446. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  447. setSetting("rlyGPIO", 0, 12);
  448. setSetting("rlyGPIO", 1, 5);
  449. setSetting("rlyGPIO", 2, 4);
  450. setSetting("rlyGPIO", 3, 15);
  451. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  452. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  453. setSetting("rlyType", 2, RELAY_TYPE_NORMAL);
  454. setSetting("rlyType", 3, RELAY_TYPE_NORMAL);
  455. #elif defined(ITEAD_SONOFF_B1)
  456. setSetting("board", 28);
  457. setSetting("device", "ITEAD_SONOFF_B1");
  458. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  459. setSetting("rlyDummy", 1);
  460. setSetting("litProvider", LIGHT_PROVIDER_MY92XX);
  461. setSetting("litChFactor", 4, 0.1); // White LEDs are way more bright in the B1
  462. setSetting("litChFactor", 5, 0.1); // White LEDs are way more bright in the B1
  463. setSetting("myModel", MY92XX_MODEL_MY9231); // 3 channels per chip
  464. setSetting("myChips", 2);
  465. setSetting("myDIGPIO", 12);
  466. setSetting("myDCKIGPIO", 14);
  467. setSetting("myMapping", "43501"); // TODO
  468. #elif defined(ITEAD_SONOFF_LED)
  469. setSetting("board", 29);
  470. setSetting("device", "ITEAD_SONOFF_LED");
  471. setSetting("ledGPIO", 0, 13);
  472. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  473. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  474. setSetting("rlyDummy", 1);
  475. setSetting("litProvider", LIGHT_PROVIDER_DIMMER);
  476. setSetting("litChGPIO", 0, 12); // Cold white
  477. setSetting("litChGPIO", 1, 14); // Warm white
  478. setSetting("litChLogic", 0, GPIO_LOGIC_DIRECT);
  479. setSetting("litChLogic", 1, GPIO_LOGIC_DIRECT);
  480. #elif defined(ITEAD_SONOFF_T1_1CH)
  481. setSetting("board", 30);
  482. setSetting("device", "ITEAD_SONOFF_T1_1CH");
  483. setSetting("btnGPIO", 0, 0);
  484. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  485. setSetting("btnRelay", 0, 0);
  486. setSetting("btnPress", 0, BUTTON_MODE_TOGGLE);
  487. setSetting("btnClick", 0, BUTTON_MODE_NONE);
  488. setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
  489. setSetting("btnLngClick", 0, BUTTON_MODE_NONE);
  490. setSetting("btnLngLngClick", 0, BUTTON_MODE_RESET);
  491. setSetting("ledGPIO", 0, 13);
  492. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  493. setSetting("rlyGPIO", 0, 12);
  494. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  495. #elif defined(ITEAD_SONOFF_T1_2CH)
  496. setSetting("board", 31);
  497. setSetting("device", "ITEAD_SONOFF_T1_2CH");
  498. setSetting("btnGPIO", 0, 0);
  499. setSetting("btnGPIO", 1, 9);
  500. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  501. setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  502. setSetting("btnRelay", 0, 0);
  503. setSetting("btnRelay", 1, 1);
  504. setSetting("btnPress", 0, BUTTON_MODE_TOGGLE);
  505. setSetting("btnPress", 1, BUTTON_MODE_TOGGLE);
  506. setSetting("btnClick", 0, BUTTON_MODE_NONE);
  507. setSetting("btnClick", 1, BUTTON_MODE_NONE);
  508. setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
  509. setSetting("btnDblClick", 1, BUTTON_MODE_NONE);
  510. setSetting("btnLngClick", 0, BUTTON_MODE_NONE);
  511. setSetting("btnLngClick", 1, BUTTON_MODE_NONE);
  512. setSetting("btnLngLngClick", 0, BUTTON_MODE_RESET);
  513. setSetting("btnLngLngClick", 1, BUTTON_MODE_RESET);
  514. setSetting("ledGPIO", 0, 13);
  515. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  516. setSetting("rlyGPIO", 0, 12);
  517. setSetting("rlyGPIO", 1, 5);
  518. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  519. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  520. #elif defined(ITEAD_SONOFF_T1_3CH)
  521. setSetting("board", 32);
  522. setSetting("device", "ITEAD_SONOFF_T1_3CH");
  523. setSetting("btnGPIO", 0, 0);
  524. setSetting("btnGPIO", 1, 9);
  525. setSetting("btnGPIO", 2, 10);
  526. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  527. setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  528. setSetting("btnMode", 2, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  529. setSetting("btnRelay", 0, 0);
  530. setSetting("btnRelay", 1, 1);
  531. setSetting("btnRelay", 2, 2);
  532. setSetting("btnPress", 0, BUTTON_MODE_TOGGLE);
  533. setSetting("btnPress", 1, BUTTON_MODE_TOGGLE);
  534. setSetting("btnPress", 2, BUTTON_MODE_TOGGLE);
  535. setSetting("btnClick", 0, BUTTON_MODE_NONE);
  536. setSetting("btnClick", 1, BUTTON_MODE_NONE);
  537. setSetting("btnClick", 2, BUTTON_MODE_NONE);
  538. setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
  539. setSetting("btnDblClick", 1, BUTTON_MODE_NONE);
  540. setSetting("btnDblClick", 2, BUTTON_MODE_NONE);
  541. setSetting("btnLngClick", 0, BUTTON_MODE_NONE);
  542. setSetting("btnLngClick", 1, BUTTON_MODE_NONE);
  543. setSetting("btnLngClick", 2, BUTTON_MODE_NONE);
  544. setSetting("btnLngLngClick", 0, BUTTON_MODE_RESET);
  545. setSetting("btnLngLngClick", 1, BUTTON_MODE_RESET);
  546. setSetting("btnLngLngClick", 2, BUTTON_MODE_RESET);
  547. setSetting("ledGPIO", 0, 13);
  548. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  549. setSetting("rlyGPIO", 0, 12);
  550. setSetting("rlyGPIO", 1, 5);
  551. setSetting("rlyGPIO", 2, 4);
  552. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  553. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  554. setSetting("rlyType", 2, RELAY_TYPE_NORMAL);
  555. #elif defined(ITEAD_SONOFF_RF)
  556. setSetting("board", 33);
  557. setSetting("device", "ITEAD_SONOFF_RF");
  558. setSetting("btnGPIO", 0, 0);
  559. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  560. setSetting("btnRelay", 0, 0);
  561. setSetting("ledGPIO", 0, 13);
  562. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  563. setSetting("rlyGPIO", 0, 12);
  564. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  565. #elif defined(WION_50055)
  566. // WiOn 50055 Indoor Wi-Fi Wall Outlet & Tap
  567. // https://rover.ebay.com/rover/1/711-53200-19255-0/1?icep_id=114&ipn=icep&toolid=20004&campid=5338044841&mpre=http%3A%2F%2Fwww.ebay.com%2Fitm%2FWiOn-50050-Indoor-Wi-Fi-Outlet-Wireless-Switch-Programmable-Timer-%2F263112281551
  568. // https://rover.ebay.com/rover/1/711-53200-19255-0/1?icep_id=114&ipn=icep&toolid=20004&campid=5338044841&mpre=http%3A%2F%2Fwww.ebay.com%2Fitm%2FWiOn-50055-Indoor-Wi-Fi-Wall-Tap-Monitor-Energy-Usage-Wireless-Smart-Switch-%2F263020837777
  569. // Does not support power monitoring yet
  570. setSetting("board", 34);
  571. setSetting("device", "WION_50055");
  572. setSetting("btnGPIO", 0, 13);
  573. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  574. setSetting("btnRelay", 0, 0);
  575. setSetting("ledGPIO", 0, 2);
  576. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  577. setSetting("rlyGPIO", 0, 15);
  578. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  579. #elif defined(EXS_WIFI_RELAY_V31)
  580. // EX-Store Wifi Relay v3.1
  581. // https://ex-store.de/ESP8266-WiFi-Relay-V31
  582. setSetting("board", 35);
  583. setSetting("device", "EXS_WIFI_RELAY_V31");
  584. setSetting("btnGPIO", 0, 0);
  585. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  586. setSetting("btnRelay", 0, 0);
  587. setSetting("rlyGPIO", 0, 13);
  588. setSetting("rlyResetGPIO", 0, 12);
  589. setSetting("rlyType", 0, RELAY_TYPE_LATCHED);
  590. #elif defined(HUACANXING_H802)
  591. setSetting("board", 36);
  592. setSetting("device", "HUACANXING_H802");
  593. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  594. setSetting("rlyDummy", 1);
  595. setSetting("dbgPort", 1);
  596. setSetting("dbgRXEnabled", 1);
  597. setSetting("litProvider", LIGHT_PROVIDER_DIMMER);
  598. setSetting("litChGPIO", 0, 12);
  599. setSetting("litChGPIO", 1, 14);
  600. setSetting("litChGPIO", 2, 13);
  601. setSetting("litChGPIO", 3, 15);
  602. setSetting("litChLogic", 0, GPIO_LOGIC_DIRECT);
  603. setSetting("litChLogic", 1, GPIO_LOGIC_DIRECT);
  604. setSetting("litChLogic", 2, GPIO_LOGIC_DIRECT);
  605. setSetting("litChLogic", 3, GPIO_LOGIC_DIRECT);
  606. #elif defined(GENERIC_V9261F)
  607. setSetting("board", 37);
  608. setSetting("device", "GENERIC_V9261F");
  609. setSetting("v92Enabled", 1);
  610. setSetting("v92GPIO", 2);
  611. setSetting("v92Logic", GPIO_LOGIC_INVERSE);
  612. #elif defined(GENERIC_ECH1560)
  613. setSetting("board", 38);
  614. setSetting("device", "GENERIC_ECH1560");
  615. setSetting("echEnabled", 1);
  616. setSetting("echCLKGPIO", 4);
  617. setSetting("echMISOGPIO", 5);
  618. setSetting("echLogic", GPIO_LOGIC_INVERSE);
  619. #elif defined(TINKERMAN_ESPURNA_H08)
  620. setSetting("board", 39);
  621. setSetting("device", "TINKERMAN_ESPURNA_H08");
  622. setSetting("btnGPIO", 0, 4);
  623. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  624. setSetting("btnRelay", 0, 0);
  625. setSetting("ledGPIO", 0, 2);
  626. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  627. setSetting("rlyGPIO", 0, 12);
  628. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  629. setSetting("hlwEnabled", 1);
  630. setSetting("hlwSELGPIO", 5);
  631. setSetting("hlwCF1GPIO", 13);
  632. setSetting("hlwCFGPIO", 14);
  633. #elif defined(MANCAVEMADE_ESPLIVE)
  634. // ESPLive
  635. // https://github.com/ManCaveMade/ESP-Live
  636. setSetting("board", 40);
  637. setSetting("device", "MANCAVEMADE_ESPLIVE");
  638. setSetting("btnGPIO", 0, 4);
  639. setSetting("btnGPIO", 1, 5);
  640. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  641. setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  642. setSetting("btnRelay", 0, 0);
  643. setSetting("btnRelay", 1, 1);
  644. // The ESPLive has an ADC MUX which needs to be enabled
  645. setSetting("ledGPIO", 0, 16);
  646. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  647. setSetting("ledMode", LED_MODE_ON);
  648. setSetting("rlyGPIO", 0, 12);
  649. setSetting("rlyGPIO", 1, 13);
  650. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  651. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  652. setSetting("dsEnabled", 1);
  653. setSetting("dsGPIO", 0, 2);
  654. #elif defined(INTERMITTECH_QUINLED)
  655. // QuinLED
  656. // http://blog.quindorian.org/2017/02/esp8266-led-lighting-quinled-v2-6-pcb.html
  657. setSetting("board", 41);
  658. setSetting("device", "INTERMITTECH_QUINLED");
  659. setSetting("ledGPIO", 0, 5);
  660. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  661. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  662. setSetting("rlyDummy", 1);
  663. setSetting("litProvider", LIGHT_PROVIDER_DIMMER);
  664. setSetting("litChGPIO", 0, 0);
  665. setSetting("litChGPIO", 1, 2);
  666. setSetting("litChLogic", 0, GPIO_LOGIC_DIRECT);
  667. setSetting("litChLogic", 1, GPIO_LOGIC_DIRECT);
  668. #elif defined(MAGICHOME_LED_CONTROLLER_20)
  669. setSetting("board", 42);
  670. setSetting("device", "MAGICHOME_LED_CONTROLLER_20");
  671. setSetting("ledGPIO", 0, 2);
  672. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  673. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  674. setSetting("rlyDummy", 1);
  675. setSetting("irEnabled", 1);
  676. setSetting("irGPIO", 4);
  677. setSetting("irSet", 1);
  678. setSetting("litProvider", LIGHT_PROVIDER_DIMMER);
  679. setSetting("litChGPIO", 0, 5);
  680. setSetting("litChGPIO", 1, 12);
  681. setSetting("litChGPIO", 2, 13);
  682. setSetting("litChGPIO", 3, 15);
  683. setSetting("litChLogic", 0, GPIO_LOGIC_DIRECT);
  684. setSetting("litChLogic", 1, GPIO_LOGIC_DIRECT);
  685. setSetting("litChLogic", 2, GPIO_LOGIC_DIRECT);
  686. setSetting("litChLogic", 3, GPIO_LOGIC_DIRECT);
  687. #elif defined(ARILUX_AL_LC06)
  688. setSetting("board", 43);
  689. setSetting("device", "ARILUX_AL_LC06");
  690. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  691. setSetting("rlyDummy", 1);
  692. setSetting("litProvider", LIGHT_PROVIDER_DIMMER);
  693. setSetting("litChGPIO", 0, 14);
  694. setSetting("litChGPIO", 1, 12);
  695. setSetting("litChGPIO", 2, 13);
  696. setSetting("litChGPIO", 3, 15);
  697. setSetting("litChGPIO", 4, 5);
  698. setSetting("litChLogic", 0, GPIO_LOGIC_DIRECT);
  699. setSetting("litChLogic", 1, GPIO_LOGIC_DIRECT);
  700. setSetting("litChLogic", 2, GPIO_LOGIC_DIRECT);
  701. setSetting("litChLogic", 3, GPIO_LOGIC_DIRECT);
  702. setSetting("litChLogic", 4, GPIO_LOGIC_DIRECT);
  703. #elif defined(XENON_SM_PW702U)
  704. setSetting("board", 44);
  705. setSetting("device", "XENON_SM_PW702U");
  706. setSetting("btnGPIO", 0, 13);
  707. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  708. setSetting("btnRelay", 0, 0);
  709. setSetting("ledGPIO", 0, 4);
  710. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  711. setSetting("rlyGPIO", 0, 12);
  712. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  713. #elif defined(AUTHOMETION_LYT8266)
  714. // AUTHOMETION LYT8266
  715. // https://authometion.com/shop/en/home/13-lyt8266.html
  716. setSetting("board", 45);
  717. setSetting("device", "AUTHOMETION_LYT8266");
  718. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  719. setSetting("rlyDummy", 1);
  720. setSetting("litProvider", LIGHT_PROVIDER_DIMMER);
  721. setSetting("litChGPIO", 0, 13);
  722. setSetting("litChGPIO", 1, 12);
  723. setSetting("litChGPIO", 2, 14);
  724. setSetting("litChGPIO", 3, 2);
  725. setSetting("litChLogic", 0, GPIO_LOGIC_DIRECT);
  726. setSetting("litChLogic", 1, GPIO_LOGIC_DIRECT);
  727. setSetting("litChLogic", 2, GPIO_LOGIC_DIRECT);
  728. setSetting("litChLogic", 3, GPIO_LOGIC_DIRECT);
  729. setSetting("litEnableGPIO", 15);
  730. setSetting("litEnableLogic", GPIO_LOGIC_DIRECT);
  731. #elif defined(ARILUX_E27)
  732. setSetting("board", 46);
  733. setSetting("device", "ARILUX_E27");
  734. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  735. setSetting("rlyDummy", 1);
  736. setSetting("litProvider", LIGHT_PROVIDER_MY92XX);
  737. setSetting("myModel", MY92XX_MODEL_MY9291); // 4 channels per chip
  738. setSetting("myChips", 1);
  739. setSetting("myDIGPIO", 13);
  740. setSetting("myDCKIGPIO", 15);
  741. setSetting("myMapping", "0123");
  742. #elif defined(YJZK_SWITCH_2CH)
  743. setSetting("board", 47);
  744. setSetting("device", "YJZK_SWITCH_2CH");
  745. setSetting("btnGPIO", 0, 0);
  746. setSetting("btnGPIO", 1, 9);
  747. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  748. setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  749. setSetting("btnRelay", 0, 0);
  750. setSetting("btnRelay", 1, 1);
  751. setSetting("ledGPIO", 0, 13);
  752. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  753. setSetting("rlyGPIO", 0, 12);
  754. setSetting("rlyGPIO", 1, 5);
  755. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  756. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  757. #elif defined(ITEAD_SONOFF_DUAL_R2)
  758. setSetting("board", 48);
  759. setSetting("device", "ITEAD_SONOFF_DUAL_R2");
  760. setSetting("btnGPIO", 0, 0);
  761. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  762. setSetting("btnRelay", 0, 0);
  763. setSetting("btnGPIO", 1, 9);
  764. setSetting("btnGPIO", 2, 10);
  765. setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  766. setSetting("btnMode", 2, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  767. setSetting("btnRelay", 1, 1);
  768. setSetting("btnRelay", 2, 0);
  769. setSetting("ledGPIO", 0, 13);
  770. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  771. setSetting("rlyGPIO", 0, 12);
  772. setSetting("rlyGPIO", 1, 5);
  773. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  774. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  775. #elif defined(GENERIC_8CH)
  776. setSetting("board", 49);
  777. setSetting("device", "GENERIC_8CH");
  778. setSetting("rlyGPIO", 0, 0);
  779. setSetting("rlyGPIO", 1, 2);
  780. setSetting("rlyGPIO", 2, 4);
  781. setSetting("rlyGPIO", 3, 5);
  782. setSetting("rlyGPIO", 4, 12);
  783. setSetting("rlyGPIO", 5, 13);
  784. setSetting("rlyGPIO", 6, 14);
  785. setSetting("rlyGPIO", 7, 15);
  786. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  787. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  788. setSetting("rlyType", 2, RELAY_TYPE_NORMAL);
  789. setSetting("rlyType", 3, RELAY_TYPE_NORMAL);
  790. setSetting("rlyType", 4, RELAY_TYPE_NORMAL);
  791. setSetting("rlyType", 5, RELAY_TYPE_NORMAL);
  792. setSetting("rlyType", 6, RELAY_TYPE_NORMAL);
  793. setSetting("rlyType", 7, RELAY_TYPE_NORMAL);
  794. #elif defined(ARILUX_AL_LC01)
  795. setSetting("board", 50);
  796. setSetting("device", "ARILUX_AL_LC01");
  797. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  798. setSetting("rlyDummy", 1);
  799. setSetting("litProvider", LIGHT_PROVIDER_DIMMER);
  800. setSetting("litChGPIO", 0, 5);
  801. setSetting("litChGPIO", 1, 12);
  802. setSetting("litChGPIO", 2, 13);
  803. setSetting("litChLogic", 0, GPIO_LOGIC_DIRECT);
  804. setSetting("litChLogic", 1, GPIO_LOGIC_DIRECT);
  805. setSetting("litChLogic", 2, GPIO_LOGIC_DIRECT);
  806. #elif defined(ARILUX_AL_LC11)
  807. setSetting("board", 51);
  808. setSetting("device", "ARILUX_AL_LC11");
  809. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  810. setSetting("rlyDummy", 1);
  811. setSetting("litProvider", LIGHT_PROVIDER_DIMMER);
  812. setSetting("litChGPIO", 0, 5);
  813. setSetting("litChGPIO", 1, 4);
  814. setSetting("litChGPIO", 2, 14);
  815. setSetting("litChGPIO", 3, 13);
  816. setSetting("litChGPIO", 4, 12);
  817. setSetting("litChLogic", 0, GPIO_LOGIC_DIRECT);
  818. setSetting("litChLogic", 1, GPIO_LOGIC_DIRECT);
  819. setSetting("litChLogic", 2, GPIO_LOGIC_DIRECT);
  820. setSetting("litChLogic", 3, GPIO_LOGIC_DIRECT);
  821. setSetting("litChLogic", 4, GPIO_LOGIC_DIRECT);
  822. #elif defined(ARILUX_AL_LC02)
  823. setSetting("board", 52);
  824. setSetting("device", "ARILUX_AL_LC02");
  825. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  826. setSetting("rlyDummy", 1);
  827. setSetting("litProvider", LIGHT_PROVIDER_DIMMER);
  828. setSetting("litChGPIO", 0, 12);
  829. setSetting("litChGPIO", 1, 5);
  830. setSetting("litChGPIO", 2, 13);
  831. setSetting("litChGPIO", 3, 15);
  832. setSetting("litChLogic", 0, GPIO_LOGIC_DIRECT);
  833. setSetting("litChLogic", 1, GPIO_LOGIC_DIRECT);
  834. setSetting("litChLogic", 2, GPIO_LOGIC_DIRECT);
  835. setSetting("litChLogic", 3, GPIO_LOGIC_DIRECT);
  836. #elif defined(KMC_70011)
  837. // KMC 70011
  838. // https://www.amazon.com/KMC-Monitoring-Required-Control-Compatible/dp/B07313TH7B
  839. setSetting("board", 53);
  840. setSetting("device", "KMC_70011");
  841. setSetting("btnGPIO", 0, 0);
  842. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  843. setSetting("btnRelay", 0, 0);
  844. setSetting("ledGPIO", 0, 13);
  845. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  846. setSetting("rlyGPIO", 0, 14);
  847. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  848. setSetting("hlwEnabled", 1);
  849. setSetting("hlwSELGPIO", 12);
  850. setSetting("hlwCF1GPIO", 5);
  851. setSetting("hlwCFGPIO", 4);
  852. setSetting("hlwVolResUp", 2000000);
  853. #elif defined(GIZWITS_WITTY_CLOUD)
  854. setSetting("board", 54);
  855. setSetting("device", "GIZWITS_WITTY_CLOUD");
  856. setSetting("btnGPIO", 0, 4);
  857. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  858. setSetting("btnPress", 0, BUTTON_MODE_TOGGLE);
  859. setSetting("btnClick", 0, BUTTON_MODE_NONE);
  860. setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
  861. setSetting("btnLngClick", 0, BUTTON_MODE_NONE);
  862. setSetting("btnLngLngClick", 0, BUTTON_MODE_RESET);
  863. setSetting("ledGPIO", 0, 2);
  864. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  865. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  866. setSetting("rlyDummy", 1);
  867. setSetting("anaEnabled", 1);
  868. setSetting("litProvider", LIGHT_PROVIDER_DIMMER);
  869. setSetting("litChGPIO", 0, 15);
  870. setSetting("litChGPIO", 1, 12);
  871. setSetting("litChGPIO", 2, 13);
  872. setSetting("litChLogic", 0, GPIO_LOGIC_DIRECT);
  873. setSetting("litChLogic", 1, GPIO_LOGIC_DIRECT);
  874. setSetting("litChLogic", 2, GPIO_LOGIC_DIRECT);
  875. #elif defined(EUROMATE_WIFI_STECKER_SCHUKO)
  876. // Euromate (?) Wifi Stecker Shuko
  877. // https://www.obi.de/hausfunksteuerung/wifi-stecker-schuko/p/2291706
  878. // Thanks to @Geitde
  879. // The relay in the device is not a bistable (latched) relay.
  880. // The device is reported to have a flip-flop circuit to drive the relay
  881. // So @Geitde hack is still the only possible
  882. // Hack: drive GPIO12 low and use GPIO5 as normal relay pin:
  883. setSetting("board", 55);
  884. setSetting("device", "EUROMATE_WIFI_STECKER_SCHUKO");
  885. setSetting("btnGPIO", 0, 14);
  886. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH | BUTTON_SET_PULLUP);
  887. setSetting("btnRelay", 0, 0);
  888. setSetting("ledGPIO", 0, 4);
  889. setSetting("ledGPIO", 1, 12);
  890. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  891. setSetting("ledLogic", 1, GPIO_LOGIC_DIRECT);
  892. setSetting("rlyGPIO", 0, 5);
  893. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  894. #elif defined(TONBUX_POWERSTRIP02)
  895. setSetting("board", 56);
  896. setSetting("device", "TONBUX_POWERSTRIP02");
  897. setSetting("btnGPIO", 0, 5);
  898. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  899. setSetting("btnRelay", 0, 1);
  900. setSetting("ledGPIO", 0, 0); // 1 blue led
  901. setSetting("ledGPIO", 1, 3); // 3 red leds
  902. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  903. setSetting("ledLogic", 1, GPIO_LOGIC_INVERSE);
  904. setSetting("rlyGPIO", 0, 4);
  905. setSetting("rlyGPIO", 1, 13);
  906. setSetting("rlyGPIO", 2, 12);
  907. setSetting("rlyGPIO", 3, 14);
  908. setSetting("rlyGPIO", 4, 16); // Not a relay. USB ports on/off
  909. setSetting("rlyType", 0, RELAY_TYPE_INVERSE);
  910. setSetting("rlyType", 1, RELAY_TYPE_INVERSE);
  911. setSetting("rlyType", 2, RELAY_TYPE_INVERSE);
  912. setSetting("rlyType", 3, RELAY_TYPE_INVERSE);
  913. setSetting("rlyType", 4, RELAY_TYPE_NORMAL); // Not a relay. USB ports on/off
  914. #elif defined(LINGAN_SWA1)
  915. setSetting("board", 57);
  916. setSetting("device", "LINGAN_SWA1");
  917. setSetting("btnGPIO", 0, 13);
  918. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH | BUTTON_SET_PULLUP);
  919. setSetting("btnRelay", 0, 0);
  920. setSetting("ledGPIO", 0, 4);
  921. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  922. setSetting("rlyGPIO", 0, 5);
  923. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  924. #elif defined(HEYGO_HY02)
  925. setSetting("board", 58);
  926. setSetting("device", "HEYGO_HY02");
  927. setSetting("btnGPIO", 0, 13);
  928. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  929. setSetting("btnRelay", 0, 0);
  930. setSetting("ledGPIO", 0, 4);
  931. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  932. setSetting("rlyGPIO", 0, 12);
  933. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  934. #elif defined(MAXCIO_WUS002S)
  935. setSetting("board", 59);
  936. setSetting("device", "MAXCIO_WUS002S");
  937. setSetting("btnGPIO", 0, 2);
  938. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  939. setSetting("btnRelay", 0, 0);
  940. setSetting("ledGPIO", 0, 3);
  941. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  942. setSetting("rlyGPIO", 0, 13);
  943. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  944. setSetting("hlwEnabled", 1);
  945. setSetting("hlwSELGPIO", 12);
  946. setSetting("hlwCF1GPIO", 5);
  947. setSetting("hlwCFGPIO", 4);
  948. setSetting("hlwCurRes", 0.002);
  949. setSetting("hlwVolResUp", 2000000);
  950. #elif defined(YIDIAN_XSSSA05)
  951. setSetting("board", 60);
  952. setSetting("device", "YIDIAN_XSSSA05");
  953. setSetting("btnGPIO", 0, 13);
  954. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  955. setSetting("btnRelay", 0, 0);
  956. setSetting("ledGPIO", 0, 4);
  957. setSetting("ledGPIO", 2, 2);
  958. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  959. setSetting("ledLogic", 2, GPIO_LOGIC_DIRECT);
  960. setSetting("rlyGPIO", 0, 12);
  961. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  962. setSetting("hlwEnabled", 1);
  963. setSetting("hlwSELGPIO", 3);
  964. setSetting("hlwCF1GPIO", 14);
  965. setSetting("hlwCFGPIO", 5);
  966. setSetting("hlwVolResUp", 2400000);
  967. #elif defined(TONBUX_XSSSA06)
  968. setSetting("board", 61);
  969. setSetting("device", "TONBUX_XSSSA06");
  970. setSetting("btnGPIO", 0, 13);
  971. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  972. setSetting("btnRelay", 0, 0);
  973. setSetting("ledGPIO", 0, 0); // Red
  974. setSetting("ledGPIO", 0, 5); // Green
  975. setSetting("ledGPIO", 0, 2); // Blue
  976. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  977. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  978. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  979. setSetting("rlyGPIO", 0, 15);
  980. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  981. #elif defined(GREEN_ESP8266RELAY)
  982. // GREEN ESP8266 RELAY MODULE
  983. // https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20180323113846&SearchText=Green+ESP8266
  984. setSetting("board", 62);
  985. setSetting("device", "GREEN_ESP8266RELAY");
  986. setSetting("btnGPIO", 0, 5);
  987. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  988. setSetting("btnRelay", 0, 0);
  989. setSetting("ledGPIO", 0, 2);
  990. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  991. setSetting("rlyGPIO", 0, 4);
  992. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  993. #elif defined(IKE_ESPIKE)
  994. // Henrique Gravina ESPIKE
  995. // https://github.com/Henriquegravina/Espike
  996. setSetting("board", 63);
  997. setSetting("device", "IKE_ESPIKE");
  998. setSetting("btnGPIO", 0, 13);
  999. setSetting("btnGPIO", 1, 12);
  1000. setSetting("btnGPIO", 2, 14);
  1001. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1002. setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1003. setSetting("btnMode", 2, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1004. setSetting("btnRelay", 0, 0);
  1005. setSetting("btnRelay", 1, 1);
  1006. setSetting("btnRelay", 2, 2);
  1007. setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
  1008. setSetting("btnLngClick", 0, BUTTON_MODE_NONE);
  1009. setSetting("btnLngLngClick", 0, BUTTON_MODE_NONE);
  1010. setSetting("ledGPIO", 0, 2);
  1011. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1012. setSetting("rlyGPIO", 0, 4);
  1013. setSetting("rlyGPIO", 1, 5);
  1014. setSetting("rlyGPIO", 2, 16);
  1015. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1016. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  1017. setSetting("rlyType", 2, RELAY_TYPE_NORMAL);
  1018. #elif defined(ARNIEX_SWIFITCH)
  1019. // SWIFITCH
  1020. // https://github.com/ArnieX/swifitch
  1021. setSetting("board", 64);
  1022. setSetting("device", "ARNIEX_SWIFITCH");
  1023. setSetting("btnGPIO", 0, 4);
  1024. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH | BUTTON_SET_PULLUP);
  1025. setSetting("btnRelay", 0, 1);
  1026. setSetting("btnPress", 0, BUTTON_MODE_NONE);
  1027. setSetting("btnClick", 0, BUTTON_MODE_TOGGLE);
  1028. setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
  1029. setSetting("btnLngClick", 0, BUTTON_MODE_NONE);
  1030. setSetting("btnLngLngClick", 0, BUTTON_MODE_NONE);
  1031. setSetting("ledGPIO", 0, 12);
  1032. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1033. setSetting("rlyGPIO", 0, 5);
  1034. setSetting("rlyType", 0, RELAY_TYPE_INVERSE);
  1035. #elif defined(GENERIC_ESP01S_RELAY_V40)
  1036. // ESP-01S RELAY v4.0
  1037. // https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20180404024035&SearchText=esp-01s+relay
  1038. setSetting("board", 65);
  1039. setSetting("device", "GENERIC_ESP01S_RELAY_V40");
  1040. setSetting("ledGPIO", 0, 2);
  1041. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  1042. setSetting("rlyGPIO", 0, 0);
  1043. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1044. #elif defined(GENERIC_ESP01S_RGBLED_V10)
  1045. // ESP-01S RGB LED v1.0 (some sold with ws2818)
  1046. // https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20180404023816&SearchText=esp-01s+led+controller
  1047. setSetting("board", 66);
  1048. setSetting("device", "GENERIC_ESP01S_RGBLED_V10");
  1049. setSetting("ledGPIO", 0, 2);
  1050. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  1051. #elif defined(HELTEC_TOUCHRELAY)
  1052. // Heltec Touch Relay
  1053. // https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20180408043114&SearchText=esp8266+touch+relay
  1054. setSetting("board", 67);
  1055. setSetting("device", "HELTEC_TOUCHRELAY");
  1056. setSetting("btnGPIO", 0, 14);
  1057. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1058. setSetting("btnRelay", 0, 1);
  1059. setSetting("rlyGPIO", 0, 12);
  1060. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1061. #elif defined(GENERIC_ESP01S_DHT11_V10)
  1062. // ESP-01S DHT11 v1.0
  1063. // https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20180410105907&SearchText=esp-01s+dht11
  1064. setSetting("board", 68);
  1065. setSetting("device", "GENERIC_ESP01S_DHT11_V10");
  1066. setSetting("dhtEnabled", 1);
  1067. setSetting("dhtGPIO", 0, 2);
  1068. setSetting("dhtType", 0, DHT_CHIP_DHT11);
  1069. #elif defined(GENERIC_ESP01S_DS18B20_V10)
  1070. // ESP-01S DS18B20 v1.0
  1071. // https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20180410105933&SearchText=esp-01s+ds18b20
  1072. setSetting("board", 69);
  1073. setSetting("device", "GENERIC_ESP01S_DS18B20_V10");
  1074. setSetting("dsEnabled", 1);
  1075. setSetting("dsGPIO", 0, 2);
  1076. #elif defined(ZHILDE_EU44_W)
  1077. // Zhilde ZLD-EU44-W
  1078. // http://www.zhilde.com/product/60705150109-805652505/EU_WiFi_Surge_Protector_Extension_Socket_4_Outlets_works_with_Amazon_Echo_Smart_Power_Strip.html
  1079. setSetting("board", 70);
  1080. setSetting("device", "ZHILDE_EU44_W");
  1081. setSetting("btnGPIO", 0, 3);
  1082. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1083. setSetting("btnRelay", 0, 0);
  1084. setSetting("ledGPIO", 0, 1);
  1085. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1086. setSetting("rlyGPIO", 0, 5);
  1087. setSetting("rlyGPIO", 1, 4);
  1088. setSetting("rlyGPIO", 2, 12);
  1089. setSetting("rlyGPIO", 3, 13);
  1090. setSetting("rlyGPIO", 4, 14);
  1091. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1092. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  1093. setSetting("rlyType", 2, RELAY_TYPE_NORMAL);
  1094. setSetting("rlyType", 3, RELAY_TYPE_NORMAL);
  1095. setSetting("rlyType", 4, RELAY_TYPE_NORMAL);
  1096. // Based on the reporter, this product uses GPIO1 and 3 for the button
  1097. // and onboard LED, so hardware serial should be disabled...
  1098. setSetting("dbgSerial", 0);
  1099. #elif defined(ITEAD_SONOFF_POW_R2)
  1100. setSetting("board", 71);
  1101. setSetting("device", "ITEAD_SONOFF_POW_R2");
  1102. setSetting("btnGPIO", 0, 0);
  1103. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1104. setSetting("btnRelay", 0, 0);
  1105. setSetting("ledGPIO", 0, 13);
  1106. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1107. setSetting("rlyGPIO", 0, 12);
  1108. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1109. setSetting("cseEnabled", 1);
  1110. setSetting("cseGPIO", 1);
  1111. setSetting("dbgSerial", 0);
  1112. #elif defined(LUANI_HVIO)
  1113. // Luani HVIO
  1114. // https://luani.de/projekte/esp8266-hvio/
  1115. // https://luani.de/blog/esp8266-230v-io-modul/
  1116. setSetting("board", 72);
  1117. setSetting("device", "LUANI_HVIO");
  1118. setSetting("ledGPIO", 0, 15);
  1119. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  1120. setSetting("btnGPIO", 0, 12);
  1121. setSetting("btnGPIO", 1, 13);
  1122. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1123. setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1124. setSetting("btnRelay", 0, 0);
  1125. setSetting("btnRelay", 1, 1);
  1126. setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
  1127. setSetting("rlyGPIO", 0, 4);
  1128. setSetting("rlyGPIO", 1, 5);
  1129. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1130. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  1131. #elif defined(ALLNET_4DUINO_IOT_WLAN_RELAIS)
  1132. // Allnet 4duino ESP8266-UP-Relais
  1133. // http://www.allnet.de/de/allnet-brand/produkte/neuheiten/p/allnet-4duino-iot-wlan-relais-unterputz-esp8266-up-relais/
  1134. // https://shop.allnet.de/fileadmin/transfer/products/148814.pdf
  1135. setSetting("board", 73);
  1136. setSetting("device", "ALLNET_4DUINO_IOT_WLAN_RELAIS");
  1137. setSetting("ledGPIO", 0, 0);
  1138. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1139. setSetting("rlyGPIO", 0, 14);
  1140. setSetting("rlyResetGPIO", 0, 12);
  1141. setSetting("rlyType", 0, RELAY_TYPE_LATCHED);
  1142. #elif defined(TONBUX_MOSQUITO_KILLER)
  1143. // Tonbux 50-100M Smart Mosquito Killer USB
  1144. // https://www.aliexpress.com/item/Original-Tonbux-50-100M-Smart-Mosquito-Killer-USB-Plug-No-Noise-Repellent-App-Smart-Module/32859330820.html
  1145. setSetting("board", 74);
  1146. setSetting("device", "TONBUX_MOSQUITO_KILLER");
  1147. setSetting("btnGPIO", 0, 2);
  1148. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1149. setSetting("btnRelay", 0, 0);
  1150. setSetting("ledGPIO", 0, 15);
  1151. setSetting("ledGPIO", 1, 14);
  1152. setSetting("ledGPIO", 2, 12);
  1153. setSetting("ledGPIO", 3, 16);
  1154. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1155. setSetting("ledLogic", 1, GPIO_LOGIC_INVERSE);
  1156. setSetting("ledLogic", 2, GPIO_LOGIC_DIRECT);
  1157. setSetting("ledLogic", 3, GPIO_LOGIC_DIRECT);
  1158. setSetting("ledMode", 0, LED_MODE_WIFI);
  1159. setSetting("ledMode", 1, LED_MODE_RELAY);
  1160. setSetting("ledRelay", 1, 0);
  1161. setSetting("rlyGPIO", 0, 5); // Fan
  1162. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1163. #elif defined(NEO_COOLCAM_NAS_WR01W)
  1164. // NEO Coolcam NAS-WR01W Wifi Smart Power Plug
  1165. // https://es.aliexpress.com/item/-/32854589733.html?spm=a219c.12010608.0.0.6d084e68xX0y5N
  1166. // https://www.fasttech.com/product/9649426-neo-coolcam-nas-wr01w-wifi-smart-power-plug-eu
  1167. setSetting("board", 75);
  1168. setSetting("device", "NEO_COOLCAM_NAS_WR01W");
  1169. setSetting("btnGPIO", 0, 13);
  1170. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1171. setSetting("btnRelay", 0, 0);
  1172. setSetting("ledGPIO", 0, 4);
  1173. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1174. setSetting("rlyGPIO", 0, 12);
  1175. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1176. #elif defined(PILOTAK_ESP_DIN_V1)
  1177. // ESP-DIN relay board V1
  1178. // https://github.com/pilotak/esp_din
  1179. setSetting("board", 76);
  1180. setSetting("device", "PILOTAK_ESP_DIN_V1");
  1181. setSetting("btnGPIO", 0, 0);
  1182. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1183. setSetting("btnRelay", 0, 0);
  1184. setSetting("ledGPIO", 0, 15);
  1185. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  1186. setSetting("rlyGPIO", 0, 4);
  1187. setSetting("rlyGPIO", 1, 5);
  1188. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1189. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  1190. setSetting("digEnabled", 1);
  1191. setSetting("digGPIO", 0, 16);
  1192. setSetting("digMode", 0, INPUT);
  1193. setSetting("dsEnabled", 1);
  1194. setSetting("dsGPIO", 0, 2);
  1195. setSetting("i2cEnable", 1);
  1196. setSetting("i2cSDAGPIO", 12);
  1197. setSetting("i2cSCLGPIO", 13);
  1198. setSetting("rfEnabled", 1);
  1199. setSetting("rfGPIO", 14);
  1200. #elif defined(ESTINK_WIFI_POWER_STRIP)
  1201. // Estink Wifi Power Strip
  1202. // https://www.amazon.de/Steckdosenleiste-Ladeger%C3%A4t-Sprachsteuerung-SmartphonesTablets-Android/dp/B0796W5FZY
  1203. // Fornorm Wi-Fi USB Extension Socket (ZLD-34EU)
  1204. // https://www.aliexpress.com/item/Fornorm-WiFi-Extension-Socket-with-Surge-Protector-Smart-Power-Strip-3-Outlets-and-4-USB-Charging/32849743948.html
  1205. setSetting("board", 77);
  1206. setSetting("device", "ESTINK_WIFI_POWER_STRIP");
  1207. setSetting("btnGPIO", 0, 16);
  1208. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1209. setSetting("btnRelay", 0, 3);
  1210. setSetting("ledGPIO", 0, 0);
  1211. setSetting("ledGPIO", 1, 12);
  1212. setSetting("ledGPIO", 2, 3);
  1213. setSetting("ledGPIO", 3, 5);
  1214. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1215. setSetting("ledLogic", 1, GPIO_LOGIC_INVERSE);
  1216. setSetting("ledLogic", 2, GPIO_LOGIC_INVERSE);
  1217. setSetting("ledLogic", 3, GPIO_LOGIC_INVERSE);
  1218. setSetting("ledMode", 0, LED_MODE_FINDME);
  1219. setSetting("ledMode", 1, LED_MODE_FOLLOW);
  1220. setSetting("ledMode", 2, LED_MODE_FOLLOW);
  1221. setSetting("ledMode", 3, LED_MODE_FOLLOW);
  1222. setSetting("ledRelay", 1, 1);
  1223. setSetting("ledRelay", 2, 2);
  1224. setSetting("ledRelay", 3, 3);
  1225. setSetting("rlyGPIO", 0, 14); // USB power
  1226. setSetting("rlyGPIO", 1, 13); // power plug 1
  1227. setSetting("rlyGPIO", 2, 4); // power plug 2
  1228. setSetting("rlyGPIO", 3, 15); // power plug 3
  1229. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1230. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  1231. setSetting("rlyType", 2, RELAY_TYPE_NORMAL);
  1232. setSetting("rlyType", 3, RELAY_TYPE_NORMAL);
  1233. setSetting("dbgSerial", 0);
  1234. #elif defined(BH_ONOFRE)
  1235. // Bruno Horta's OnOfre
  1236. // https://www.bhonofre.pt/
  1237. // https://github.com/brunohorta82/BH_OnOfre/
  1238. setSetting("board", 78);
  1239. setSetting("device", "BH_ONOFRE");
  1240. setSetting("btnGPIO", 0, 12);
  1241. setSetting("btnGPIO", 1, 13);
  1242. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH | BUTTON_SET_PULLUP);
  1243. setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH | BUTTON_SET_PULLUP);
  1244. setSetting("btnRelay", 0, 0);
  1245. setSetting("btnRelay", 1, 1);
  1246. setSetting("rlyGPIO", 0, 4);
  1247. setSetting("rlyGPIO", 1, 5);
  1248. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1249. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  1250. #elif defined(BLITZWOLF_BWSHP2)
  1251. // Several boards under different names uing a power chip labelled BL0937 or HJL-01
  1252. // * Blitzwolf (https://www.amazon.es/Inteligente-Temporización-Dispositivos-Cualquier-BlitzWolf/dp/B07BMQP142)
  1253. // * HomeCube (https://www.amazon.de/Steckdose-Homecube-intelligente-Verbrauchsanzeige-funktioniert/dp/B076Q2LKHG)
  1254. // * Coosa (https://www.amazon.com/COOSA-Monitoring-Function-Campatible-Assiatant/dp/B0788W9TDR)
  1255. // * Goosund (http://www.gosund.com/?m=content&c=index&a=show&catid=6&id=5)
  1256. // * Ablue (https://www.amazon.de/Intelligente-Steckdose-Ablue-Funktioniert-Assistant/dp/B076DRFRZC)
  1257. setSetting("board", 79);
  1258. setSetting("device", "BLITZWOLF_BWSHP2");
  1259. setSetting("btnGPIO", 0, 13);
  1260. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1261. setSetting("btnRelay", 0, 0);
  1262. setSetting("ledGPIO", 0, 2);
  1263. setSetting("ledGPIO", 1, 0);
  1264. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1265. setSetting("ledLogic", 1, GPIO_LOGIC_INVERSE);
  1266. setSetting("ledMode", 0, LED_MODE_WIFI);
  1267. setSetting("ledMode", 1, LED_MODE_FINDME);
  1268. setSetting("ledRelay", 1, 0);
  1269. setSetting("rlyGPIO", 0, 15);
  1270. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1271. setSetting("hlwSELGPIO", 12);
  1272. setSetting("hlwCF1GPIO", 14);
  1273. setSetting("hlwCFGPIO", 5);
  1274. setSetting("hlwCurLevel", LOW);
  1275. setSetting("hlwInt", FALLING);
  1276. setSetting("curRatio", 25740);
  1277. setSetting("volRatio", 313400);
  1278. setSetting("pwrRatio", 3414290);
  1279. #elif defined(TINKERMAN_ESPURNA_SWITCH)
  1280. setSetting("board", 80);
  1281. setSetting("device", "TINKERMAN_ESPURNA_SWITCH");
  1282. setSetting("btnGPIO", 0, 4);
  1283. setSetting("btnMode", 0, BUTTON_PUSHBUTTON);
  1284. setSetting("btnPress", 0, BUTTON_MODE_TOGGLE);
  1285. setSetting("btnClick", 0, BUTTON_MODE_NONE);
  1286. setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
  1287. setSetting("btnLngClick", 0, BUTTON_MODE_NONE);
  1288. setSetting("btnLngLngClick", 0, BUTTON_MODE_NONE);
  1289. setSetting("btnRelay", 0, 0);
  1290. setSetting("ledGPIO", 0, 2);
  1291. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  1292. setSetting("rlyGPIO", 0, 12);
  1293. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1294. #elif defined(ITEAD_SONOFF_S31)
  1295. setSetting("board", 81);
  1296. setSetting("device", "ITEAD_SONOFF_S31");
  1297. setSetting("btnGPIO", 0, 0);
  1298. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1299. setSetting("btnRelay", 0, 0);
  1300. setSetting("ledGPIO", 0, 13);
  1301. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1302. setSetting("rlyGPIO", 0, 12);
  1303. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1304. setSetting("cseEnabled", 1);
  1305. setSetting("cseGPIO", 1);
  1306. setSetting("dbgSerial", 0);
  1307. #elif defined(STM_RELAY)
  1308. setSetting("board", 82);
  1309. setSetting("device", "STM_RELAY");
  1310. setSetting("rlyDummy", 2);
  1311. setSetting("rlyProvider", RELAY_PROVIDER_STM)
  1312. setSetting("dbgSerial", 0);
  1313. #elif defined(VANZAVANZU_SMART_WIFI_PLUG_MINI)
  1314. // VANZAVANZU Smart Outlet Socket (based on BL0937 or HJL-01)
  1315. // https://www.amazon.com/Smart-Plug-Wifi-Mini-VANZAVANZU/dp/B078PHD6S5
  1316. setSetting("board", 83);
  1317. setSetting("device", "VANZAVANZU_SMART_WIFI_PLUG_MINI");
  1318. setSetting("btnGPIO", 0, 13);
  1319. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1320. setSetting("btnRelay", 0, 0);
  1321. setSetting("ledGPIO", 0, 2);
  1322. setSetting("ledGPIO", 1, 0);
  1323. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1324. setSetting("ledLogic", 1, GPIO_LOGIC_INVERSE);
  1325. setSetting("ledMode", 0, LED_MODE_WIFI);
  1326. setSetting("ledMode", 1, LED_MODE_FINDME);
  1327. setSetting("ledRelay", 1, 0);
  1328. setSetting("rlyGPIO", 0, 15);
  1329. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1330. setSetting("hlwSELGPIO", 3);
  1331. setSetting("hlwCF1GPIO", 14);
  1332. setSetting("hlwCFGPIO", 5);
  1333. setSetting("hlwCurLevel", LOW);
  1334. setSetting("hlwInt", FALLING);
  1335. setSetting("curRatio", 25740);
  1336. setSetting("volRatio", 313400);
  1337. setSetting("pwrRatio", 3414290);
  1338. #elif defined(GENERIC_GEIGER_COUNTER)
  1339. setSetting("board", 84);
  1340. setSetting("device", "GENERIC_GEIGER_COUNTER");
  1341. setSetting("geiEnabled", 1);
  1342. #elif defined(TINKERMAN_RFM69GW)
  1343. // Check http://tinkerman.cat/rfm69-wifi-gateway/
  1344. setSetting("board", 85);
  1345. setSetting("device", "TINKERMAN_RFM69GW");
  1346. setSetting("btnGPIO", 0, 0);
  1347. setSetting("rfm69Enabled", 1);
  1348. setSetting("rfm69CSGPIO", 15);
  1349. setSetting("rfm69IRQGPIO", 5);
  1350. setSetting("rfm69ResetGPIO", 7);
  1351. setSetting("rfm69HW", 0)
  1352. #endif
  1353. }
  1354. void _hardwareSpecific() {
  1355. // These devices use the hardware UART
  1356. // to communicate to secondary microcontrollers
  1357. #if defined(ITEAD_SONOFF_RFBRIDGE) || defined(ITEAD_SONOFF_DUAL) || defined(STM_RELAY)
  1358. Serial.begin(DEBUG_SERIAL_SPEED);
  1359. #endif
  1360. }
  1361. void hardwareSetup() {
  1362. _hardwareMigrate();
  1363. if (getSetting("board", 1).toInt() != 1) {
  1364. _hardwareLoad();
  1365. }
  1366. _hardwareSpecific();
  1367. }