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.

2030 lines
73 KiB

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