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.

2049 lines
74 KiB

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