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.

537 lines
18 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 6
  205. #define TRACK_RELAY_STATUS 0
  206. // -----------------------------------------------------------------------------
  207. // Electrodragon boards
  208. // -----------------------------------------------------------------------------
  209. #elif defined(ESP_RELAY_BOARD)
  210. #define MANUFACTURER "ELECTRODRAGON"
  211. #define DEVICE "ESP_RELAY_BOARD"
  212. #define BUTTON1_PIN 0
  213. #define BUTTON1_RELAY 1
  214. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  215. #define BUTTON2_PIN 2
  216. #define BUTTON2_RELAY 2
  217. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  218. #define RELAY1_PIN 12
  219. #define RELAY1_PIN_INVERSE 0
  220. #define RELAY2_PIN 13
  221. #define RELAY2_PIN_INVERSE 0
  222. #define LED1_PIN 16
  223. #define LED1_PIN_INVERSE 0
  224. // -----------------------------------------------------------------------------
  225. // WorkChoice ecoPlug
  226. // -----------------------------------------------------------------------------
  227. #elif defined(ECOPLUG)
  228. #define MANUFACTURER "WORKCHOICE"
  229. #define DEVICE "ECOPLUG"
  230. #define BUTTON1_PIN 13
  231. #define BUTTON1_RELAY 1
  232. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  233. #define RELAY1_PIN 15
  234. #define RELAY1_PIN_INVERSE 0
  235. #define LED1_PIN 2
  236. #define LED1_PIN_INVERSE 0
  237. // -----------------------------------------------------------------------------
  238. // AI Thinker
  239. // -----------------------------------------------------------------------------
  240. #elif defined(AI_LIGHT)
  241. #define MANUFACTURER "AI_THINKER"
  242. #define DEVICE "AI_LIGHT"
  243. #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT
  244. #define LIGHT_PROVIDER LIGHT_PROVIDER_MY9192
  245. #define DUMMY_RELAY_COUNT 1
  246. // -----------------------------------------------------------------------------
  247. // LED Controller
  248. // -----------------------------------------------------------------------------
  249. #elif defined(LED_CONTROLLER)
  250. #define MANUFACTURER "MAGIC_HOME"
  251. #define DEVICE "LED_CONTROLLER"
  252. #define LED1_PIN 2
  253. #define LED1_PIN_INVERSE 1
  254. #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT
  255. #define LIGHT_PROVIDER LIGHT_PROVIDER_RGB
  256. #define DUMMY_RELAY_COUNT 1
  257. #undef RGBW_INVERSE_LOGIC
  258. #undef RGBW_RED_PIN
  259. #undef RGBW_GREEN_PIN
  260. #undef RGBW_BLUE_PIN
  261. #undef RGBW_WHITE_PIN
  262. #define RGBW_INVERSE_LOGIC 1
  263. #define RGBW_RED_PIN 14
  264. #define RGBW_GREEN_PIN 5
  265. #define RGBW_BLUE_PIN 12
  266. #define RGBW_WHITE_PIN 13
  267. // -----------------------------------------------------------------------------
  268. // HUACANXING H801
  269. // -----------------------------------------------------------------------------
  270. #elif defined(H801_LED_CONTROLLER)
  271. #define MANUFACTURER "HUACANXING"
  272. #define DEVICE "H801"
  273. #define LED1_PIN 5
  274. #define LED1_PIN_INVERSE 1
  275. #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT
  276. #define LIGHT_PROVIDER LIGHT_PROVIDER_RGB2W
  277. #define DUMMY_RELAY_COUNT 1
  278. #undef RGBW_INVERSE_LOGIC
  279. #undef RGBW_RED_PIN
  280. #undef RGBW_GREEN_PIN
  281. #undef RGBW_BLUE_PIN
  282. #undef RGBW_WHITE_PIN
  283. #define RGBW_INVERSE_LOGIC 1
  284. #define RGBW_RED_PIN 15
  285. #define RGBW_GREEN_PIN 13
  286. #define RGBW_BLUE_PIN 12
  287. #define RGBW_WHITE_PIN 14
  288. #define RGBW_WHITE2_PIN 4
  289. // -----------------------------------------------------------------------------
  290. // Jan Goedeke Wifi Relay
  291. // https://github.com/JanGoe/esp8266-wifi-relay
  292. // -----------------------------------------------------------------------------
  293. #elif defined(WIFI_RELAY_NC)
  294. #define MANUFACTURER "JAN_GOEDEKE"
  295. #define DEVICE "WIFI_RELAY_NC"
  296. #define BUTTON1_PIN 12
  297. #define BUTTON1_RELAY 1
  298. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  299. #define BUTTON2_PIN 13
  300. #define BUTTON2_RELAY 2
  301. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  302. #define RELAY1_PIN 2
  303. #define RELAY1_PIN_INVERSE 1
  304. #define RELAY2_PIN 14
  305. #define RELAY2_PIN_INVERSE 1
  306. #elif defined(WIFI_RELAY_NO)
  307. #define MANUFACTURER "JAN_GOEDEKE"
  308. #define DEVICE "WIFI_RELAY_NO"
  309. #define BUTTON1_PIN 12
  310. #define BUTTON1_RELAY 1
  311. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  312. #define BUTTON2_PIN 13
  313. #define BUTTON2_RELAY 2
  314. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  315. #define RELAY1_PIN 2
  316. #define RELAY1_PIN_INVERSE 0
  317. #define RELAY2_PIN 14
  318. #define RELAY2_PIN_INVERSE 0
  319. // -----------------------------------------------------------------------------
  320. // Jorge García Wifi+Relays Board Kit
  321. // https://www.tindie.com/products/jorgegarciadev/wifi--relays-board-kit
  322. // https://github.com/jorgegarciadev/wifikit
  323. // -----------------------------------------------------------------------------
  324. #elif defined(WIFI_RELAYS_BOARD_KIT)
  325. #define MANUFACTURER "JORGE_GARCIA"
  326. #define DEVICE "WIFI_RELAYS_BOARD_KIT"
  327. #define RELAY1_PIN 0
  328. #define RELAY1_PIN_INVERSE 1
  329. #define RELAY2_PIN 2
  330. #define RELAY2_PIN_INVERSE 1
  331. // -----------------------------------------------------------------------------
  332. // WiFi MQTT Relay / Thermostat
  333. // -----------------------------------------------------------------------------
  334. #elif defined(MQTT_RELAY)
  335. #define MANUFACTURER "OPENENERGYMONITOR"
  336. #define DEVICE "MQTT_RELAY"
  337. #define BUTTON1_PIN 0
  338. #define BUTTON1_RELAY 1
  339. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  340. #define RELAY1_PIN 12
  341. #define RELAY1_PIN_INVERSE 0
  342. #define LED1_PIN 16
  343. #define LED1_PIN_INVERSE 0
  344. // -----------------------------------------------------------------------------
  345. // Unknown hardware
  346. // -----------------------------------------------------------------------------
  347. #else
  348. #error "UNSUPPORTED HARDWARE!"
  349. #endif
  350. // -----------------------------------------------------------------------------
  351. // Default values
  352. // -----------------------------------------------------------------------------
  353. #ifndef BUTTON1_PRESS
  354. #define BUTTON1_PRESS BUTTON_MODE_NONE
  355. #endif
  356. #ifndef BUTTON2_PRESS
  357. #define BUTTON2_PRESS BUTTON_MODE_NONE
  358. #endif
  359. #ifndef BUTTON3_PRESS
  360. #define BUTTON3_PRESS BUTTON_MODE_NONE
  361. #endif
  362. #ifndef BUTTON4_PRESS
  363. #define BUTTON4_PRESS BUTTON_MODE_NONE
  364. #endif
  365. #ifndef BUTTON1_CLICK
  366. #define BUTTON1_CLICK BUTTON_MODE_TOGGLE
  367. #endif
  368. #ifndef BUTTON2_CLICK
  369. #define BUTTON2_CLICK BUTTON_MODE_TOGGLE
  370. #endif
  371. #ifndef BUTTON3_CLICK
  372. #define BUTTON3_CLICK BUTTON_MODE_TOGGLE
  373. #endif
  374. #ifndef BUTTON4_CLICK
  375. #define BUTTON4_CLICK BUTTON_MODE_TOGGLE
  376. #endif
  377. #ifndef BUTTON1_DBLCLICK
  378. #define BUTTON1_DBLCLICK BUTTON_MODE_AP
  379. #endif
  380. #ifndef BUTTON2_DBLCLICK
  381. #define BUTTON2_DBLCLICK BUTTON_MODE_NONE
  382. #endif
  383. #ifndef BUTTON3_DBLCLICK
  384. #define BUTTON3_DBLCLICK BUTTON_MODE_NONE
  385. #endif
  386. #ifndef BUTTON4_DBLCLICK
  387. #define BUTTON4_DBLCLICK BUTTON_MODE_NONE
  388. #endif
  389. #ifndef BUTTON1_LNGCLICK
  390. #define BUTTON1_LNGCLICK BUTTON_MODE_RESET
  391. #endif
  392. #ifndef BUTTON2_LNGCLICK
  393. #define BUTTON2_LNGCLICK BUTTON_MODE_NONE
  394. #endif
  395. #ifndef BUTTON3_LNGCLICK
  396. #define BUTTON3_LNGCLICK BUTTON_MODE_NONE
  397. #endif
  398. #ifndef BUTTON4_LNGCLICK
  399. #define BUTTON4_LNGCLICK BUTTON_MODE_NONE
  400. #endif
  401. #ifndef BUTTON1_LNGLNGCLICK
  402. #define BUTTON1_LNGLNGCLICK BUTTON_MODE_FACTORY
  403. #endif
  404. #ifndef BUTTON2_LNGLNGCLICK
  405. #define BUTTON2_LNGLNGCLICK BUTTON_MODE_NONE
  406. #endif
  407. #ifndef BUTTON3_LNGLNGCLICK
  408. #define BUTTON3_LNGLNGCLICK BUTTON_MODE_NONE
  409. #endif
  410. #ifndef BUTTON4_LNGLNGCLICK
  411. #define BUTTON4_LNGLNGCLICK BUTTON_MODE_NONE
  412. #endif
  413. #ifndef BUTTON1_RELAY
  414. #define BUTTON1_RELAY 0
  415. #endif
  416. #ifndef BUTTON2_RELAY
  417. #define BUTTON2_RELAY 0
  418. #endif
  419. #ifndef BUTTON3_RELAY
  420. #define BUTTON3_RELAY 0
  421. #endif
  422. #ifndef BUTTON4_RELAY
  423. #define BUTTON4_RELAY 0
  424. #endif
  425. #ifndef RELAY1_LED
  426. #define RELAY1_LED 0
  427. #endif
  428. #ifndef RELAY2_LED
  429. #define RELAY2_LED 0
  430. #endif
  431. #ifndef RELAY3_LED
  432. #define RELAY3_LED 0
  433. #endif
  434. #ifndef RELAY4_LED
  435. #define RELAY4_LED 0
  436. #endif
  437. #ifndef WIFI_LED
  438. #define WIFI_LED 1
  439. #endif
  440. // Needed for ESP8285 boards under Windows using PlatformIO (?)
  441. #ifndef BUTTON_PUSHBUTTON
  442. #define BUTTON_PUSHBUTTON 0
  443. #define BUTTON_SWITCH 1
  444. #define BUTTON_DEFAULT_HIGH 2
  445. #define BUTTON_SET_PULLUP 4
  446. #endif
  447. // Does the board track the relay status?
  448. #ifndef TRACK_RELAY_STATUS
  449. #define TRACK_RELAY_STATUS 1
  450. #endif
  451. // Relay providers
  452. #ifndef RELAY_PROVIDER
  453. #define RELAY_PROVIDER RELAY_PROVIDER_RELAY
  454. #endif
  455. // Light provider
  456. #ifndef LIGHT_PROVIDER
  457. #define LIGHT_PROVIDER LIGHT_PROVIDER_NONE
  458. #endif