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.

531 lines
17 KiB

  1. // -----------------------------------------------------------------------------
  2. // Configuration HELP
  3. // -----------------------------------------------------------------------------
  4. //
  5. // MANUFACTURER: Name of the manufacturer of the board ("string")
  6. // DEVICE: Name of the device ("string")
  7. // BUTTON#_PIN: GPIO for the n-th button (1-based, up to 4 buttons)
  8. // BUTTON#_RELAY: Relay number that will be bind to the n-th button (1-based)
  9. // BUTTON#_MODE: A mask of options (BUTTON_PUSHBUTTON and BUTTON_SWITCH cannot be together)
  10. // - BUTTON_PUSHBUTTON: button event is fired when released
  11. // - BUTTON_SWITCH: button event is fired when pressed or released
  12. // - BUTTON_DEFAULT_HIGH: there is a pull up in place
  13. // - BUTTON_SET_PULLUP: set pullup by software
  14. // RELAY#_PIN: GPIO for the n-th relay (1-based, up to 4 relays)
  15. // RELAY#_PIN_INVERSE: Relay has inversed logic (closed or ON when pulled down)
  16. // RELAY#_LED: LED number that will be bind to the n-th relay (1-based)
  17. // LED#_PIN: GPIO for the n-th LED (1-based, up to 4 LEDs)
  18. // LED#_PIN_INVERSE: LED has inversed logic (lit when pulled down)
  19. // WIFI_LED: LED number that will used for WIFI notifications (1-based, defaults to 1)
  20. // -----------------------------------------------------------------------------
  21. // Development boards
  22. // -----------------------------------------------------------------------------
  23. #if defined(NODEMCUV2)
  24. #define MANUFACTURER "NODEMCU"
  25. #define DEVICE "LOLIN"
  26. #define BUTTON1_PIN 0
  27. #define BUTTON1_RELAY 1
  28. #define BUTTON1_LNGCLICK BUTTON_MODE_PULSE
  29. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  30. #define RELAY1_PIN 12
  31. #define RELAY1_PIN_INVERSE 0
  32. #define LED1_PIN 2
  33. #define LED1_PIN_INVERSE 1
  34. #elif defined(D1_RELAYSHIELD)
  35. #define MANUFACTURER "WEMOS"
  36. #define DEVICE "D1_MINI"
  37. #define RELAY1_PIN 5
  38. #define RELAY1_PIN_INVERSE 0
  39. #define LED1_PIN 2
  40. #define LED1_PIN_INVERSE 1
  41. // -----------------------------------------------------------------------------
  42. // ESPurna
  43. // -----------------------------------------------------------------------------
  44. #elif defined(ESPURNA_H)
  45. #define MANUFACTURER "TINKERMAN"
  46. #define DEVICE "ESPURNA_H"
  47. #define RELAY1_PIN 12
  48. #define RELAY1_PIN_INVERSE 1
  49. #define LED1_PIN 5
  50. #define LED1_PIN_INVERSE 0
  51. #define BUTTON1_PIN 4
  52. #define BUTTON1_RELAY 1
  53. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  54. #define ENABLE_HLW8012 1
  55. // -----------------------------------------------------------------------------
  56. // Itead Studio boards
  57. // -----------------------------------------------------------------------------
  58. #elif defined(SONOFF)
  59. #define MANUFACTURER "ITEAD"
  60. #define DEVICE "SONOFF"
  61. #define BUTTON1_PIN 0
  62. #define BUTTON1_RELAY 1
  63. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  64. #define RELAY1_PIN 12
  65. #define RELAY1_PIN_INVERSE 0
  66. #define LED1_PIN 13
  67. #define LED1_PIN_INVERSE 1
  68. #elif defined(SONOFF_TH)
  69. #define MANUFACTURER "ITEAD"
  70. #define DEVICE "SONOFF_TH"
  71. #define BUTTON1_PIN 0
  72. #define BUTTON1_RELAY 1
  73. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  74. #define RELAY1_PIN 12
  75. #define RELAY1_PIN_INVERSE 0
  76. #define LED1_PIN 13
  77. #define LED1_PIN_INVERSE 1
  78. #elif defined(SONOFF_SV)
  79. #define MANUFACTURER "ITEAD"
  80. #define DEVICE "SONOFF_SV"
  81. #define BUTTON1_PIN 0
  82. #define BUTTON1_RELAY 1
  83. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  84. #define RELAY1_PIN 12
  85. #define RELAY1_PIN_INVERSE 0
  86. #define LED1_PIN 13
  87. #define LED1_PIN_INVERSE 1
  88. #elif defined(SLAMPHER)
  89. #define MANUFACTURER "ITEAD"
  90. #define DEVICE "SLAMPHER"
  91. #define BUTTON1_PIN 0
  92. #define BUTTON1_RELAY 1
  93. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  94. #define RELAY1_PIN 12
  95. #define RELAY1_PIN_INVERSE 0
  96. #define LED1_PIN 13
  97. #define LED1_PIN_INVERSE 1
  98. #elif defined(S20)
  99. #define MANUFACTURER "ITEAD"
  100. #define DEVICE "S20"
  101. #define BUTTON1_PIN 0
  102. #define BUTTON1_RELAY 1
  103. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  104. #define RELAY1_PIN 12
  105. #define RELAY1_PIN_INVERSE 0
  106. #define LED1_PIN 13
  107. #define LED1_PIN_INVERSE 1
  108. #elif defined(SONOFF_TOUCH)
  109. #define MANUFACTURER "ITEAD"
  110. #define DEVICE "SONOFF_TOUCH"
  111. #define BUTTON1_PIN 0
  112. #define BUTTON1_RELAY 1
  113. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  114. #define RELAY1_PIN 12
  115. #define RELAY1_PIN_INVERSE 0
  116. #define LED1_PIN 13
  117. #define LED1_PIN_INVERSE 1
  118. #elif defined(SONOFF_POW)
  119. #define MANUFACTURER "ITEAD"
  120. #define DEVICE "SONOFF_POW"
  121. #define BUTTON1_PIN 0
  122. #define BUTTON1_RELAY 1
  123. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  124. #define RELAY1_PIN 12
  125. #define RELAY1_PIN_INVERSE 0
  126. #define LED1_PIN 15
  127. #define LED1_PIN_INVERSE 0
  128. #define ENABLE_HLW8012 1
  129. #elif defined(SONOFF_DUAL)
  130. #define MANUFACTURER "ITEAD"
  131. #define DEVICE "SONOFF_DUAL"
  132. #define BUTTON3_RELAY 1
  133. #define LED1_PIN 13
  134. #define LED1_PIN_INVERSE 1
  135. #undef SERIAL_BAUDRATE
  136. #define SERIAL_BAUDRATE 19230
  137. #undef RELAY_PROVIDER
  138. #define RELAY_PROVIDER RELAY_PROVIDER_DUAL
  139. #define DUMMY_RELAY_COUNT 2
  140. #elif defined(SONOFF_4CH)
  141. #define MANUFACTURER "ITEAD"
  142. #define DEVICE "SONOFF_4CH"
  143. #define BUTTON1_PIN 0
  144. #define BUTTON1_RELAY 1
  145. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  146. #define BUTTON2_PIN 9
  147. #define BUTTON2_RELAY 2
  148. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  149. #define BUTTON3_PIN 10
  150. #define BUTTON3_RELAY 3
  151. #define BUTTON3_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  152. #define BUTTON4_PIN 14
  153. #define BUTTON4_RELAY 4
  154. #define BUTTON4_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  155. #define RELAY1_PIN 12
  156. #define RELAY1_PIN_INVERSE 0
  157. #define RELAY2_PIN 5
  158. #define RELAY2_PIN_INVERSE 0
  159. #define RELAY3_PIN 4
  160. #define RELAY3_PIN_INVERSE 0
  161. #define RELAY4_PIN 15
  162. #define RELAY4_PIN_INVERSE 0
  163. #define LED1_PIN 13
  164. #define LED1_PIN_INVERSE 1
  165. #elif defined(ITEAD_1CH_INCHING)
  166. // The inching functionality is managed by a misterious IC in the board.
  167. // You cannot control the inching button and functionality from the ESP8266
  168. // Besides, enabling the inching functionality using the hardware button
  169. // will result in the relay switching on and off continuously.
  170. // Fortunately the unkown IC keeps memory of the hardware inching status
  171. // so you can just disable it and forget. The inching LED must be lit.
  172. // You can still use the pulse options from the web interface
  173. // without problem.
  174. #define MANUFACTURER "ITEAD"
  175. #define DEVICE "1CH_INCHING"
  176. #define BUTTON1_PIN 0
  177. #define BUTTON1_RELAY 1
  178. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  179. #define RELAY1_PIN 12
  180. #define RELAY1_PIN_INVERSE 0
  181. #define LED1_PIN 13
  182. #define LED1_PIN_INVERSE 1
  183. #elif defined(ITEAD_MOTOR)
  184. #define MANUFACTURER "ITEAD"
  185. #define DEVICE "MOTOR"
  186. #define BUTTON1_PIN 0
  187. #define BUTTON1_RELAY 1
  188. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  189. #define RELAY1_PIN 12
  190. #define RELAY1_PIN_INVERSE 0
  191. #define LED1_PIN 13
  192. #define LED1_PIN_INVERSE 1
  193. #elif defined(SONOFF_RFBRIDGE)
  194. #define MANUFACTURER "ITEAD"
  195. #define DEVICE "RFBRIDGE"
  196. #define BUTTON1_PIN 0
  197. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  198. #define LED1_PIN 13
  199. #define LED1_PIN_INVERSE 1
  200. #undef SERIAL_BAUDRATE
  201. #define SERIAL_BAUDRATE 19200
  202. #undef RELAY_PROVIDER
  203. #define RELAY_PROVIDER RELAY_PROVIDER_RFBRIDGE
  204. #define DUMMY_RELAY_COUNT 4
  205. // -----------------------------------------------------------------------------
  206. // Electrodragon boards
  207. // -----------------------------------------------------------------------------
  208. #elif defined(ESP_RELAY_BOARD)
  209. #define MANUFACTURER "ELECTRODRAGON"
  210. #define DEVICE "ESP_RELAY_BOARD"
  211. #define BUTTON1_PIN 0
  212. #define BUTTON1_RELAY 1
  213. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  214. #define BUTTON2_PIN 2
  215. #define BUTTON2_RELAY 2
  216. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  217. #define RELAY1_PIN 12
  218. #define RELAY1_PIN_INVERSE 0
  219. #define RELAY2_PIN 13
  220. #define RELAY2_PIN_INVERSE 0
  221. #define LED1_PIN 16
  222. #define LED1_PIN_INVERSE 0
  223. // -----------------------------------------------------------------------------
  224. // WorkChoice ecoPlug
  225. // -----------------------------------------------------------------------------
  226. #elif defined(ECOPLUG)
  227. #define MANUFACTURER "WORKCHOICE"
  228. #define DEVICE "ECOPLUG"
  229. #define BUTTON1_PIN 13
  230. #define BUTTON1_RELAY 1
  231. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  232. #define RELAY1_PIN 15
  233. #define RELAY1_PIN_INVERSE 0
  234. #define LED1_PIN 2
  235. #define LED1_PIN_INVERSE 0
  236. // -----------------------------------------------------------------------------
  237. // AI Thinker
  238. // -----------------------------------------------------------------------------
  239. #elif defined(AI_LIGHT)
  240. #define MANUFACTURER "AI_THINKER"
  241. #define DEVICE "AI_LIGHT"
  242. #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT
  243. #define LIGHT_PROVIDER LIGHT_PROVIDER_MY9192
  244. #define DUMMY_RELAY_COUNT 1
  245. // -----------------------------------------------------------------------------
  246. // LED Controller
  247. // -----------------------------------------------------------------------------
  248. #elif defined(LED_CONTROLLER)
  249. #define MANUFACTURER "MAGIC_HOME"
  250. #define DEVICE "LED_CONTROLLER"
  251. #define LED1_PIN 2
  252. #define LED1_PIN_INVERSE 1
  253. #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT
  254. #define LIGHT_PROVIDER LIGHT_PROVIDER_RGB
  255. #define DUMMY_RELAY_COUNT 1
  256. #undef RGBW_INVERSE_LOGIC
  257. #undef RGBW_RED_PIN
  258. #undef RGBW_GREEN_PIN
  259. #undef RGBW_BLUE_PIN
  260. #undef RGBW_WHITE_PIN
  261. #define RGBW_INVERSE_LOGIC 1
  262. #define RGBW_RED_PIN 14
  263. #define RGBW_GREEN_PIN 5
  264. #define RGBW_BLUE_PIN 12
  265. #define RGBW_WHITE_PIN 13
  266. // -----------------------------------------------------------------------------
  267. // HUACANXING H801
  268. // -----------------------------------------------------------------------------
  269. #elif defined(H801_LED_CONTROLLER)
  270. #define MANUFACTURER "HUACANXING"
  271. #define DEVICE "H801"
  272. #define LED1_PIN 5
  273. #define LED1_PIN_INVERSE 1
  274. #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT
  275. #define LIGHT_PROVIDER LIGHT_PROVIDER_RGB2W
  276. #define DUMMY_RELAY_COUNT 1
  277. #undef RGBW_INVERSE_LOGIC
  278. #undef RGBW_RED_PIN
  279. #undef RGBW_GREEN_PIN
  280. #undef RGBW_BLUE_PIN
  281. #undef RGBW_WHITE_PIN
  282. #define RGBW_INVERSE_LOGIC 1
  283. #define RGBW_RED_PIN 15
  284. #define RGBW_GREEN_PIN 13
  285. #define RGBW_BLUE_PIN 12
  286. #define RGBW_WHITE_PIN 14
  287. #define RGBW_WHITE2_PIN 4
  288. // -----------------------------------------------------------------------------
  289. // Jan Goedeke Wifi Relay
  290. // https://github.com/JanGoe/esp8266-wifi-relay
  291. // -----------------------------------------------------------------------------
  292. #elif defined(WIFI_RELAY_NC)
  293. #define MANUFACTURER "JAN_GOEDEKE"
  294. #define DEVICE "WIFI_RELAY_NC"
  295. #define BUTTON1_PIN 12
  296. #define BUTTON1_RELAY 1
  297. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  298. #define BUTTON2_PIN 13
  299. #define BUTTON2_RELAY 2
  300. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  301. #define RELAY1_PIN 2
  302. #define RELAY1_PIN_INVERSE 1
  303. #define RELAY2_PIN 14
  304. #define RELAY2_PIN_INVERSE 1
  305. #elif defined(WIFI_RELAY_NO)
  306. #define MANUFACTURER "JAN_GOEDEKE"
  307. #define DEVICE "WIFI_RELAY_NO"
  308. #define BUTTON1_PIN 12
  309. #define BUTTON1_RELAY 1
  310. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  311. #define BUTTON2_PIN 13
  312. #define BUTTON2_RELAY 2
  313. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  314. #define RELAY1_PIN 2
  315. #define RELAY1_PIN_INVERSE 0
  316. #define RELAY2_PIN 14
  317. #define RELAY2_PIN_INVERSE 0
  318. // -----------------------------------------------------------------------------
  319. // Jorge García Wifi+Relays Board Kit
  320. // https://www.tindie.com/products/jorgegarciadev/wifi--relays-board-kit
  321. // https://github.com/jorgegarciadev/wifikit
  322. // -----------------------------------------------------------------------------
  323. #elif defined(WIFI_RELAYS_BOARD_KIT)
  324. #define MANUFACTURER "JORGE_GARCIA"
  325. #define DEVICE "WIFI_RELAYS_BOARD_KIT"
  326. #define RELAY1_PIN 0
  327. #define RELAY1_PIN_INVERSE 1
  328. #define RELAY2_PIN 2
  329. #define RELAY2_PIN_INVERSE 1
  330. // -----------------------------------------------------------------------------
  331. // WiFi MQTT Relay / Thermostat
  332. // -----------------------------------------------------------------------------
  333. #elif defined(MQTT_RELAY)
  334. #define MANUFACTURER "OPENENERGYMONITOR"
  335. #define DEVICE "MQTT_RELAY"
  336. #define BUTTON1_PIN 0
  337. #define BUTTON1_RELAY 1
  338. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  339. #define RELAY1_PIN 12
  340. #define RELAY1_PIN_INVERSE 0
  341. #define LED1_PIN 16
  342. #define LED1_PIN_INVERSE 0
  343. // -----------------------------------------------------------------------------
  344. // Unknown hardware
  345. // -----------------------------------------------------------------------------
  346. #else
  347. #error "UNSUPPORTED HARDWARE!"
  348. #endif
  349. // -----------------------------------------------------------------------------
  350. // Default values
  351. // -----------------------------------------------------------------------------
  352. #ifndef BUTTON1_PRESS
  353. #define BUTTON1_PRESS BUTTON_MODE_NONE
  354. #endif
  355. #ifndef BUTTON2_PRESS
  356. #define BUTTON2_PRESS BUTTON_MODE_NONE
  357. #endif
  358. #ifndef BUTTON3_PRESS
  359. #define BUTTON3_PRESS BUTTON_MODE_NONE
  360. #endif
  361. #ifndef BUTTON4_PRESS
  362. #define BUTTON4_PRESS BUTTON_MODE_NONE
  363. #endif
  364. #ifndef BUTTON1_CLICK
  365. #define BUTTON1_CLICK BUTTON_MODE_TOGGLE
  366. #endif
  367. #ifndef BUTTON2_CLICK
  368. #define BUTTON2_CLICK BUTTON_MODE_TOGGLE
  369. #endif
  370. #ifndef BUTTON3_CLICK
  371. #define BUTTON3_CLICK BUTTON_MODE_TOGGLE
  372. #endif
  373. #ifndef BUTTON4_CLICK
  374. #define BUTTON4_CLICK BUTTON_MODE_TOGGLE
  375. #endif
  376. #ifndef BUTTON1_DBLCLICK
  377. #define BUTTON1_DBLCLICK BUTTON_MODE_AP
  378. #endif
  379. #ifndef BUTTON2_DBLCLICK
  380. #define BUTTON2_DBLCLICK BUTTON_MODE_NONE
  381. #endif
  382. #ifndef BUTTON3_DBLCLICK
  383. #define BUTTON3_DBLCLICK BUTTON_MODE_NONE
  384. #endif
  385. #ifndef BUTTON4_DBLCLICK
  386. #define BUTTON4_DBLCLICK BUTTON_MODE_NONE
  387. #endif
  388. #ifndef BUTTON1_LNGCLICK
  389. #define BUTTON1_LNGCLICK BUTTON_MODE_RESET
  390. #endif
  391. #ifndef BUTTON2_LNGCLICK
  392. #define BUTTON2_LNGCLICK BUTTON_MODE_NONE
  393. #endif
  394. #ifndef BUTTON3_LNGCLICK
  395. #define BUTTON3_LNGCLICK BUTTON_MODE_NONE
  396. #endif
  397. #ifndef BUTTON4_LNGCLICK
  398. #define BUTTON4_LNGCLICK BUTTON_MODE_NONE
  399. #endif
  400. #ifndef BUTTON1_LNGLNGCLICK
  401. #define BUTTON1_LNGLNGCLICK BUTTON_MODE_FACTORY
  402. #endif
  403. #ifndef BUTTON2_LNGLNGCLICK
  404. #define BUTTON2_LNGLNGCLICK BUTTON_MODE_NONE
  405. #endif
  406. #ifndef BUTTON3_LNGLNGCLICK
  407. #define BUTTON3_LNGLNGCLICK BUTTON_MODE_NONE
  408. #endif
  409. #ifndef BUTTON4_LNGLNGCLICK
  410. #define BUTTON4_LNGLNGCLICK BUTTON_MODE_NONE
  411. #endif
  412. #ifndef BUTTON1_RELAY
  413. #define BUTTON1_RELAY 0
  414. #endif
  415. #ifndef BUTTON2_RELAY
  416. #define BUTTON2_RELAY 0
  417. #endif
  418. #ifndef BUTTON3_RELAY
  419. #define BUTTON3_RELAY 0
  420. #endif
  421. #ifndef BUTTON4_RELAY
  422. #define BUTTON4_RELAY 0
  423. #endif
  424. #ifndef RELAY1_LED
  425. #define RELAY1_LED 0
  426. #endif
  427. #ifndef RELAY2_LED
  428. #define RELAY2_LED 0
  429. #endif
  430. #ifndef RELAY3_LED
  431. #define RELAY3_LED 0
  432. #endif
  433. #ifndef RELAY4_LED
  434. #define RELAY4_LED 0
  435. #endif
  436. #ifndef WIFI_LED
  437. #define WIFI_LED 1
  438. #endif
  439. // Needed for ESP8285 boards under Windows using PlatformIO (?)
  440. #ifndef BUTTON_PUSHBUTTON
  441. #define BUTTON_PUSHBUTTON 0
  442. #define BUTTON_SWITCH 1
  443. #define BUTTON_DEFAULT_HIGH 2
  444. #define BUTTON_SET_PULLUP 4
  445. #endif
  446. // Relay providers
  447. #ifndef RELAY_PROVIDER
  448. #define RELAY_PROVIDER RELAY_PROVIDER_RELAY
  449. #endif
  450. // Light provider
  451. #ifndef LIGHT_PROVIDER
  452. #define LIGHT_PROVIDER LIGHT_PROVIDER_NONE
  453. #endif