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.

1907 lines
68 KiB

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