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.

2269 lines
82 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_1CH)
  742. setSetting("board", DEVICE_YJZK_SWITCH_1CH);
  743. setSetting("device", "YJZK_SWITCH_1CH");
  744. setSetting("fw", ESPURNA_BASIC);
  745. setSetting("btnGPIO", 0, 0);
  746. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  747. setSetting("btnRelay", 0, 0);
  748. setSetting("btnPress", 0, BUTTON_MODE_TOGGLE);
  749. setSetting("btnClick", 0, BUTTON_MODE_NONE);
  750. setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
  751. setSetting("btnLngClick", 0, BUTTON_MODE_NONE);
  752. setSetting("btnLngLngClick", 0, BUTTON_MODE_RESET);
  753. setSetting("ledGPIO", 0, 13);
  754. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  755. setSetting("rlyGPIO", 0, 12);
  756. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  757. #elif defined(YJZK_SWITCH_2CH)
  758. setSetting("board", DEVICE_YJZK_SWITCH_2CH);
  759. setSetting("device", "YJZK_SWITCH_2CH");
  760. setSetting("fw", ESPURNA_BASIC);
  761. setSetting("btnGPIO", 0, 0);
  762. setSetting("btnGPIO", 1, 9);
  763. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  764. setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  765. setSetting("btnRelay", 0, 0);
  766. setSetting("btnRelay", 1, 1);
  767. setSetting("btnPress", 0, BUTTON_MODE_TOGGLE);
  768. setSetting("btnClick", 0, BUTTON_MODE_NONE);
  769. setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
  770. setSetting("btnLngClick", 0, BUTTON_MODE_NONE);
  771. setSetting("btnLngLngClick", 0, BUTTON_MODE_RESET);
  772. setSetting("btnPress", 1, BUTTON_MODE_TOGGLE);
  773. setSetting("btnClick", 1, BUTTON_MODE_NONE);
  774. setSetting("btnDblClick", 1, BUTTON_MODE_NONE);
  775. setSetting("btnLngClick", 1, BUTTON_MODE_NONE);
  776. setSetting("btnLngLngClick", 1, BUTTON_MODE_RESET);
  777. setSetting("ledGPIO", 0, 13);
  778. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  779. setSetting("rlyGPIO", 0, 12);
  780. setSetting("rlyGPIO", 1, 5);
  781. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  782. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  783. #elif defined(YJZK_SWITCH_3CH)
  784. setSetting("board", DEVICE_YJZK_SWITCH_3CH);
  785. setSetting("device", "YJZK_SWITCH_3CH");
  786. setSetting("fw", ESPURNA_BASIC);
  787. setSetting("btnGPIO", 0, 0);
  788. setSetting("btnGPIO", 1, 9);
  789. setSetting("btnGPIO", 2, 10);
  790. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  791. setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  792. setSetting("btnMode", 2, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  793. setSetting("btnRelay", 0, 0);
  794. setSetting("btnRelay", 1, 1);
  795. setSetting("btnRelay", 2, 2);
  796. setSetting("btnPress", 0, BUTTON_MODE_TOGGLE);
  797. setSetting("btnClick", 0, BUTTON_MODE_NONE);
  798. setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
  799. setSetting("btnLngClick", 0, BUTTON_MODE_NONE);
  800. setSetting("btnLngLngClick", 0, BUTTON_MODE_RESET);
  801. setSetting("btnPress", 1, BUTTON_MODE_TOGGLE);
  802. setSetting("btnClick", 1, BUTTON_MODE_NONE);
  803. setSetting("btnDblClick", 1, BUTTON_MODE_NONE);
  804. setSetting("btnLngClick", 1, BUTTON_MODE_NONE);
  805. setSetting("btnLngLngClick", 1, BUTTON_MODE_RESET);
  806. setSetting("btnPress", 2, BUTTON_MODE_TOGGLE);
  807. setSetting("btnClick", 2, BUTTON_MODE_NONE);
  808. setSetting("btnDblClick", 2, BUTTON_MODE_NONE);
  809. setSetting("btnLngClick", 2, BUTTON_MODE_NONE);
  810. setSetting("btnLngLngClick", 2, BUTTON_MODE_RESET);
  811. setSetting("ledGPIO", 0, 13);
  812. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  813. setSetting("rlyGPIO", 0, 12);
  814. setSetting("rlyGPIO", 1, 5);
  815. setSetting("rlyGPIO", 2, 4);
  816. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  817. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  818. setSetting("rlyType", 2, RELAY_TYPE_NORMAL);
  819. #elif defined(ITEAD_SONOFF_DUAL_R2)
  820. setSetting("board", DEVICE_ITEAD_SONOFF_DUAL_R2);
  821. setSetting("device", "ITEAD_SONOFF_DUAL_R2");
  822. setSetting("fw", ESPURNA_BASIC);
  823. setSetting("btnGPIO", 0, 0);
  824. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  825. setSetting("btnRelay", 0, 0);
  826. setSetting("btnGPIO", 1, 9);
  827. setSetting("btnGPIO", 2, 10);
  828. setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  829. setSetting("btnMode", 2, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  830. setSetting("btnRelay", 1, 1);
  831. setSetting("btnRelay", 2, 0);
  832. setSetting("ledGPIO", 0, 13);
  833. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  834. setSetting("rlyGPIO", 0, 12);
  835. setSetting("rlyGPIO", 1, 5);
  836. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  837. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  838. #elif defined(GENERIC_8CH)
  839. setSetting("board", DEVICE_GENERIC_8CH);
  840. setSetting("device", "GENERIC_8CH");
  841. setSetting("fw", ESPURNA_BASIC);
  842. setSetting("rlyGPIO", 0, 0);
  843. setSetting("rlyGPIO", 1, 2);
  844. setSetting("rlyGPIO", 2, 4);
  845. setSetting("rlyGPIO", 3, 5);
  846. setSetting("rlyGPIO", 4, 12);
  847. setSetting("rlyGPIO", 5, 13);
  848. setSetting("rlyGPIO", 6, 14);
  849. setSetting("rlyGPIO", 7, 15);
  850. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  851. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  852. setSetting("rlyType", 2, RELAY_TYPE_NORMAL);
  853. setSetting("rlyType", 3, RELAY_TYPE_NORMAL);
  854. setSetting("rlyType", 4, RELAY_TYPE_NORMAL);
  855. setSetting("rlyType", 5, RELAY_TYPE_NORMAL);
  856. setSetting("rlyType", 6, RELAY_TYPE_NORMAL);
  857. setSetting("rlyType", 7, RELAY_TYPE_NORMAL);
  858. #elif defined(ARILUX_AL_LC01)
  859. setSetting("board", DEVICE_ARILUX_AL_LC01);
  860. setSetting("device", "ARILUX_AL_LC01");
  861. setSetting("fw", ESPURNA_DIMMER);
  862. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  863. setSetting("rlyDummy", 1);
  864. setSetting("litChGPIO", 0, 5);
  865. setSetting("litChGPIO", 1, 12);
  866. setSetting("litChGPIO", 2, 13);
  867. setSetting("litChLogic", 0, GPIO_LOGIC_DIRECT);
  868. setSetting("litChLogic", 1, GPIO_LOGIC_DIRECT);
  869. setSetting("litChLogic", 2, GPIO_LOGIC_DIRECT);
  870. #elif defined(ARILUX_AL_LC11)
  871. setSetting("board", DEVICE_ARILUX_AL_LC11);
  872. setSetting("device", "ARILUX_AL_LC11");
  873. setSetting("fw", ESPURNA_DIMMER);
  874. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  875. setSetting("rlyDummy", 1);
  876. setSetting("litChGPIO", 0, 5);
  877. setSetting("litChGPIO", 1, 4);
  878. setSetting("litChGPIO", 2, 14);
  879. setSetting("litChGPIO", 3, 13);
  880. setSetting("litChGPIO", 4, 12);
  881. setSetting("litChLogic", 0, GPIO_LOGIC_DIRECT);
  882. setSetting("litChLogic", 1, GPIO_LOGIC_DIRECT);
  883. setSetting("litChLogic", 2, GPIO_LOGIC_DIRECT);
  884. setSetting("litChLogic", 3, GPIO_LOGIC_DIRECT);
  885. setSetting("litChLogic", 4, GPIO_LOGIC_DIRECT);
  886. #elif defined(ARILUX_AL_LC02)
  887. setSetting("board", DEVICE_ARILUX_AL_LC02);
  888. setSetting("device", "ARILUX_AL_LC02");
  889. setSetting("fw", ESPURNA_DIMMER);
  890. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  891. setSetting("rlyDummy", 1);
  892. setSetting("litChGPIO", 0, 12);
  893. setSetting("litChGPIO", 1, 5);
  894. setSetting("litChGPIO", 2, 13);
  895. setSetting("litChGPIO", 3, 15);
  896. setSetting("litChLogic", 0, GPIO_LOGIC_DIRECT);
  897. setSetting("litChLogic", 1, GPIO_LOGIC_DIRECT);
  898. setSetting("litChLogic", 2, GPIO_LOGIC_DIRECT);
  899. setSetting("litChLogic", 3, GPIO_LOGIC_DIRECT);
  900. #elif defined(KMC_70011)
  901. // KMC 70011
  902. // https://www.amazon.com/KMC-Monitoring-Required-Control-Compatible/dp/B07313TH7B
  903. setSetting("board", DEVICE_KMC_70011);
  904. setSetting("device", "KMC_70011");
  905. setSetting("fw", ESPURNA_HLW8012);
  906. setSetting("btnGPIO", 0, 0);
  907. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  908. setSetting("btnRelay", 0, 0);
  909. setSetting("ledGPIO", 0, 13);
  910. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  911. setSetting("rlyGPIO", 0, 14);
  912. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  913. setSetting("hlwEnabled", 1);
  914. setSetting("hlwSELGPIO", 12);
  915. setSetting("hlwCF1GPIO", 5);
  916. setSetting("hlwCFGPIO", 4);
  917. setSetting("hlwVolResUp", 2000000);
  918. #elif defined(GIZWITS_WITTY_CLOUD)
  919. setSetting("board", DEVICE_GIZWITS_WITTY_CLOUD);
  920. setSetting("device", "GIZWITS_WITTY_CLOUD");
  921. setSetting("fw", ESPURNA_DIMMER);
  922. setSetting("btnGPIO", 0, 4);
  923. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  924. setSetting("btnPress", 0, BUTTON_MODE_TOGGLE);
  925. setSetting("btnClick", 0, BUTTON_MODE_NONE);
  926. setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
  927. setSetting("btnLngClick", 0, BUTTON_MODE_NONE);
  928. setSetting("btnLngLngClick", 0, BUTTON_MODE_RESET);
  929. setSetting("ledGPIO", 0, 2);
  930. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  931. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  932. setSetting("rlyDummy", 1);
  933. setSetting("anaEnabled", 1);
  934. setSetting("litChGPIO", 0, 15);
  935. setSetting("litChGPIO", 1, 12);
  936. setSetting("litChGPIO", 2, 13);
  937. setSetting("litChLogic", 0, GPIO_LOGIC_DIRECT);
  938. setSetting("litChLogic", 1, GPIO_LOGIC_DIRECT);
  939. setSetting("litChLogic", 2, GPIO_LOGIC_DIRECT);
  940. #elif defined(EUROMATE_WIFI_STECKER_SCHUKO)
  941. // Euromate (?) Wifi Stecker Shuko
  942. // https://www.obi.de/hausfunksteuerung/wifi-stecker-schuko/p/2291706
  943. // Thanks to @Geitde
  944. // The relay in the device is not a bistable (latched) relay.
  945. // The device is reported to have a flip-flop circuit to drive the relay
  946. // So @Geitde hack is still the only possible
  947. // Hack: drive GPIO12 low and use GPIO5 as normal relay pin:
  948. setSetting("board", DEVICE_EUROMATE_WIFI_STECKER_SCHUKO);
  949. setSetting("device", "EUROMATE_WIFI_STECKER_SCHUKO");
  950. setSetting("fw", ESPURNA_BASIC);
  951. setSetting("btnGPIO", 0, 14);
  952. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH | BUTTON_SET_PULLUP);
  953. setSetting("btnRelay", 0, 0);
  954. setSetting("ledGPIO", 0, 4);
  955. setSetting("ledGPIO", 1, 12);
  956. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  957. setSetting("ledLogic", 1, GPIO_LOGIC_DIRECT);
  958. setSetting("rlyGPIO", 0, 5);
  959. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  960. #elif defined(TONBUX_POWERSTRIP02)
  961. setSetting("board", DEVICE_TONBUX_POWERSTRIP02);
  962. setSetting("device", "TONBUX_POWERSTRIP02");
  963. setSetting("fw", ESPURNA_BASIC);
  964. setSetting("btnGPIO", 0, 5);
  965. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  966. setSetting("btnRelay", 0, 1);
  967. setSetting("ledGPIO", 0, 0); // 1 blue led
  968. setSetting("ledGPIO", 1, 3); // 3 red leds
  969. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  970. setSetting("ledLogic", 1, GPIO_LOGIC_INVERSE);
  971. setSetting("rlyGPIO", 0, 4);
  972. setSetting("rlyGPIO", 1, 13);
  973. setSetting("rlyGPIO", 2, 12);
  974. setSetting("rlyGPIO", 3, 14);
  975. setSetting("rlyGPIO", 4, 16); // Not a relay. USB ports on/off
  976. setSetting("rlyType", 0, RELAY_TYPE_INVERSE);
  977. setSetting("rlyType", 1, RELAY_TYPE_INVERSE);
  978. setSetting("rlyType", 2, RELAY_TYPE_INVERSE);
  979. setSetting("rlyType", 3, RELAY_TYPE_INVERSE);
  980. setSetting("rlyType", 4, RELAY_TYPE_NORMAL); // Not a relay. USB ports on/off
  981. #elif defined(LINGAN_SWA1)
  982. setSetting("board", DEVICE_LINGAN_SWA1);
  983. setSetting("device", "LINGAN_SWA1");
  984. setSetting("fw", ESPURNA_BASIC);
  985. setSetting("btnGPIO", 0, 13);
  986. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH | BUTTON_SET_PULLUP);
  987. setSetting("btnRelay", 0, 0);
  988. setSetting("ledGPIO", 0, 4);
  989. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  990. setSetting("rlyGPIO", 0, 5);
  991. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  992. #elif defined(HEYGO_HY02)
  993. setSetting("board", DEVICE_HEYGO_HY02);
  994. setSetting("device", "HEYGO_HY02");
  995. setSetting("fw", ESPURNA_BASIC);
  996. setSetting("btnGPIO", 0, 13);
  997. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  998. setSetting("btnRelay", 0, 0);
  999. setSetting("ledGPIO", 0, 4);
  1000. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  1001. setSetting("rlyGPIO", 0, 12);
  1002. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1003. #elif defined(MAXCIO_WUS002S)
  1004. setSetting("board", DEVICE_MAXCIO_WUS002S);
  1005. setSetting("device", "MAXCIO_WUS002S");
  1006. setSetting("fw", ESPURNA_HLW8012);
  1007. setSetting("btnGPIO", 0, 2);
  1008. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1009. setSetting("btnRelay", 0, 0);
  1010. setSetting("ledGPIO", 0, 3);
  1011. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  1012. setSetting("rlyGPIO", 0, 13);
  1013. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1014. setSetting("hlwEnabled", 1);
  1015. setSetting("hlwSELGPIO", 12);
  1016. setSetting("hlwCF1GPIO", 5);
  1017. setSetting("hlwCFGPIO", 4);
  1018. setSetting("hlwCurRes", 0.002);
  1019. setSetting("hlwVolResUp", 2000000);
  1020. #elif defined(YIDIAN_XSSSA05)
  1021. setSetting("board", DEVICE_YIDIAN_XSSSA05);
  1022. setSetting("device", "YIDIAN_XSSSA05");
  1023. setSetting("fw", ESPURNA_HLW8012);
  1024. setSetting("btnGPIO", 0, 13);
  1025. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1026. setSetting("btnRelay", 0, 0);
  1027. setSetting("ledGPIO", 0, 4);
  1028. setSetting("ledGPIO", 2, 2);
  1029. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  1030. setSetting("ledLogic", 2, GPIO_LOGIC_DIRECT);
  1031. setSetting("rlyGPIO", 0, 12);
  1032. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1033. setSetting("hlwEnabled", 1);
  1034. setSetting("hlwSELGPIO", 3);
  1035. setSetting("hlwCF1GPIO", 14);
  1036. setSetting("hlwCFGPIO", 5);
  1037. setSetting("hlwCurRes", 0.001);
  1038. setSetting("hlwVolResUp", 2400000);
  1039. #elif defined(TONBUX_XSSSA06)
  1040. setSetting("board", DEVICE_TONBUX_XSSSA06);
  1041. setSetting("device", "TONBUX_XSSSA06");
  1042. setSetting("fw", ESPURNA_BASIC);
  1043. setSetting("btnGPIO", 0, 13);
  1044. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1045. setSetting("btnRelay", 0, 0);
  1046. setSetting("ledGPIO", 0, 0); // Red
  1047. setSetting("ledGPIO", 0, 5); // Green
  1048. setSetting("ledGPIO", 0, 2); // Blue
  1049. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  1050. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  1051. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  1052. setSetting("rlyGPIO", 0, 15);
  1053. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1054. #elif defined(GREEN_ESP8266RELAY)
  1055. // GREEN ESP8266 RELAY MODULE
  1056. // https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20180323113846&SearchText=Green+ESP8266
  1057. setSetting("board", DEVICE_GREEN_ESP8266RELAY);
  1058. setSetting("device", "GREEN_ESP8266RELAY");
  1059. setSetting("fw", ESPURNA_BASIC);
  1060. setSetting("btnGPIO", 0, 5);
  1061. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1062. setSetting("btnRelay", 0, 0);
  1063. setSetting("ledGPIO", 0, 2);
  1064. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1065. setSetting("rlyGPIO", 0, 4);
  1066. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1067. #elif defined(IKE_ESPIKE)
  1068. // Henrique Gravina ESPIKE
  1069. // https://github.com/Henriquegravina/Espike
  1070. setSetting("board", DEVICE_IKE_ESPIKE);
  1071. setSetting("device", "IKE_ESPIKE");
  1072. setSetting("fw", ESPURNA_BASIC);
  1073. setSetting("btnGPIO", 0, 13);
  1074. setSetting("btnGPIO", 1, 12);
  1075. setSetting("btnGPIO", 2, 14);
  1076. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1077. setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1078. setSetting("btnMode", 2, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1079. setSetting("btnRelay", 0, 0);
  1080. setSetting("btnRelay", 1, 1);
  1081. setSetting("btnRelay", 2, 2);
  1082. setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
  1083. setSetting("btnLngClick", 0, BUTTON_MODE_NONE);
  1084. setSetting("btnLngLngClick", 0, BUTTON_MODE_NONE);
  1085. setSetting("ledGPIO", 0, 2);
  1086. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1087. setSetting("rlyGPIO", 0, 4);
  1088. setSetting("rlyGPIO", 1, 5);
  1089. setSetting("rlyGPIO", 2, 16);
  1090. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1091. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  1092. setSetting("rlyType", 2, RELAY_TYPE_NORMAL);
  1093. #elif defined(ARNIEX_SWIFITCH)
  1094. // SWIFITCH
  1095. // https://github.com/ArnieX/swifitch
  1096. setSetting("board", DEVICE_ARNIEX_SWIFITCH);
  1097. setSetting("device", "ARNIEX_SWIFITCH");
  1098. setSetting("fw", ESPURNA_BASIC);
  1099. setSetting("btnGPIO", 0, 4);
  1100. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH | BUTTON_SET_PULLUP);
  1101. setSetting("btnRelay", 0, 1);
  1102. setSetting("btnPress", 0, BUTTON_MODE_NONE);
  1103. setSetting("btnClick", 0, BUTTON_MODE_TOGGLE);
  1104. setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
  1105. setSetting("btnLngClick", 0, BUTTON_MODE_NONE);
  1106. setSetting("btnLngLngClick", 0, BUTTON_MODE_NONE);
  1107. setSetting("ledGPIO", 0, 12);
  1108. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1109. setSetting("rlyGPIO", 0, 5);
  1110. setSetting("rlyType", 0, RELAY_TYPE_INVERSE);
  1111. #elif defined(GENERIC_ESP01S_RELAY_V40)
  1112. // ESP-01S RELAY v4.0
  1113. // https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20180404024035&SearchText=esp-01s+relay
  1114. setSetting("board", DEVICE_GENERIC_ESP01S_RELAY_V40);
  1115. setSetting("device", "GENERIC_ESP01S_RELAY_V40");
  1116. setSetting("fw", ESPURNA_BASIC);
  1117. setSetting("ledGPIO", 0, 2);
  1118. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  1119. setSetting("rlyGPIO", 0, 0);
  1120. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1121. #elif defined(GENERIC_ESP01S_RGBLED_V10)
  1122. // ESP-01S RGB LED v1.0 (some sold with ws2818)
  1123. // https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20180404023816&SearchText=esp-01s+led+controller
  1124. setSetting("board", DEVICE_GENERIC_ESP01S_RGBLED_V10);
  1125. setSetting("device", "GENERIC_ESP01S_RGBLED_V10");
  1126. setSetting("fw", ESPURNA_BASIC);
  1127. setSetting("ledGPIO", 0, 2);
  1128. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  1129. #elif defined(HELTEC_TOUCHRELAY)
  1130. // Heltec Touch Relay
  1131. // https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20180408043114&SearchText=esp8266+touch+relay
  1132. setSetting("board", DEVICE_HELTEC_TOUCHRELAY);
  1133. setSetting("device", "HELTEC_TOUCHRELAY");
  1134. setSetting("fw", ESPURNA_BASIC);
  1135. setSetting("btnGPIO", 0, 14);
  1136. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1137. setSetting("btnRelay", 0, 1);
  1138. setSetting("rlyGPIO", 0, 12);
  1139. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1140. #elif defined(GENERIC_ESP01S_DHT11_V10)
  1141. // ESP-01S DHT11 v1.0
  1142. // https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20180410105907&SearchText=esp-01s+dht11
  1143. setSetting("board", DEVICE_GENERIC_ESP01S_DHT11_V10);
  1144. setSetting("device", "GENERIC_ESP01S_DHT11_V10");
  1145. setSetting("fw", ESPURNA_SENSOR);
  1146. setSetting("dhtEnabled", 1);
  1147. setSetting("dhtGPIO", 0, 2);
  1148. setSetting("dhtType", 0, DHT_CHIP_DHT11);
  1149. #elif defined(GENERIC_ESP01S_DS18B20_V10)
  1150. // ESP-01S DS18B20 v1.0
  1151. // https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20180410105933&SearchText=esp-01s+ds18b20
  1152. setSetting("board", DEVICE_GENERIC_ESP01S_DS18B20_V10);
  1153. setSetting("device", "GENERIC_ESP01S_DS18B20_V10");
  1154. setSetting("fw", ESPURNA_SENSOR);
  1155. setSetting("dsEnabled", 1);
  1156. setSetting("dsGPIO", 0, 2);
  1157. #elif defined(ZHILDE_EU44_W)
  1158. // Zhilde ZLD-EU44-W
  1159. // http://www.zhilde.com/product/60705150109-805652505/EU_WiFi_Surge_Protector_Extension_Socket_4_Outlets_works_with_Amazon_Echo_Smart_Power_Strip.html
  1160. setSetting("board", DEVICE_ZHILDE_EU44_W);
  1161. setSetting("device", "ZHILDE_EU44_W");
  1162. setSetting("fw", ESPURNA_BASIC);
  1163. setSetting("btnGPIO", 0, 3);
  1164. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1165. setSetting("btnRelay", 0, 0);
  1166. setSetting("ledGPIO", 0, 1);
  1167. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1168. setSetting("rlyGPIO", 0, 5);
  1169. setSetting("rlyGPIO", 1, 4);
  1170. setSetting("rlyGPIO", 2, 12);
  1171. setSetting("rlyGPIO", 3, 13);
  1172. setSetting("rlyGPIO", 4, 14);
  1173. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1174. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  1175. setSetting("rlyType", 2, RELAY_TYPE_NORMAL);
  1176. setSetting("rlyType", 3, RELAY_TYPE_NORMAL);
  1177. setSetting("rlyType", 4, RELAY_TYPE_NORMAL);
  1178. // Based on the reporter, this product uses GPIO1 and 3 for the button
  1179. // and onboard LED, so hardware serial should be disabled...
  1180. setSetting("dbgSerial", 0);
  1181. #elif defined(ITEAD_SONOFF_POW_R2)
  1182. setSetting("board", DEVICE_ITEAD_SONOFF_POW_R2);
  1183. setSetting("device", "ITEAD_SONOFF_POW_R2");
  1184. setSetting("fw", ESPURNA_CSE77XX);
  1185. setSetting("btnGPIO", 0, 0);
  1186. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1187. setSetting("btnRelay", 0, 0);
  1188. setSetting("ledGPIO", 0, 13);
  1189. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1190. setSetting("rlyGPIO", 0, 12);
  1191. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1192. setSetting("cseEnabled", 1);
  1193. setSetting("cseGPIO", 1);
  1194. setSetting("dbgSerial", 0);
  1195. #elif defined(LUANI_HVIO)
  1196. // Luani HVIO
  1197. // https://luani.de/projekte/esp8266-hvio/
  1198. // https://luani.de/blog/esp8266-230v-io-modul/
  1199. setSetting("board", DEVICE_LUANI_HVIO);
  1200. setSetting("device", "LUANI_HVIO");
  1201. setSetting("fw", ESPURNA_BASIC);
  1202. setSetting("ledGPIO", 0, 15);
  1203. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  1204. setSetting("btnGPIO", 0, 12);
  1205. setSetting("btnGPIO", 1, 13);
  1206. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1207. setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1208. setSetting("btnRelay", 0, 0);
  1209. setSetting("btnRelay", 1, 1);
  1210. setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
  1211. setSetting("rlyGPIO", 0, 4);
  1212. setSetting("rlyGPIO", 1, 5);
  1213. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1214. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  1215. #elif defined(ALLNET_4DUINO_IOT_WLAN_RELAIS)
  1216. // Allnet 4duino ESP8266-UP-Relais
  1217. // http://www.allnet.de/de/allnet-brand/produkte/neuheiten/p/allnet-4duino-iot-wlan-relais-unterputz-esp8266-up-relais/
  1218. // https://shop.allnet.de/fileadmin/transfer/products/148814.pdf
  1219. setSetting("board", DEVICE_ALLNET_4DUINO_IOT_WLAN_RELAIS);
  1220. setSetting("device", "ALLNET_4DUINO_IOT_WLAN_RELAIS");
  1221. setSetting("fw", ESPURNA_BASIC);
  1222. setSetting("ledGPIO", 0, 0);
  1223. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1224. setSetting("rlyGPIO", 0, 14);
  1225. setSetting("rlyResetGPIO", 0, 12);
  1226. setSetting("rlyType", 0, RELAY_TYPE_LATCHED);
  1227. #elif defined(TONBUX_MOSQUITO_KILLER)
  1228. // Tonbux 50-100M Smart Mosquito Killer USB
  1229. // https://www.aliexpress.com/item/Original-Tonbux-50-100M-Smart-Mosquito-Killer-USB-Plug-No-Noise-Repellent-App-Smart-Module/32859330820.html
  1230. setSetting("board", DEVICE_TONBUX_MOSQUITO_KILLER);
  1231. setSetting("device", "TONBUX_MOSQUITO_KILLER");
  1232. setSetting("fw", ESPURNA_BASIC);
  1233. setSetting("btnGPIO", 0, 2);
  1234. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1235. setSetting("btnRelay", 0, 0);
  1236. setSetting("ledGPIO", 0, 15);
  1237. setSetting("ledGPIO", 1, 14);
  1238. setSetting("ledGPIO", 2, 12);
  1239. setSetting("ledGPIO", 3, 16);
  1240. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1241. setSetting("ledLogic", 1, GPIO_LOGIC_INVERSE);
  1242. setSetting("ledLogic", 2, GPIO_LOGIC_DIRECT);
  1243. setSetting("ledLogic", 3, GPIO_LOGIC_DIRECT);
  1244. setSetting("ledMode", 0, LED_MODE_WIFI);
  1245. setSetting("ledMode", 1, LED_MODE_RELAY);
  1246. setSetting("ledRelay", 1, 0);
  1247. setSetting("rlyGPIO", 0, 5); // Fan
  1248. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1249. #elif defined(NEO_COOLCAM_NAS_WR01W)
  1250. // NEO Coolcam NAS-WR01W Wifi Smart Power Plug
  1251. // https://es.aliexpress.com/item/-/32854589733.html?spm=a219c.12010608.0.0.6d084e68xX0y5N
  1252. // https://www.fasttech.com/product/9649426-neo-coolcam-nas-wr01w-wifi-smart-power-plug-eu
  1253. setSetting("board", DEVICE_NEO_COOLCAM_NAS_WR01W);
  1254. setSetting("device", "NEO_COOLCAM_NAS_WR01W");
  1255. setSetting("fw", ESPURNA_BASIC);
  1256. setSetting("btnGPIO", 0, 13);
  1257. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1258. setSetting("btnRelay", 0, 0);
  1259. setSetting("ledGPIO", 0, 4);
  1260. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1261. setSetting("rlyGPIO", 0, 12);
  1262. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1263. #elif defined(PILOTAK_ESP_DIN_V1)
  1264. // ESP-DIN relay board V1
  1265. // https://github.com/pilotak/esp_din
  1266. setSetting("board", DEVICE_PILOTAK_ESP_DIN_V1);
  1267. setSetting("device", "PILOTAK_ESP_DIN_V1");
  1268. setSetting("fw", ESPURNA_SENSOR);
  1269. setSetting("btnGPIO", 0, 0);
  1270. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1271. setSetting("btnRelay", 0, 0);
  1272. setSetting("ledGPIO", 0, 15);
  1273. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  1274. setSetting("rlyGPIO", 0, 4);
  1275. setSetting("rlyGPIO", 1, 5);
  1276. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1277. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  1278. setSetting("digEnabled", 1);
  1279. setSetting("digGPIO", 0, 16);
  1280. setSetting("digMode", 0, INPUT);
  1281. setSetting("dsEnabled", 1);
  1282. setSetting("dsGPIO", 0, 2);
  1283. setSetting("i2cEnable", 1);
  1284. setSetting("i2cSDAGPIO", 12);
  1285. setSetting("i2cSCLGPIO", 13);
  1286. setSetting("rfEnabled", 1);
  1287. setSetting("rfGPIO", 14);
  1288. #elif defined(ESTINK_WIFI_POWER_STRIP)
  1289. // Estink Wifi Power Strip
  1290. // https://www.amazon.de/Steckdosenleiste-Ladeger%C3%A4t-Sprachsteuerung-SmartphonesTablets-Android/dp/B0796W5FZY
  1291. // Fornorm Wi-Fi USB Extension Socket (ZLD-34EU)
  1292. // https://www.aliexpress.com/item/Fornorm-WiFi-Extension-Socket-with-Surge-Protector-Smart-Power-Strip-3-Outlets-and-4-USB-Charging/32849743948.html
  1293. setSetting("board", DEVICE_ESTINK_WIFI_POWER_STRIP);
  1294. setSetting("device", "ESTINK_WIFI_POWER_STRIP");
  1295. setSetting("fw", ESPURNA_BASIC);
  1296. setSetting("btnGPIO", 0, 16);
  1297. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1298. setSetting("btnRelay", 0, 3);
  1299. setSetting("ledGPIO", 0, 0);
  1300. setSetting("ledGPIO", 1, 12);
  1301. setSetting("ledGPIO", 2, 3);
  1302. setSetting("ledGPIO", 3, 5);
  1303. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1304. setSetting("ledLogic", 1, GPIO_LOGIC_INVERSE);
  1305. setSetting("ledLogic", 2, GPIO_LOGIC_INVERSE);
  1306. setSetting("ledLogic", 3, GPIO_LOGIC_INVERSE);
  1307. setSetting("ledMode", 0, LED_MODE_FINDME);
  1308. setSetting("ledMode", 1, LED_MODE_FOLLOW);
  1309. setSetting("ledMode", 2, LED_MODE_FOLLOW);
  1310. setSetting("ledMode", 3, LED_MODE_FOLLOW);
  1311. setSetting("ledRelay", 1, 1);
  1312. setSetting("ledRelay", 2, 2);
  1313. setSetting("ledRelay", 3, 3);
  1314. setSetting("rlyGPIO", 0, 14); // USB power
  1315. setSetting("rlyGPIO", 1, 13); // power plug 1
  1316. setSetting("rlyGPIO", 2, 4); // power plug 2
  1317. setSetting("rlyGPIO", 3, 15); // power plug 3
  1318. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1319. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  1320. setSetting("rlyType", 2, RELAY_TYPE_NORMAL);
  1321. setSetting("rlyType", 3, RELAY_TYPE_NORMAL);
  1322. // Disable UART noise since this board uses GPIO3
  1323. setSetting("dbgSerial", 0);
  1324. #elif defined(BH_ONOFRE)
  1325. // Bruno Horta's OnOfre
  1326. // https://www.bhonofre.pt/
  1327. // https://github.com/brunohorta82/BH_OnOfre/
  1328. setSetting("board", DEVICE_BH_ONOFRE);
  1329. setSetting("device", "BH_ONOFRE");
  1330. setSetting("fw", ESPURNA_BASIC);
  1331. setSetting("btnGPIO", 0, 12);
  1332. setSetting("btnGPIO", 1, 13);
  1333. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH | BUTTON_SET_PULLUP);
  1334. setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH | BUTTON_SET_PULLUP);
  1335. setSetting("btnRelay", 0, 0);
  1336. setSetting("btnRelay", 1, 1);
  1337. setSetting("rlyGPIO", 0, 4);
  1338. setSetting("rlyGPIO", 1, 5);
  1339. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1340. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  1341. #elif defined(BLITZWOLF_BWSHP2)
  1342. // Several devices under different names uing a power chip labelled BL0937 or HJL-01
  1343. // * Blitzwolf (https://www.amazon.es/Inteligente-Temporización-Dispositivos-Cualquier-BlitzWolf/dp/B07BMQP142)
  1344. // * HomeCube (https://www.amazon.de/Steckdose-Homecube-intelligente-Verbrauchsanzeige-funktioniert/dp/B076Q2LKHG)
  1345. // * Coosa (https://www.amazon.com/COOSA-Monitoring-Function-Campatible-Assiatant/dp/B0788W9TDR)
  1346. // * Goosund (http://www.gosund.com/?m=content&c=index&a=show&catid=6&id=5)
  1347. // * Ablue (https://www.amazon.de/Intelligente-Steckdose-Ablue-Funktioniert-Assistant/dp/B076DRFRZC)
  1348. setSetting("board", DEVICE_BLITZWOLF_BWSHP2);
  1349. setSetting("device", "BLITZWOLF_BWSHP2");
  1350. setSetting("fw", ESPURNA_HLW8012);
  1351. setSetting("btnGPIO", 0, 13);
  1352. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1353. setSetting("btnRelay", 0, 0);
  1354. setSetting("ledGPIO", 0, 2);
  1355. setSetting("ledGPIO", 1, 0);
  1356. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1357. setSetting("ledLogic", 1, GPIO_LOGIC_INVERSE);
  1358. setSetting("ledMode", 0, LED_MODE_WIFI);
  1359. setSetting("ledMode", 1, LED_MODE_FINDME);
  1360. setSetting("ledRelay", 1, 0);
  1361. setSetting("rlyGPIO", 0, 15);
  1362. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1363. setSetting("hlwSELGPIO", 12);
  1364. setSetting("hlwCF1GPIO", 14);
  1365. setSetting("hlwCFGPIO", 5);
  1366. setSetting("hlwCurSel", LOW);
  1367. setSetting("hlwIntMode", FALLING);
  1368. setSetting("curRatio", 25740);
  1369. setSetting("volRatio", 313400);
  1370. setSetting("pwrRatio", 3414290);
  1371. #elif defined(HOMECUBE_16A)
  1372. // Homecube 16A is similar to BLITZWOLF_BWSHP2 but some pins differ and it also has RGB LEDs
  1373. // https://www.amazon.de/gp/product/B07D7RVF56/ref=oh_aui_detailpage_o00_s01?ie=UTF8&psc=1
  1374. setSetting("board", DEVICE_HOMECUBE_16A);
  1375. setSetting("device", "HOMECUBE_16A");
  1376. setSetting("fw", ESPURNA_HLW8012);
  1377. setSetting("btnGPIO", 0, 13);
  1378. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1379. setSetting("btnRelay", 0, 0);
  1380. setSetting("ledGPIO", 0, 2);
  1381. setSetting("ledGPIO", 1, 12);
  1382. setSetting("ledGPIO", 2, 0);
  1383. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  1384. setSetting("ledLogic", 1, GPIO_LOGIC_DIRECT);
  1385. setSetting("ledLogic", 2, GPIO_LOGIC_DIRECT);
  1386. setSetting("ledMode", 0, LED_MODE_WIFI);
  1387. setSetting("ledMode", 1, LED_MODE_FINDME);
  1388. setSetting("ledMode", 2, LED_MODE_OFF);
  1389. setSetting("ledRelay", 1, 0);
  1390. setSetting("rlyGPIO", 0, 15);
  1391. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1392. setSetting("hlwSELGPIO", 16);
  1393. setSetting("hlwCF1GPIO", 14);
  1394. setSetting("hlwCFGPIO", 5);
  1395. setSetting("hlwCurSel", LOW);
  1396. setSetting("hlwIntMode", FALLING);
  1397. setSetting("curRatio", 25740);
  1398. setSetting("volRatio", 313400);
  1399. setSetting("pwrRatio", 3414290);
  1400. #elif defined(TINKERMAN_ESPURNA_SWITCH)
  1401. setSetting("board", DEVICE_TINKERMAN_ESPURNA_SWITCH);
  1402. setSetting("device", "TINKERMAN_ESPURNA_SWITCH");
  1403. setSetting("fw", ESPURNA_BASIC);
  1404. setSetting("btnGPIO", 0, 4);
  1405. setSetting("btnMode", 0, BUTTON_PUSHBUTTON);
  1406. setSetting("btnPress", 0, BUTTON_MODE_TOGGLE);
  1407. setSetting("btnClick", 0, BUTTON_MODE_NONE);
  1408. setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
  1409. setSetting("btnLngClick", 0, BUTTON_MODE_NONE);
  1410. setSetting("btnLngLngClick", 0, BUTTON_MODE_NONE);
  1411. setSetting("btnRelay", 0, 0);
  1412. setSetting("ledGPIO", 0, 2);
  1413. setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
  1414. setSetting("rlyGPIO", 0, 12);
  1415. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1416. #elif defined(ITEAD_SONOFF_S31)
  1417. setSetting("board", DEVICE_ITEAD_SONOFF_S31);
  1418. setSetting("device", "ITEAD_SONOFF_S31");
  1419. setSetting("fw", ESPURNA_CSE77XX);
  1420. setSetting("btnGPIO", 0, 0);
  1421. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1422. setSetting("btnRelay", 0, 0);
  1423. setSetting("ledGPIO", 0, 13);
  1424. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1425. setSetting("rlyGPIO", 0, 12);
  1426. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1427. setSetting("cseEnabled", 1);
  1428. setSetting("cseGPIO", 1);
  1429. setSetting("dbgSerial", 0);
  1430. #elif defined(STM_RELAY)
  1431. setSetting("board", DEVICE_STM_RELAY);
  1432. setSetting("device", "STM_RELAY");
  1433. setSetting("fw", ESPURNA_STM);
  1434. setSetting("rlyDummy", 2);
  1435. setSetting("rlyProvider", RELAY_PROVIDER_STM);
  1436. setSetting("dbgSerial", 0);
  1437. #elif defined(VANZAVANZU_SMART_WIFI_PLUG_MINI)
  1438. // VANZAVANZU Smart Outlet Socket (based on BL0937 or HJL-01)
  1439. // https://www.amazon.com/Smart-Plug-Wifi-Mini-VANZAVANZU/dp/B078PHD6S5
  1440. setSetting("board", DEVICE_VANZAVANZU_SMART_WIFI_PLUG_MINI);
  1441. setSetting("device", "VANZAVANZU_SMART_WIFI_PLUG_MINI");
  1442. setSetting("fw", ESPURNA_HLW8012);
  1443. setSetting("btnGPIO", 0, 13);
  1444. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1445. setSetting("btnRelay", 0, 0);
  1446. setSetting("ledGPIO", 0, 2);
  1447. setSetting("ledGPIO", 1, 0);
  1448. setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
  1449. setSetting("ledLogic", 1, GPIO_LOGIC_INVERSE);
  1450. setSetting("ledMode", 0, LED_MODE_WIFI);
  1451. setSetting("ledMode", 1, LED_MODE_FINDME);
  1452. setSetting("ledRelay", 1, 0);
  1453. setSetting("rlyGPIO", 0, 15);
  1454. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1455. setSetting("hlwSELGPIO", 3);
  1456. setSetting("hlwCF1GPIO", 14);
  1457. setSetting("hlwCFGPIO", 5);
  1458. setSetting("hlwCurSel", LOW);
  1459. setSetting("hlwIntMode", FALLING);
  1460. setSetting("curRatio", 25740);
  1461. setSetting("volRatio", 313400);
  1462. setSetting("pwrRatio", 3414290);
  1463. setSetting("dbgSerial", 0);
  1464. #elif defined(GENERIC_GEIGER_COUNTER)
  1465. setSetting("board", DEVICE_GENERIC_GEIGER_COUNTER);
  1466. setSetting("device", "GENERIC_GEIGER_COUNTER");
  1467. setSetting("fw", ESPURNA_GEIGER);
  1468. setSetting("geiEnabled", 1);
  1469. setSetting("geiGPIO", 5);
  1470. #elif defined(TINKERMAN_RFM69GW)
  1471. // Check http://tinkerman.cat/rfm69-wifi-gateway/
  1472. setSetting("board", DEVICE_TINKERMAN_RFM69GW);
  1473. setSetting("device", "TINKERMAN_RFM69GW");
  1474. setSetting("fw", ESPURNA_RFM69);
  1475. setSetting("btnGPIO", 0, 0);
  1476. setSetting("rfm69Enabled", 1);
  1477. setSetting("rfm69CSGPIO", 15);
  1478. setSetting("rfm69IRQGPIO", 5);
  1479. setSetting("rfm69ResetGPIO", 7);
  1480. setSetting("rfm69HW", 0);
  1481. #elif defined(ITEAD_SONOFF_IFAN02)
  1482. setSetting("board", DEVICE_ITEAD_SONOFF_IFAN02);
  1483. setSetting("device", "ITEAD_SONOFF_IFAN02");
  1484. setSetting("fw", ESPURNA_BASIC);
  1485. setSetting("btnGPIO", 0, 0);
  1486. setSetting("btnGPIO", 1, 9);
  1487. setSetting("btnGPIO", 2, 10);
  1488. setSetting("btnGPIO", 3, 14);
  1489. setSetting("ledGPIO", 0, 13);
  1490. setSetting("ledLogic", 0, 1);
  1491. setSetting("ledMode", 0, LED_MODE_WIFI);
  1492. setSetting("rlyGPIO", 0, 12);
  1493. setSetting("rlyGPIO", 1, 5);
  1494. setSetting("rlyGPIO", 2, 4);
  1495. setSetting("rlyGPIO", 3, 15);
  1496. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1497. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  1498. setSetting("rlyType", 2, RELAY_TYPE_NORMAL);
  1499. setSetting("rlyType", 3, RELAY_TYPE_NORMAL);
  1500. #elif defined(GENERIC_AG_L4)
  1501. setSetting("board", DEVICE_GENERIC_AG_L4);
  1502. setSetting("device", "GENERIC_AG_L4");
  1503. setSetting("fw", ESPURNA_DIMMER);
  1504. setSetting("btnGPIO", 0, 4);
  1505. setSetting("btnGPIO", 1, 2);
  1506. setSetting("btnRelay", 0, 0);
  1507. setSetting("btnMode", 0, BUTTON_PUSHBUTTON);
  1508. setSetting("btnPress", 0, BUTTON_MODE_TOGGLE);
  1509. setSetting("btnClick", 0, BUTTON_MODE_NONE);
  1510. setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
  1511. setSetting("btnLngClick", 0, BUTTON_MODE_NONE);
  1512. setSetting("btnLngLngClick", 0, BUTTON_MODE_NONE);
  1513. setSetting("ledGPIO", 0, 5);
  1514. setSetting("ledGPIO", 1, 16);
  1515. setSetting("ledLogic", 0, 0);
  1516. setSetting("ledLogic", 1, 1);
  1517. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  1518. setSetting("rlyDummy", 1);
  1519. setSetting("litChGPIO", 0, 14);
  1520. setSetting("litChGPIO", 1, 13);
  1521. setSetting("litChGPIO", 2, 12);
  1522. setSetting("litChLogic", 0, 0);
  1523. setSetting("litChLogic", 1, 0);
  1524. setSetting("litChLogic", 2, 0);
  1525. #elif defined(LOHAS_9W)
  1526. setSetting("board", DEVICE_LOHAS_9W);
  1527. setSetting("device", "LOHAS_9W");
  1528. setSetting("fw", ESPURNA_MY92XX);
  1529. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  1530. setSetting("rlyDummy", 1);
  1531. setSetting("litChFactor", 4, 0.1); // White LEDs are way more bright
  1532. setSetting("litChFactor", 5, 0.1); // White LEDs are way more bright
  1533. setSetting("myModel", 1); // 3 channels per chip
  1534. setSetting("myChips", 2);
  1535. setSetting("myDIGPIO", 13);
  1536. setSetting("myDCKIGPIO", 15);
  1537. setSetting("myMapping", "01234"); // TODO
  1538. #elif defined(ALLTERCO_SHELLY1)
  1539. setSetting("board", DEVICE_ALLTERCO_SHELLY1);
  1540. setSetting("device", "ALLTERCO_SHELLY1");
  1541. setSetting("fw", ESPURNA_BASIC);
  1542. setSetting("btnGPIO", 0, 5);
  1543. setSetting("btnMode", 0, BUTTON_SWITCH);
  1544. setSetting("btnRelay", 0, 0);
  1545. setSetting("rlyGPIO", 0, 4);
  1546. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1547. #elif defined(XIAOMI_SMART_DESK_LAMP)
  1548. setSetting("board", DEVICE_XIAOMI_SMART_DESK_LAMP);
  1549. setSetting("device", "XIAOMI_SMART_DESK_LAMP");
  1550. setSetting("fw", ESPURNA_DIMMER);
  1551. // This button doubles as switch here and as encoder mode switch below
  1552. // Clicking it (for less than 500ms) will turn the light on and off
  1553. // Double and Long clicks will not work as these are used to modify the encoder action
  1554. setSetting("btnGPIO", 0, 2);
  1555. setSetting("btnGPIO", 1, 14);
  1556. setSetting("btnRelay", 0, 0);
  1557. setSetting("btnLngDelay", 500);
  1558. setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
  1559. setSetting("btnLngClick", 0, BUTTON_MODE_NONE);
  1560. setSetting("btnLngLngClick", 0, BUTTON_MODE_NONE);
  1561. // Hidden button will enter AP mode if dblclick and reset the device when long-long-clicked
  1562. setSetting("btnDblClick", 1, BUTTON_MODE_AP);
  1563. setSetting("btnLngLngClick", 1, BUTTON_MODE_RESET);
  1564. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  1565. setSetting("litChGPIO", 0, 5);
  1566. setSetting("litChGPIO", 1, 4);
  1567. setSetting("litChLogic", 0, 0);
  1568. setSetting("litChLogic", 1, 0);
  1569. // Encoder
  1570. // If mode is ENCODER_MODE_RATIO, the value ratio between both channels is changed
  1571. // when the button is not pressed, and the overall brightness when pressed
  1572. // If mode is ENCODER_MODE_CHANNEL, the first channel value is changed
  1573. // when the button is not pressed, and the second channel when pressed
  1574. // If no ENCODERX_BUTTON_PIN defined it will only change the value of the first defined channel
  1575. setSetting("enc1stGPIO", 0, 12);
  1576. setSetting("enc2ndGPIO", 0, 13);
  1577. setSetting("encBtnGPIO", 0, 2);
  1578. setSetting("encMode", ENCODER_MODE_RATIO);
  1579. #elif defined(ALLTERCO_SHELLY2)
  1580. setSetting("board", DEVICE_ALLTERCO_SHELLY2);
  1581. setSetting("device", "ALLTERCO_SHELLY2");
  1582. setSetting("fw", ESPURNA_BASIC);
  1583. setSetting("btnGPIO", 0, 12);
  1584. setSetting("btnGPIO", 1, 14);
  1585. setSetting("btnMode", 0, BUTTON_SWITCH);
  1586. setSetting("btnMode", 1, BUTTON_SWITCH);
  1587. setSetting("btnRelay", 0, 0);
  1588. setSetting("btnRelay", 1, 1);
  1589. setSetting("rlyGPIO", 0, 4);
  1590. setSetting("rlyGPIO", 1, 5);
  1591. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1592. setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
  1593. #elif defined(PHYX_ESP12_RGB)
  1594. setSetting("board", DEVICE_PHYX_ESP12_RGB);
  1595. setSetting("device", "PHYX_ESP12_RGB");
  1596. setSetting("fw", ESPURNA_DIMMER);
  1597. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  1598. setSetting("litChGPIO", 0, 4);
  1599. setSetting("litChGPIO", 1, 14);
  1600. setSetting("litChGPIO", 2, 12);
  1601. setSetting("litChLogic", 0, 0);
  1602. setSetting("litChLogic", 1, 0);
  1603. setSetting("litChLogic", 3, 0);
  1604. #elif defined(IWOOLE_LED_TABLE_LAMP)
  1605. // iWoole LED Table Lamp
  1606. // http://iwoole.com/newst-led-smart-night-light-7w-smart-table-light-rgbw-wifi-app-remote-control-110v-220v-us-eu-plug-smart-lamp-google-home-decore-p00022p1.html
  1607. setSetting("board", DEVICE_IWOOLE_LED_TABLE_LAMP);
  1608. setSetting("device", "IWOOLE_LED_TABLE_LAMP");
  1609. setSetting("fw", ESPURNA_DIMMER);
  1610. setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
  1611. setSetting("litChGPIO", 0, 12);
  1612. setSetting("litChGPIO", 1, 5);
  1613. setSetting("litChGPIO", 2, 14);
  1614. setSetting("litChGPIO", 3, 4);
  1615. setSetting("litChLogic", 0, 0);
  1616. setSetting("litChLogic", 1, 0);
  1617. setSetting("litChLogic", 2, 0);
  1618. setSetting("litChLogic", 3, 0);
  1619. #elif defined(EXS_WIFI_RELAY_V50)
  1620. setSetting("board", DEVICE_EXS_WIFI_RELAY_V50);
  1621. setSetting("device", "EXS_WIFI_RELAY_V50");
  1622. setSetting("fw", ESPURNA_BASIC);
  1623. setSetting("btnGPIO", 0, 5);
  1624. setSetting("btnGPIO", 1, 4);
  1625. setSetting("btnRelay", 0, 0);
  1626. setSetting("btnRelay", 1, 1);
  1627. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1628. setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
  1629. setSetting("rlyGPIO", 0, 14);
  1630. setSetting("rlyGPIO", 1, 13);
  1631. setSetting("rlyResetGPIO", 0, 16);
  1632. setSetting("rlyResetGPIO", 1, 12);
  1633. setSetting("rlyType", 0, RELAY_TYPE_LATCHED);
  1634. setSetting("rlyType", 0, RELAY_TYPE_LATCHED);
  1635. setSetting("ledGPIO", 1, 15);
  1636. setSetting("ledLogic", 1, 0);
  1637. #elif defined(BESTEK_MRJ1011)
  1638. // Bestek Smart Plug with 2 USB ports
  1639. // https://www.bestekcorp.com/bestek-smart-plug-works-with-amazon-alexa-google-assistant-and-ifttt-with-2-usb
  1640. setSetting("board", DEVICE_BESTEK_MRJ1011);
  1641. setSetting("device", "BESTEK_MRJ1011");
  1642. setSetting("fw", ESPURNA_BASIC);
  1643. setSetting("btnGPIO", 0, 13);
  1644. setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_SET_PULLUP | BUTTON_DEFAULT_HIGH);
  1645. setSetting("btnRelay", 0, 0);
  1646. setSetting("rlyGPIO", 0, 12);
  1647. setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
  1648. setSetting("ledGPIO", 1, 4);
  1649. setSetting("ledLogic", 1, 1);
  1650. #endif
  1651. }
  1652. void _deviceMigrateMoveIndexDown(const char * key, int offset = 0) {
  1653. if (hasSetting(key, 0)) return;
  1654. for (unsigned char index = 1; index < SETTINGS_MAX_LIST_COUNT; index++) {
  1655. if (hasSetting(key, index)) {
  1656. setSetting(key, index - 1, getSetting(key, index).toInt() + offset);
  1657. } else {
  1658. delSetting(key, index - 1);
  1659. }
  1660. }
  1661. }
  1662. // Configuration versions
  1663. //
  1664. // 1: based on Embedis, no board definitions
  1665. // 2: based on Embedis, with board definitions 1-based
  1666. // 3: based on Embedis, with board definitions 0-based
  1667. // 4: based on Embedis, added sensors and force resetting
  1668. void _deviceMigrate() {
  1669. moveSetting("boardName", "device");
  1670. moveSettings("relayGPIO", "rlyGPIO");
  1671. moveSettings("relayResetGPIO", "rlyResetGPIO");
  1672. moveSettings("relayType", "rlyType");
  1673. moveSetting("selGPIO", "hlwSELGPIO");
  1674. moveSetting("cfGPIO", "hlwCFGPIO");
  1675. moveSetting("cf1GPIO", "hlwCF1GPIO");
  1676. moveSetting("relayProvider", "rlyProvider");
  1677. moveSetting("relays", "rlyDummy");
  1678. moveSettings("chGPIO", "litChGPIO");
  1679. moveSettings("chLogic", "litChLogic");
  1680. moveSetting("enGPIO", "litEnableGPIO");
  1681. moveSetting("hlwSelC", "hlwCurLevel");
  1682. moveSetting("hlwIntM", "hlwInt");
  1683. delSetting("ledWifi");
  1684. delSetting("lightProvider");
  1685. delSetting("litProvider");
  1686. // Get config version
  1687. unsigned int board = getSetting("board", 0).toInt();
  1688. unsigned int config_version = getSetting("cfg", board > 0 ? 2 : 1).toInt();
  1689. setSetting("cfg", CFG_VERSION);
  1690. if (config_version == 2) {
  1691. _deviceMigrateMoveIndexDown("ledGPIO");
  1692. _deviceMigrateMoveIndexDown("ledLogic");
  1693. _deviceMigrateMoveIndexDown("btnGPIO");
  1694. _deviceMigrateMoveIndexDown("btnRelay", -1);
  1695. _deviceMigrateMoveIndexDown("rlyGPIO");
  1696. _deviceMigrateMoveIndexDown("rlyType");
  1697. }
  1698. }
  1699. void _deviceSpecific() {
  1700. // These devices use the hardware UART
  1701. // to communicate to secondary microcontrollers
  1702. #if \
  1703. (ESPURNA_IMAGE == ESPURNA_SONOFF_RFBRIDGE) || \
  1704. (ESPURNA_IMAGE == ESPURNA_SONOFF_DUAL) || \
  1705. (ESPURNA_IMAGE == ESPURNA_STM)
  1706. unsigned long speed = getSetting("dbgSpeed", DEBUG_SERIAL_SPEED).toInt();
  1707. Serial.begin(speed);
  1708. #endif
  1709. }
  1710. // -----------------------------------------------------------------------------
  1711. void deviceSetup() {
  1712. _deviceMigrate();
  1713. _deviceLoad();
  1714. _deviceSpecific();
  1715. // Check match firmware-configuration
  1716. // At the time being, this will always match.
  1717. // In the future, custom loaded configuration
  1718. // might not match loaded firmware image
  1719. if (getSetting("fw", ESPURNA_CORE).toInt() != ESPURNA_IMAGE) {
  1720. DEBUG_MSG_P(PSTR("[HW] Configuration does not match firmware image!!!"));
  1721. }
  1722. }