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.

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