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.

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