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.

515 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_POW 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_POW 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. #elif defined(SONOFF_4CH)
  140. #define MANUFACTURER "ITEAD"
  141. #define DEVICE "SONOFF_4CH"
  142. #define BUTTON1_PIN 0
  143. #define BUTTON1_RELAY 1
  144. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  145. #define BUTTON2_PIN 9
  146. #define BUTTON2_RELAY 2
  147. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  148. #define BUTTON3_PIN 10
  149. #define BUTTON3_RELAY 3
  150. #define BUTTON3_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  151. #define BUTTON4_PIN 14
  152. #define BUTTON4_RELAY 4
  153. #define BUTTON4_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  154. #define RELAY1_PIN 12
  155. #define RELAY1_PIN_INVERSE 0
  156. #define RELAY2_PIN 5
  157. #define RELAY2_PIN_INVERSE 0
  158. #define RELAY3_PIN 4
  159. #define RELAY3_PIN_INVERSE 0
  160. #define RELAY4_PIN 15
  161. #define RELAY4_PIN_INVERSE 0
  162. #define LED1_PIN 13
  163. #define LED1_PIN_INVERSE 1
  164. #elif defined(ITEAD_1CH_INCHING)
  165. // The inching functionality is managed by a misterious IC in the board.
  166. // You cannot control the inching button and functionality from the ESP8266
  167. // Besides, enabling the inching functionality using the hardware button
  168. // will result in the relay switching on and off continuously.
  169. // Fortunately the unkown IC keeps memory of the hardware inching status
  170. // so you can just disable it and forget. The inching LED must be lit.
  171. // You can still use the pulse options from the web interface
  172. // without problem.
  173. #define MANUFACTURER "ITEAD"
  174. #define DEVICE "1CH_INCHING"
  175. #define BUTTON1_PIN 0
  176. #define BUTTON1_RELAY 1
  177. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  178. #define RELAY1_PIN 12
  179. #define RELAY1_PIN_INVERSE 0
  180. #define LED1_PIN 13
  181. #define LED1_PIN_INVERSE 1
  182. #elif defined(ITEAD_MOTOR)
  183. #define MANUFACTURER "ITEAD"
  184. #define DEVICE "MOTOR"
  185. #define BUTTON1_PIN 0
  186. #define BUTTON1_RELAY 1
  187. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  188. #define RELAY1_PIN 12
  189. #define RELAY1_PIN_INVERSE 0
  190. #define LED1_PIN 13
  191. #define LED1_PIN_INVERSE 1
  192. // -----------------------------------------------------------------------------
  193. // Electrodragon boards
  194. // -----------------------------------------------------------------------------
  195. #elif defined(ESP_RELAY_BOARD)
  196. #define MANUFACTURER "ELECTRODRAGON"
  197. #define DEVICE "ESP_RELAY_BOARD"
  198. #define BUTTON1_PIN 0
  199. #define BUTTON1_RELAY 1
  200. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  201. #define BUTTON2_PIN 2
  202. #define BUTTON2_RELAY 2
  203. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  204. #define RELAY1_PIN 12
  205. #define RELAY1_PIN_INVERSE 0
  206. #define RELAY2_PIN 13
  207. #define RELAY2_PIN_INVERSE 0
  208. #define LED1_PIN 16
  209. #define LED1_PIN_INVERSE 0
  210. // -----------------------------------------------------------------------------
  211. // WorkChoice ecoPlug
  212. // -----------------------------------------------------------------------------
  213. #elif defined(ECOPLUG)
  214. #define MANUFACTURER "WORKCHOICE"
  215. #define DEVICE "ECOPLUG"
  216. #define BUTTON1_PIN 13
  217. #define BUTTON1_RELAY 1
  218. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  219. #define RELAY1_PIN 15
  220. #define RELAY1_PIN_INVERSE 0
  221. #define LED1_PIN 2
  222. #define LED1_PIN_INVERSE 0
  223. // -----------------------------------------------------------------------------
  224. // AI Thinker
  225. // -----------------------------------------------------------------------------
  226. #elif defined(AI_LIGHT)
  227. #define MANUFACTURER "AI_THINKER"
  228. #define DEVICE "AI_LIGHT"
  229. #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT
  230. #define LIGHT_PROVIDER LIGHT_PROVIDER_MY9192
  231. // -----------------------------------------------------------------------------
  232. // LED Controller
  233. // -----------------------------------------------------------------------------
  234. #elif defined(LED_CONTROLLER)
  235. #define MANUFACTURER "MAGIC_HOME"
  236. #define DEVICE "LED_CONTROLLER"
  237. #define LED1_PIN 2
  238. #define LED1_PIN_INVERSE 1
  239. #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT
  240. #define LIGHT_PROVIDER LIGHT_PROVIDER_RGB
  241. #undef RGBW_INVERSE_LOGIC
  242. #undef RGBW_RED_PIN
  243. #undef RGBW_GREEN_PIN
  244. #undef RGBW_BLUE_PIN
  245. #undef RGBW_WHITE_PIN
  246. #define RGBW_INVERSE_LOGIC 1
  247. #define RGBW_RED_PIN 14
  248. #define RGBW_GREEN_PIN 5
  249. #define RGBW_BLUE_PIN 12
  250. #define RGBW_WHITE_PIN 13
  251. // -----------------------------------------------------------------------------
  252. // HUACANXING H801
  253. // -----------------------------------------------------------------------------
  254. #elif defined(H801)
  255. #define MANUFACTURER "HUACANXING"
  256. #define DEVICE "H801"
  257. #define LED1_PIN 5
  258. #define LED1_PIN_INVERSE 1
  259. #define LED2_PIN 2
  260. #define LED2_PIN_INVERSE 1
  261. #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT
  262. #define LIGHT_PROVIDER LIGHT_PROVIDER_RGBW
  263. #undef RGBW_INVERSE_LOGIC
  264. #undef RGBW_RED_PIN
  265. #undef RGBW_GREEN_PIN
  266. #undef RGBW_BLUE_PIN
  267. #undef RGBW_WHITE_PIN
  268. #define RGBW_INVERSE_LOGIC 0
  269. #define RGBW_RED_PIN 15
  270. #define RGBW_GREEN_PIN 13
  271. #define RGBW_BLUE_PIN 12
  272. #define RGBW_WHITE_PIN 14
  273. //#define RGBW_WHITE_PIN 4 <= warm white
  274. // -----------------------------------------------------------------------------
  275. // Jan Goedeke Wifi Relay
  276. // https://github.com/JanGoe/esp8266-wifi-relay
  277. // -----------------------------------------------------------------------------
  278. #elif defined(WIFI_RELAY_NC)
  279. #define MANUFACTURER "JAN_GOEDEKE"
  280. #define DEVICE "WIFI_RELAY_NC"
  281. #define BUTTON1_PIN 12
  282. #define BUTTON1_RELAY 1
  283. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  284. #define BUTTON2_PIN 13
  285. #define BUTTON2_RELAY 2
  286. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  287. #define RELAY1_PIN 2
  288. #define RELAY1_PIN_INVERSE 1
  289. #define RELAY2_PIN 14
  290. #define RELAY2_PIN_INVERSE 1
  291. #elif defined(WIFI_RELAY_NO)
  292. #define MANUFACTURER "JAN_GOEDEKE"
  293. #define DEVICE "WIFI_RELAY_NO"
  294. #define BUTTON1_PIN 12
  295. #define BUTTON1_RELAY 1
  296. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  297. #define BUTTON2_PIN 13
  298. #define BUTTON2_RELAY 2
  299. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  300. #define RELAY1_PIN 2
  301. #define RELAY1_PIN_INVERSE 0
  302. #define RELAY2_PIN 14
  303. #define RELAY2_PIN_INVERSE 0
  304. // -----------------------------------------------------------------------------
  305. // Jorge García Wifi+Relays Board Kit
  306. // https://www.tindie.com/products/jorgegarciadev/wifi--relays-board-kit
  307. // https://github.com/jorgegarciadev/wifikit
  308. // -----------------------------------------------------------------------------
  309. #elif defined(WIFI_RELAYS_BOARD_KIT)
  310. #define MANUFACTURER "JORGE_GARCIA"
  311. #define DEVICE "WIFI_RELAYS_BOARD_KIT"
  312. #define RELAY1_PIN 0
  313. #define RELAY1_PIN_INVERSE 1
  314. #define RELAY2_PIN 2
  315. #define RELAY2_PIN_INVERSE 1
  316. // -----------------------------------------------------------------------------
  317. // WiFi MQTT Relay / Thermostat
  318. // -----------------------------------------------------------------------------
  319. #elif defined(MQTT_RELAY)
  320. #define MANUFACTURER "OPENENERGYMONITOR"
  321. #define DEVICE "MQTT_RELAY"
  322. #define BUTTON1_PIN 0
  323. #define BUTTON1_RELAY 1
  324. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  325. #define RELAY1_PIN 12
  326. #define RELAY1_PIN_INVERSE 0
  327. #define LED1_PIN 16
  328. #define LED1_PIN_INVERSE 0
  329. // -----------------------------------------------------------------------------
  330. // Unknown hardware
  331. // -----------------------------------------------------------------------------
  332. #else
  333. #error "UNSUPPORTED HARDWARE!"
  334. #endif
  335. // -----------------------------------------------------------------------------
  336. // Default values
  337. // -----------------------------------------------------------------------------
  338. #ifndef BUTTON1_PRESS
  339. #define BUTTON1_PRESS BUTTON_MODE_NONE
  340. #endif
  341. #ifndef BUTTON2_PRESS
  342. #define BUTTON2_PRESS BUTTON_MODE_NONE
  343. #endif
  344. #ifndef BUTTON3_PRESS
  345. #define BUTTON3_PRESS BUTTON_MODE_NONE
  346. #endif
  347. #ifndef BUTTON4_PRESS
  348. #define BUTTON4_PRESS BUTTON_MODE_NONE
  349. #endif
  350. #ifndef BUTTON1_CLICK
  351. #define BUTTON1_CLICK BUTTON_MODE_TOGGLE
  352. #endif
  353. #ifndef BUTTON2_CLICK
  354. #define BUTTON2_CLICK BUTTON_MODE_TOGGLE
  355. #endif
  356. #ifndef BUTTON3_CLICK
  357. #define BUTTON3_CLICK BUTTON_MODE_TOGGLE
  358. #endif
  359. #ifndef BUTTON4_CLICK
  360. #define BUTTON4_CLICK BUTTON_MODE_TOGGLE
  361. #endif
  362. #ifndef BUTTON1_DBLCLICK
  363. #define BUTTON1_DBLCLICK BUTTON_MODE_AP
  364. #endif
  365. #ifndef BUTTON2_DBLCLICK
  366. #define BUTTON2_DBLCLICK BUTTON_MODE_NONE
  367. #endif
  368. #ifndef BUTTON3_DBLCLICK
  369. #define BUTTON3_DBLCLICK BUTTON_MODE_NONE
  370. #endif
  371. #ifndef BUTTON4_DBLCLICK
  372. #define BUTTON4_DBLCLICK BUTTON_MODE_NONE
  373. #endif
  374. #ifndef BUTTON1_LNGCLICK
  375. #define BUTTON1_LNGCLICK BUTTON_MODE_RESET
  376. #endif
  377. #ifndef BUTTON2_LNGCLICK
  378. #define BUTTON2_LNGCLICK BUTTON_MODE_NONE
  379. #endif
  380. #ifndef BUTTON3_LNGCLICK
  381. #define BUTTON3_LNGCLICK BUTTON_MODE_NONE
  382. #endif
  383. #ifndef BUTTON4_LNGCLICK
  384. #define BUTTON4_LNGCLICK BUTTON_MODE_NONE
  385. #endif
  386. #ifndef BUTTON1_LNGLNGCLICK
  387. #define BUTTON1_LNGLNGCLICK BUTTON_MODE_FACTORY
  388. #endif
  389. #ifndef BUTTON2_LNGLNGCLICK
  390. #define BUTTON2_LNGLNGCLICK BUTTON_MODE_NONE
  391. #endif
  392. #ifndef BUTTON3_LNGLNGCLICK
  393. #define BUTTON3_LNGLNGCLICK BUTTON_MODE_NONE
  394. #endif
  395. #ifndef BUTTON4_LNGLNGCLICK
  396. #define BUTTON4_LNGLNGCLICK BUTTON_MODE_NONE
  397. #endif
  398. #ifndef BUTTON1_RELAY
  399. #define BUTTON1_RELAY 0
  400. #endif
  401. #ifndef BUTTON2_RELAY
  402. #define BUTTON2_RELAY 0
  403. #endif
  404. #ifndef BUTTON3_RELAY
  405. #define BUTTON3_RELAY 0
  406. #endif
  407. #ifndef BUTTON4_RELAY
  408. #define BUTTON4_RELAY 0
  409. #endif
  410. #ifndef RELAY1_LED
  411. #define RELAY1_LED 0
  412. #endif
  413. #ifndef RELAY2_LED
  414. #define RELAY2_LED 0
  415. #endif
  416. #ifndef RELAY3_LED
  417. #define RELAY3_LED 0
  418. #endif
  419. #ifndef RELAY4_LED
  420. #define RELAY4_LED 0
  421. #endif
  422. #ifndef WIFI_LED
  423. #define WIFI_LED 1
  424. #endif
  425. // Needed for ESP8285 boards under Windows using PlatformIO (?)
  426. #ifndef BUTTON_PUSHBUTTON
  427. #define BUTTON_PUSHBUTTON 0
  428. #define BUTTON_SWITCH 1
  429. #define BUTTON_DEFAULT_HIGH 2
  430. #define BUTTON_SET_PULLUP 4
  431. #endif
  432. // Relay providers
  433. #ifndef RELAY_PROVIDER
  434. #define RELAY_PROVIDER RELAY_PROVIDER_RELAY
  435. #endif
  436. // Light provider
  437. #ifndef LIGHT_PROVIDER
  438. #define LIGHT_PROVIDER LIGHT_PROVIDER_NONE
  439. #endif