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.

464 lines
15 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_MINI)
  35. #define MANUFACTURER "WEMOS"
  36. #define DEVICE "D1_MINI"
  37. #define LED1_PIN 2
  38. #define LED1_PIN_INVERSE 1
  39. #elif defined(D1_RELAYSHIELD)
  40. #define MANUFACTURER "WEMOS"
  41. #define DEVICE "D1_MINI"
  42. #define RELAY1_PIN 5
  43. #define RELAY1_PIN_INVERSE 0
  44. #define LED1_PIN 2
  45. #define LED1_PIN_INVERSE 1
  46. // -----------------------------------------------------------------------------
  47. // Itead Studio boards
  48. // -----------------------------------------------------------------------------
  49. #elif defined(SONOFF)
  50. #define MANUFACTURER "ITEAD"
  51. #define DEVICE "SONOFF"
  52. #define BUTTON1_PIN 0
  53. #define BUTTON1_RELAY 1
  54. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  55. #define RELAY1_PIN 12
  56. #define RELAY1_PIN_INVERSE 0
  57. #define LED1_PIN 13
  58. #define LED1_PIN_INVERSE 1
  59. #elif defined(SONOFF_TH)
  60. #define MANUFACTURER "ITEAD"
  61. #define DEVICE "SONOFF_TH"
  62. #define BUTTON1_PIN 0
  63. #define BUTTON1_RELAY 1
  64. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  65. #define RELAY1_PIN 12
  66. #define RELAY1_PIN_INVERSE 0
  67. #define LED1_PIN 13
  68. #define LED1_PIN_INVERSE 1
  69. #elif defined(SONOFF_SV)
  70. #define MANUFACTURER "ITEAD"
  71. #define DEVICE "SONOFF_SV"
  72. #define BUTTON1_PIN 0
  73. #define BUTTON1_RELAY 1
  74. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  75. #define RELAY1_PIN 12
  76. #define RELAY1_PIN_INVERSE 0
  77. #define LED1_PIN 13
  78. #define LED1_PIN_INVERSE 1
  79. #elif defined(SLAMPHER)
  80. #define MANUFACTURER "ITEAD"
  81. #define DEVICE "SLAMPHER"
  82. #define BUTTON1_PIN 0
  83. #define BUTTON1_RELAY 1
  84. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  85. #define RELAY1_PIN 12
  86. #define RELAY1_PIN_INVERSE 0
  87. #define LED1_PIN 13
  88. #define LED1_PIN_INVERSE 1
  89. #elif defined(S20)
  90. #define MANUFACTURER "ITEAD"
  91. #define DEVICE "S20"
  92. #define BUTTON1_PIN 0
  93. #define BUTTON1_RELAY 1
  94. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  95. #define RELAY1_PIN 12
  96. #define RELAY1_PIN_INVERSE 0
  97. #define LED1_PIN 13
  98. #define LED1_PIN_INVERSE 1
  99. #elif defined(SONOFF_TOUCH)
  100. #define MANUFACTURER "ITEAD"
  101. #define DEVICE "SONOFF_TOUCH"
  102. #define BUTTON1_PIN 0
  103. #define BUTTON1_RELAY 1
  104. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  105. #define RELAY1_PIN 12
  106. #define RELAY1_PIN_INVERSE 0
  107. #define LED1_PIN 13
  108. #define LED1_PIN_INVERSE 1
  109. #elif defined(SONOFF_POW)
  110. #define MANUFACTURER "ITEAD"
  111. #define DEVICE "SONOFF_POW"
  112. #define BUTTON1_PIN 0
  113. #define BUTTON1_RELAY 1
  114. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  115. #define RELAY1_PIN 12
  116. #define RELAY1_PIN_INVERSE 0
  117. #define LED1_PIN 15
  118. #define LED1_PIN_INVERSE 0
  119. #define ENABLE_POW 1
  120. #elif defined(SONOFF_DUAL)
  121. #define MANUFACTURER "ITEAD"
  122. #define DEVICE "SONOFF_DUAL"
  123. #define BUTTON3_RELAY 1
  124. #define LED1_PIN 13
  125. #define LED1_PIN_INVERSE 1
  126. #undef SERIAL_BAUDRATE
  127. #define SERIAL_BAUDRATE 19230
  128. #undef RELAY_PROVIDER
  129. #define RELAY_PROVIDER RELAY_PROVIDER_DUAL
  130. #elif defined(SONOFF_4CH)
  131. #define MANUFACTURER "ITEAD"
  132. #define DEVICE "SONOFF_4CH"
  133. #define BUTTON1_PIN 0
  134. #define BUTTON1_RELAY 1
  135. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  136. #define BUTTON2_PIN 9
  137. #define BUTTON2_RELAY 2
  138. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  139. #define BUTTON3_PIN 10
  140. #define BUTTON3_RELAY 3
  141. #define BUTTON3_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  142. #define BUTTON4_PIN 14
  143. #define BUTTON4_RELAY 4
  144. #define BUTTON4_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  145. #define RELAY1_PIN 12
  146. #define RELAY1_PIN_INVERSE 0
  147. #define RELAY2_PIN 5
  148. #define RELAY2_PIN_INVERSE 0
  149. #define RELAY3_PIN 4
  150. #define RELAY3_PIN_INVERSE 0
  151. #define RELAY4_PIN 15
  152. #define RELAY4_PIN_INVERSE 0
  153. #define LED1_PIN 13
  154. #define LED1_PIN_INVERSE 1
  155. #elif defined(ITEAD_1CH_INCHING)
  156. // The inching functionality is managed by a misterious IC in the board.
  157. // You cannot control the inching button and functionality from the ESP8266
  158. // Besides, enabling the inching functionality using the hardware button
  159. // will result in the relay switching on and off continuously.
  160. // Fortunately the unkown IC keeps memory of the hardware inching status
  161. // so you can just disable it and forget. The inching LED must be lit.
  162. // You can still use the pulse options from the web interface
  163. // without problem.
  164. #define MANUFACTURER "ITEAD"
  165. #define DEVICE "1CH_INCHING"
  166. #define BUTTON1_PIN 0
  167. #define BUTTON1_RELAY 1
  168. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  169. #define RELAY1_PIN 12
  170. #define RELAY1_PIN_INVERSE 0
  171. #define LED1_PIN 13
  172. #define LED1_PIN_INVERSE 1
  173. #elif defined(ITEAD_MOTOR)
  174. #define MANUFACTURER "ITEAD"
  175. #define DEVICE "MOTOR"
  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. // -----------------------------------------------------------------------------
  184. // Electrodragon boards
  185. // -----------------------------------------------------------------------------
  186. #elif defined(ESP_RELAY_BOARD)
  187. #define MANUFACTURER "ELECTRODRAGON"
  188. #define DEVICE "ESP_RELAY_BOARD"
  189. #define BUTTON1_PIN 0
  190. #define BUTTON1_RELAY 1
  191. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  192. #define BUTTON2_PIN 2
  193. #define BUTTON2_RELAY 2
  194. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  195. #define RELAY1_PIN 12
  196. #define RELAY1_PIN_INVERSE 0
  197. #define RELAY2_PIN 13
  198. #define RELAY2_PIN_INVERSE 0
  199. #define LED1_PIN 16
  200. #define LED1_PIN_INVERSE 0
  201. // -----------------------------------------------------------------------------
  202. // WorkChoice ecoPlug
  203. // -----------------------------------------------------------------------------
  204. #elif defined(ECOPLUG)
  205. #define MANUFACTURER "WORKCHOICE"
  206. #define DEVICE "ECOPLUG"
  207. #define BUTTON1_PIN 13
  208. #define BUTTON1_RELAY 1
  209. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  210. #define RELAY1_PIN 15
  211. #define RELAY1_PIN_INVERSE 0
  212. #define LED1_PIN 2
  213. #define LED1_PIN_INVERSE 0
  214. // -----------------------------------------------------------------------------
  215. // AI Thinker
  216. // -----------------------------------------------------------------------------
  217. #elif defined(AI_LIGHT)
  218. #define MANUFACTURER "AI THINKER"
  219. #define DEVICE "AI LIGHT"
  220. #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT
  221. #define LIGHT_PROVIDER LIGHT_PROVIDER_MY9192
  222. // -----------------------------------------------------------------------------
  223. // LED Controller
  224. // -----------------------------------------------------------------------------
  225. #elif defined(LED_CONTROLLER)
  226. #define MANUFACTURER "MAGIC HOME"
  227. #define DEVICE "LED CONTROLLER"
  228. #define LED1_PIN 2
  229. #define LED1_PIN_INVERSE 1
  230. #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT
  231. #define LIGHT_PROVIDER LIGHT_PROVIDER_RGB
  232. // -----------------------------------------------------------------------------
  233. // Jan Goedeke Wifi Relay
  234. // https://github.com/JanGoe/esp8266-wifi-relay
  235. // -----------------------------------------------------------------------------
  236. #elif defined(WIFI_RELAY_NC)
  237. #define MANUFACTURER "JAN_GOEDEKE"
  238. #define DEVICE "WIFI_RELAY_NC"
  239. #define BUTTON1_PIN 12
  240. #define BUTTON1_RELAY 1
  241. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  242. #define BUTTON2_PIN 13
  243. #define BUTTON2_RELAY 2
  244. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  245. #define RELAY1_PIN 2
  246. #define RELAY1_PIN_INVERSE 1
  247. #define RELAY2_PIN 14
  248. #define RELAY2_PIN_INVERSE 1
  249. #elif defined(WIFI_RELAY_NO)
  250. #define MANUFACTURER "JAN_GOEDEKE"
  251. #define DEVICE "WIFI_RELAY_NO"
  252. #define BUTTON1_PIN 12
  253. #define BUTTON1_RELAY 1
  254. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  255. #define BUTTON2_PIN 13
  256. #define BUTTON2_RELAY 2
  257. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  258. #define RELAY1_PIN 2
  259. #define RELAY1_PIN_INVERSE 0
  260. #define RELAY2_PIN 14
  261. #define RELAY2_PIN_INVERSE 0
  262. // -----------------------------------------------------------------------------
  263. // Jorge García Wifi+Relays Board Kit
  264. // https://www.tindie.com/products/jorgegarciadev/wifi--relays-board-kit
  265. // https://github.com/jorgegarciadev/wifikit
  266. // -----------------------------------------------------------------------------
  267. #elif defined(WIFI_RELAYS_BOARD_KIT)
  268. #define MANUFACTURER "JORGE_GARCIA"
  269. #define DEVICE "WIFI_RELAYS_BOARD_KIT"
  270. #define RELAY1_PIN 0
  271. #define RELAY1_PIN_INVERSE 1
  272. #define RELAY2_PIN 2
  273. #define RELAY2_PIN_INVERSE 1
  274. // -----------------------------------------------------------------------------
  275. // WiFi MQTT Relay / Thermostat
  276. // -----------------------------------------------------------------------------
  277. #elif defined(MQTT_RELAY)
  278. #define MANUFACTURER "OPENENERGYMONITOR"
  279. #define DEVICE "MQTT_RELAY"
  280. #define BUTTON1_PIN 0
  281. #define BUTTON1_RELAY 1
  282. #define RELAY1_PIN 12
  283. #define RELAY1_PIN_INVERSE 0
  284. #define LED1_PIN 16
  285. #define LED1_PIN_INVERSE 0
  286. // -----------------------------------------------------------------------------
  287. // Unknown hardware
  288. // -----------------------------------------------------------------------------
  289. #else
  290. #error "UNSUPPORTED HARDWARE!"
  291. #endif
  292. // -----------------------------------------------------------------------------
  293. // Default values
  294. // -----------------------------------------------------------------------------
  295. #ifndef BUTTON1_PRESS
  296. #define BUTTON1_PRESS BUTTON_MODE_NONE
  297. #endif
  298. #ifndef BUTTON2_PRESS
  299. #define BUTTON2_PRESS BUTTON_MODE_NONE
  300. #endif
  301. #ifndef BUTTON3_PRESS
  302. #define BUTTON3_PRESS BUTTON_MODE_NONE
  303. #endif
  304. #ifndef BUTTON4_PRESS
  305. #define BUTTON4_PRESS BUTTON_MODE_NONE
  306. #endif
  307. #ifndef BUTTON1_CLICK
  308. #define BUTTON1_CLICK BUTTON_MODE_TOGGLE
  309. #endif
  310. #ifndef BUTTON2_CLICK
  311. #define BUTTON2_CLICK BUTTON_MODE_TOGGLE
  312. #endif
  313. #ifndef BUTTON3_CLICK
  314. #define BUTTON3_CLICK BUTTON_MODE_TOGGLE
  315. #endif
  316. #ifndef BUTTON4_CLICK
  317. #define BUTTON4_CLICK BUTTON_MODE_TOGGLE
  318. #endif
  319. #ifndef BUTTON1_DBLCLICK
  320. #define BUTTON1_DBLCLICK BUTTON_MODE_AP
  321. #endif
  322. #ifndef BUTTON2_DBLCLICK
  323. #define BUTTON2_DBLCLICK BUTTON_MODE_NONE
  324. #endif
  325. #ifndef BUTTON3_DBLCLICK
  326. #define BUTTON3_DBLCLICK BUTTON_MODE_NONE
  327. #endif
  328. #ifndef BUTTON4_DBLCLICK
  329. #define BUTTON4_DBLCLICK BUTTON_MODE_NONE
  330. #endif
  331. #ifndef BUTTON1_LNGCLICK
  332. #define BUTTON1_LNGCLICK BUTTON_MODE_RESET
  333. #endif
  334. #ifndef BUTTON2_LNGCLICK
  335. #define BUTTON2_LNGCLICK BUTTON_MODE_NONE
  336. #endif
  337. #ifndef BUTTON3_LNGCLICK
  338. #define BUTTON3_LNGCLICK BUTTON_MODE_NONE
  339. #endif
  340. #ifndef BUTTON4_LNGCLICK
  341. #define BUTTON4_LNGCLICK BUTTON_MODE_NONE
  342. #endif
  343. #ifndef BUTTON1_LNGLNGCLICK
  344. #define BUTTON1_LNGLNGCLICK BUTTON_MODE_FACTORY
  345. #endif
  346. #ifndef BUTTON2_LNGLNGCLICK
  347. #define BUTTON2_LNGLNGCLICK BUTTON_MODE_NONE
  348. #endif
  349. #ifndef BUTTON3_LNGLNGCLICK
  350. #define BUTTON3_LNGLNGCLICK BUTTON_MODE_NONE
  351. #endif
  352. #ifndef BUTTON4_LNGLNGCLICK
  353. #define BUTTON4_LNGLNGCLICK BUTTON_MODE_NONE
  354. #endif
  355. #ifndef BUTTON1_RELAY
  356. #define BUTTON1_RELAY 0
  357. #endif
  358. #ifndef BUTTON2_RELAY
  359. #define BUTTON2_RELAY 0
  360. #endif
  361. #ifndef BUTTON3_RELAY
  362. #define BUTTON3_RELAY 0
  363. #endif
  364. #ifndef BUTTON4_RELAY
  365. #define BUTTON4_RELAY 0
  366. #endif
  367. #ifndef RELAY1_LED
  368. #define RELAY1_LED 0
  369. #endif
  370. #ifndef RELAY2_LED
  371. #define RELAY2_LED 0
  372. #endif
  373. #ifndef RELAY3_LED
  374. #define RELAY3_LED 0
  375. #endif
  376. #ifndef RELAY4_LED
  377. #define RELAY4_LED 0
  378. #endif
  379. #ifndef WIFI_LED
  380. #define WIFI_LED 1
  381. #endif
  382. // Needed for ESP8285 boards under Windows using PlatformIO (?)
  383. #ifndef BUTTON_PUSHBUTTON
  384. #define BUTTON_PUSHBUTTON 0
  385. #define BUTTON_SWITCH 1
  386. #define BUTTON_DEFAULT_HIGH 2
  387. #define BUTTON_SET_PULLUP 4
  388. #endif
  389. // Relay providers
  390. #ifndef RELAY_PROVIDER
  391. #define RELAY_PROVIDER RELAY_PROVIDER_RELAY
  392. #endif
  393. // Light provider
  394. #ifndef LIGHT_PROVIDER
  395. #define LIGHT_PROVIDER LIGHT_PROVIDER_NONE
  396. #endif