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.

1928 lines
64 KiB

8 years ago
8 years ago
6 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
6 years ago
6 years ago
6 years ago
8 years ago
8 years ago
6 years ago
6 years ago
6 years ago
6 years ago
8 years ago
6 years ago
  1. // // //------------------------------------------------------------------------------
  2. // Do not change this file unless you know what you are doing
  3. // Configuration settings are in the settings.h file
  4. //------------------------------------------------------------------------------
  5. //------------------------------------------------------------------------------
  6. // GENERAL
  7. //------------------------------------------------------------------------------
  8. #define DEVICE_NAME MANUFACTURER "_" DEVICE // Concatenate both to get a unique device name
  9. // When defined, ADMIN_PASS must be 8..63 printable ASCII characters. See:
  10. // https://en.wikipedia.org/wiki/Wi-Fi_Protected_Access#Target_users_(authentication_key_distribution)
  11. // https://github.com/xoseperez/espurna/issues/1151
  12. #ifndef ADMIN_PASS
  13. #define ADMIN_PASS "fibonacci" // Default password (WEB, OTA, WIFI SoftAP)
  14. #endif
  15. #ifndef USE_PASSWORD
  16. #define USE_PASSWORD 1 // Insecurity caution! Disabling this will disable password querying completely.
  17. #endif
  18. #ifndef LOOP_DELAY_TIME
  19. #define LOOP_DELAY_TIME 10 // Delay for the main loop, in millis [0-250]
  20. // Recommended minimum is 10, see:
  21. // https://github.com/xoseperez/espurna/issues/1541
  22. // https://github.com/xoseperez/espurna/issues/1631
  23. // https://github.com/esp8266/Arduino/issues/5825
  24. #endif
  25. //------------------------------------------------------------------------------
  26. // DEBUG
  27. //------------------------------------------------------------------------------
  28. #ifndef DEBUG_LOG_MODE
  29. #define DEBUG_LOG_MODE DebugLogMode::Enabled // Set global logger mode. One of:
  30. // ::Enabled, ::Disabled or ::SkipBoot
  31. #endif
  32. // Serial debug log
  33. #ifndef DEBUG_SERIAL_SUPPORT
  34. #define DEBUG_SERIAL_SUPPORT 1 // Enable serial debug log
  35. #endif
  36. #ifndef DEBUG_PORT
  37. #define DEBUG_PORT Serial // Default debugging port
  38. #endif
  39. #ifndef SERIAL_BAUDRATE
  40. #define SERIAL_BAUDRATE 115200 // Default baudrate
  41. #endif
  42. #ifndef DEBUG_ADD_TIMESTAMP
  43. #define DEBUG_ADD_TIMESTAMP 1 // Add timestamp to debug messages
  44. // (in millis overflowing every 1000 seconds)
  45. #endif
  46. // Second serial port (used for RX)
  47. #ifndef SERIAL_RX_ENABLED
  48. #define SERIAL_RX_ENABLED 0 // Secondary serial port for RX
  49. #endif
  50. #ifndef SERIAL_RX_PORT
  51. #define SERIAL_RX_PORT Serial // This setting is usually defined
  52. // in the hardware.h file for those
  53. // boards that require it
  54. #endif
  55. #ifndef SERIAL_RX_BAUDRATE
  56. #define SERIAL_RX_BAUDRATE 115200 // Default baudrate
  57. #endif
  58. //------------------------------------------------------------------------------
  59. // UDP debug log
  60. // To receive the message son the destination computer use nc:
  61. // nc -ul 8113
  62. #ifndef DEBUG_UDP_SUPPORT
  63. #define DEBUG_UDP_SUPPORT 0 // Enable UDP debug log
  64. #endif
  65. #ifndef DEBUG_UDP_IP
  66. #define DEBUG_UDP_IP IPAddress(192, 168, 1, 100)
  67. #endif
  68. #ifndef DEBUG_UDP_PORT
  69. #define DEBUG_UDP_PORT 514
  70. #endif
  71. // If DEBUG_UDP_PORT is set to 514 syslog format is assumed
  72. // (https://tools.ietf.org/html/rfc3164)
  73. // DEBUG_UDP_FAC_PRI is the facility+priority
  74. #define DEBUG_UDP_FAC_PRI (SYSLOG_LOCAL0 | SYSLOG_DEBUG)
  75. //------------------------------------------------------------------------------
  76. #ifndef DEBUG_TELNET_SUPPORT
  77. #define DEBUG_TELNET_SUPPORT 1 // Enable telnet debug log (will only work if TELNET_SUPPORT is also 1)
  78. #endif
  79. //------------------------------------------------------------------------------
  80. #ifndef DEBUG_WEB_SUPPORT
  81. #define DEBUG_WEB_SUPPORT 1 // Enable web debug log (will only work if WEB_SUPPORT is also 1)
  82. #endif
  83. //------------------------------------------------------------------------------
  84. #ifndef DEBUG_LOG_BUFFER_SUPPORT
  85. #define DEBUG_LOG_BUFFER_SUPPORT 1 // Support boot log buffer (1.2Kb)
  86. // Will only work if DEBUG_LOG_BUFFER_ENABLED or runtime setting is also 1
  87. #endif
  88. #ifndef DEBUG_LOG_BUFFER_ENABLED
  89. #define DEBUG_LOG_BUFFER_ENABLED 0 // Disable boot log buffer by default
  90. #endif
  91. #ifndef DEBUG_LOG_BUFFER_SIZE
  92. #define DEBUG_LOG_BUFFER_SIZE 4096 // Store 4 Kb of log strings
  93. // WARNING! Memory is only reclaimed after `debug.buffer` prints the buffer contents
  94. #endif
  95. //------------------------------------------------------------------------------
  96. // TELNET
  97. //------------------------------------------------------------------------------
  98. #ifndef TELNET_SUPPORT
  99. #define TELNET_SUPPORT 1 // Enable telnet support by default (3.34Kb)
  100. #endif
  101. #ifndef TELNET_STA
  102. #define TELNET_STA 0 // By default, disallow connections via STA interface
  103. #endif
  104. #ifndef TELNET_AUTHENTICATION
  105. #define TELNET_AUTHENTICATION 1 // Request password to start telnet session by default
  106. #endif
  107. #ifndef TELNET_PORT
  108. #define TELNET_PORT 23 // Port to listen to telnet clients
  109. #endif
  110. #ifndef TELNET_MAX_CLIENTS
  111. #define TELNET_MAX_CLIENTS 1 // Max number of concurrent telnet clients
  112. #endif
  113. #ifndef TELNET_SERVER
  114. #define TELNET_SERVER TELNET_SERVER_ASYNC // Can be either TELNET_SERVER_ASYNC (using ESPAsyncTCP) or TELNET_SERVER_WIFISERVER (using WiFiServer)
  115. #endif
  116. #ifndef TELNET_SERVER_ASYNC_BUFFERED
  117. #define TELNET_SERVER_ASYNC_BUFFERED 0 // Enable buffered output for telnet server (+1Kb)
  118. // Helps to avoid lost data with lwip2 TCP_MSS=536 option
  119. #endif
  120. // Enable this flag to add support for reverse telnet (+800 bytes)
  121. // This is useful to telnet to a device behind a NAT or firewall
  122. // To use this feature, start a listen server on a publicly reachable host with e.g. "ncat -vlp <port>" and use the MQTT reverse telnet command to connect
  123. #ifndef TELNET_REVERSE_SUPPORT
  124. #define TELNET_REVERSE_SUPPORT 0
  125. #endif
  126. //------------------------------------------------------------------------------
  127. // TERMINAL
  128. //------------------------------------------------------------------------------
  129. #ifndef TERMINAL_SUPPORT
  130. #define TERMINAL_SUPPORT 1 // Enable terminal commands (0.97Kb)
  131. #endif
  132. #define TERMINAL_BUFFER_SIZE 128 // Max size for commands commands
  133. //------------------------------------------------------------------------------
  134. // SYSTEM CHECK
  135. //------------------------------------------------------------------------------
  136. #ifndef SYSTEM_CHECK_ENABLED
  137. #define SYSTEM_CHECK_ENABLED 1 // Enable crash check by default
  138. #endif
  139. #ifndef SYSTEM_CHECK_TIME
  140. #define SYSTEM_CHECK_TIME 60000 // The system is considered stable after these many millis
  141. #endif
  142. #ifndef SYSTEM_CHECK_MAX
  143. #define SYSTEM_CHECK_MAX 5 // After this many crashes on boot
  144. // the system is flagged as unstable
  145. #endif
  146. //------------------------------------------------------------------------------
  147. // EEPROM
  148. //------------------------------------------------------------------------------
  149. #define EEPROM_SIZE SPI_FLASH_SEC_SIZE // EEPROM size in bytes (1 sector = 4096 bytes)
  150. //#define EEPROM_RORATE_SECTORS 2 // Number of sectors to use for EEPROM rotation
  151. // If not defined the firmware will use a number based
  152. // on the number of available sectors
  153. #define EEPROM_RELAY_STATUS 0 // Address for the relay status (1 byte)
  154. #define EEPROM_ENERGY_COUNT 1 // Address for the energy counter (4 bytes)
  155. #define EEPROM_CUSTOM_RESET 5 // Address for the reset reason (1 byte)
  156. #define EEPROM_CRASH_COUNTER 6 // Address for the crash counter (1 byte)
  157. #define EEPROM_MESSAGE_ID 7 // Address for the MQTT message id (4 bytes)
  158. #define EEPROM_ROTATE_DATA 11 // Reserved for the EEPROM_ROTATE library (3 bytes)
  159. #define EEPROM_DATA_END 14 // End of custom EEPROM data block
  160. #ifndef SAVE_CRASH_ENABLED
  161. #define SAVE_CRASH_ENABLED 1 // Save stack trace to EEPROM by default
  162. // Depends on DEBUG_SUPPORT == 1
  163. #endif
  164. #ifndef SAVE_CRASH_STACK_TRACE_MAX
  165. #define SAVE_CRASH_STACK_TRACE_MAX 0x80 // limit at 128 bytes (increment/decrement by 16)
  166. #endif
  167. //------------------------------------------------------------------------------
  168. // THERMOSTAT
  169. //------------------------------------------------------------------------------
  170. #ifndef THERMOSTAT_SUPPORT
  171. #define THERMOSTAT_SUPPORT 0
  172. #endif
  173. #ifndef THERMOSTAT_DISPLAY_SUPPORT
  174. #define THERMOSTAT_DISPLAY_SUPPORT 0
  175. #endif
  176. #define THERMOSTAT_SERVER_LOST_INTERVAL 120000 //server means lost after 2 min from last response
  177. #define THERMOSTAT_REMOTE_TEMP_MAX_WAIT 120 // 2 min
  178. //------------------------------------------------------------------------------
  179. // HEARTBEAT
  180. //------------------------------------------------------------------------------
  181. #define HEARTBEAT_NONE 0 // Never send heartbeat
  182. #define HEARTBEAT_ONCE 1 // Send it only once upon MQTT connection
  183. #define HEARTBEAT_REPEAT 2 // Send it upon MQTT connection and every HEARTBEAT_INTERVAL
  184. #define HEARTBEAT_REPEAT_STATUS 3 // Send it upon MQTT connection and every HEARTBEAT_INTERVAL only STATUS report
  185. // Backwards compatibility check
  186. #if defined(HEARTBEAT_ENABLED) && (HEARTBEAT_ENABLED == 0)
  187. #define HEARTBEAT_MODE HEARTBEAT_NONE
  188. #endif
  189. #ifndef HEARTBEAT_MODE
  190. #define HEARTBEAT_MODE HEARTBEAT_REPEAT
  191. #endif
  192. #ifndef HEARTBEAT_INTERVAL
  193. #define HEARTBEAT_INTERVAL 300UL // Interval between heartbeat messages (in sec)
  194. #endif
  195. #define UPTIME_OVERFLOW 4294967295UL // Uptime overflow value
  196. // Values that will be reported in heartbeat
  197. #ifndef HEARTBEAT_REPORT_STATUS
  198. #define HEARTBEAT_REPORT_STATUS 1
  199. #endif
  200. #ifndef HEARTBEAT_REPORT_SSID
  201. #define HEARTBEAT_REPORT_SSID 1
  202. #endif
  203. #ifndef HEARTBEAT_REPORT_IP
  204. #define HEARTBEAT_REPORT_IP 1
  205. #endif
  206. #ifndef HEARTBEAT_REPORT_MAC
  207. #define HEARTBEAT_REPORT_MAC 1
  208. #endif
  209. #ifndef HEARTBEAT_REPORT_RSSI
  210. #define HEARTBEAT_REPORT_RSSI 1
  211. #endif
  212. #ifndef HEARTBEAT_REPORT_UPTIME
  213. #define HEARTBEAT_REPORT_UPTIME 1
  214. #endif
  215. #ifndef HEARTBEAT_REPORT_DATETIME
  216. #define HEARTBEAT_REPORT_DATETIME 1
  217. #endif
  218. #ifndef HEARTBEAT_REPORT_FREEHEAP
  219. #define HEARTBEAT_REPORT_FREEHEAP 1
  220. #endif
  221. #ifndef HEARTBEAT_REPORT_VCC
  222. #define HEARTBEAT_REPORT_VCC 1
  223. #endif
  224. #ifndef HEARTBEAT_REPORT_RELAY
  225. #define HEARTBEAT_REPORT_RELAY 1
  226. #endif
  227. #ifndef HEARTBEAT_REPORT_LIGHT
  228. #define HEARTBEAT_REPORT_LIGHT 1
  229. #endif
  230. #ifndef HEARTBEAT_REPORT_HOSTNAME
  231. #define HEARTBEAT_REPORT_HOSTNAME 1
  232. #endif
  233. #ifndef HEARTBEAT_REPORT_DESCRIPTION
  234. #define HEARTBEAT_REPORT_DESCRIPTION 1
  235. #endif
  236. #ifndef HEARTBEAT_REPORT_APP
  237. #define HEARTBEAT_REPORT_APP 1
  238. #endif
  239. #ifndef HEARTBEAT_REPORT_VERSION
  240. #define HEARTBEAT_REPORT_VERSION 1
  241. #endif
  242. #ifndef HEARTBEAT_REPORT_BOARD
  243. #define HEARTBEAT_REPORT_BOARD 1
  244. #endif
  245. #ifndef HEARTBEAT_REPORT_LOADAVG
  246. #define HEARTBEAT_REPORT_LOADAVG 1
  247. #endif
  248. #ifndef HEARTBEAT_REPORT_INTERVAL
  249. #define HEARTBEAT_REPORT_INTERVAL 0
  250. #endif
  251. #ifndef HEARTBEAT_REPORT_RANGE
  252. #define HEARTBEAT_REPORT_RANGE THERMOSTAT_SUPPORT
  253. #endif
  254. #ifndef HEARTBEAT_REPORT_REMOTE_TEMP
  255. #define HEARTBEAT_REPORT_REMOTE_TEMP THERMOSTAT_SUPPORT
  256. #endif
  257. #ifndef HEARTBEAT_REPORT_BSSID
  258. #define HEARTBEAT_REPORT_BSSID 0
  259. #endif
  260. //------------------------------------------------------------------------------
  261. // Load average
  262. //------------------------------------------------------------------------------
  263. #ifndef LOADAVG_INTERVAL
  264. #define LOADAVG_INTERVAL 30000 // Interval between calculating load average (in ms)
  265. #endif
  266. //------------------------------------------------------------------------------
  267. // BUTTON
  268. //------------------------------------------------------------------------------
  269. #ifndef BUTTON_SUPPORT
  270. #define BUTTON_SUPPORT 1
  271. #endif
  272. #ifndef BUTTON_DEBOUNCE_DELAY
  273. #define BUTTON_DEBOUNCE_DELAY 50 // Debounce delay (ms)
  274. #endif
  275. #ifndef BUTTON_DBLCLICK_DELAY
  276. #define BUTTON_DBLCLICK_DELAY 500 // Time in ms to wait for a second (or third...) click
  277. #endif
  278. #ifndef BUTTON_LNGCLICK_DELAY
  279. #define BUTTON_LNGCLICK_DELAY 1000 // Time in ms holding the button down to get a long click
  280. #endif
  281. #ifndef BUTTON_LNGLNGCLICK_DELAY
  282. #define BUTTON_LNGLNGCLICK_DELAY 10000 // Time in ms holding the button down to get a long-long click
  283. #endif
  284. #ifndef BUTTON_MQTT_SEND_ALL_EVENTS
  285. #define BUTTON_MQTT_SEND_ALL_EVENTS 0 // 0 - to send only events the are bound to actions
  286. // 1 - to send all button events to MQTT
  287. #endif
  288. //------------------------------------------------------------------------------
  289. // ENCODER
  290. //------------------------------------------------------------------------------
  291. #ifndef ENCODER_SUPPORT
  292. #define ENCODER_SUPPORT 0
  293. #endif
  294. #ifndef ENCODER_MINIMUM_DELTA
  295. #define ENCODER_MINIMUM_DELTA 1
  296. #endif
  297. //------------------------------------------------------------------------------
  298. // LED
  299. //------------------------------------------------------------------------------
  300. #ifndef LED_SUPPORT
  301. #define LED_SUPPORT 1
  302. #endif
  303. //------------------------------------------------------------------------------
  304. // RELAY
  305. //------------------------------------------------------------------------------
  306. // Default boot mode: 0 means OFF, 1 ON and 2 whatever was before
  307. #ifndef RELAY_BOOT_MODE
  308. #define RELAY_BOOT_MODE RELAY_BOOT_OFF
  309. #endif
  310. // 0 means ANY, 1 zero or one and 2 one and only one
  311. #ifndef RELAY_SYNC
  312. #define RELAY_SYNC RELAY_SYNC_ANY
  313. #endif
  314. // Default pulse mode: 0 means no pulses, 1 means normally off, 2 normally on
  315. #ifndef RELAY_PULSE_MODE
  316. #define RELAY_PULSE_MODE RELAY_PULSE_NONE
  317. #endif
  318. // Default pulse time in seconds
  319. #ifndef RELAY_PULSE_TIME
  320. #define RELAY_PULSE_TIME 1.0
  321. #endif
  322. // Relay requests flood protection window - in seconds
  323. #ifndef RELAY_FLOOD_WINDOW
  324. #define RELAY_FLOOD_WINDOW 3.0
  325. #endif
  326. // Allowed actual relay changes inside requests flood protection window
  327. #ifndef RELAY_FLOOD_CHANGES
  328. #define RELAY_FLOOD_CHANGES 5
  329. #endif
  330. // Pulse with in milliseconds for a latched relay
  331. #ifndef RELAY_LATCHING_PULSE
  332. #define RELAY_LATCHING_PULSE 10
  333. #endif
  334. // Do not save relay state after these many milliseconds
  335. #ifndef RELAY_SAVE_DELAY
  336. #define RELAY_SAVE_DELAY 1000
  337. #endif
  338. #ifndef RELAY_REPORT_STATUS
  339. #define RELAY_REPORT_STATUS 1
  340. #endif
  341. // Configure the MQTT payload for ON, OFF and TOGGLE
  342. #ifndef RELAY_MQTT_OFF
  343. #define RELAY_MQTT_OFF "0"
  344. #endif
  345. #ifndef RELAY_MQTT_ON
  346. #define RELAY_MQTT_ON "1"
  347. #endif
  348. #ifndef RELAY_MQTT_TOGGLE
  349. #define RELAY_MQTT_TOGGLE "2"
  350. #endif
  351. // -----------------------------------------------------------------------------
  352. // WIFI
  353. // -----------------------------------------------------------------------------
  354. #ifndef WIFI_CONNECT_TIMEOUT
  355. #define WIFI_CONNECT_TIMEOUT 60000 // Connecting timeout for WIFI in ms
  356. #endif
  357. #ifndef WIFI_RECONNECT_INTERVAL
  358. #define WIFI_RECONNECT_INTERVAL 180000 // If could not connect to WIFI, retry after this time in ms
  359. #endif
  360. #ifndef WIFI_MAX_NETWORKS
  361. #define WIFI_MAX_NETWORKS 5 // Max number of WIFI connection configurations
  362. #endif
  363. #ifndef WIFI_AP_CAPTIVE
  364. #define WIFI_AP_CAPTIVE 1 // Captive portal enabled when in AP mode
  365. #endif
  366. #ifndef WIFI_FALLBACK_APMODE
  367. #define WIFI_FALLBACK_APMODE 1 // Fallback to AP mode if no STA connection
  368. #endif
  369. #ifndef WIFI_SLEEP_MODE
  370. #define WIFI_SLEEP_MODE WIFI_NONE_SLEEP // WIFI_NONE_SLEEP, WIFI_LIGHT_SLEEP or WIFI_MODEM_SLEEP
  371. #endif
  372. #ifndef WIFI_SCAN_NETWORKS
  373. #define WIFI_SCAN_NETWORKS 1 // Perform a network scan before connecting
  374. #endif
  375. // Optional hardcoded configuration (up to 2 networks)
  376. #ifndef WIFI1_SSID
  377. #define WIFI1_SSID ""
  378. #endif
  379. #ifndef WIFI1_PASS
  380. #define WIFI1_PASS ""
  381. #endif
  382. #ifndef WIFI1_IP
  383. #define WIFI1_IP ""
  384. #endif
  385. #ifndef WIFI1_GW
  386. #define WIFI1_GW ""
  387. #endif
  388. #ifndef WIFI1_MASK
  389. #define WIFI1_MASK ""
  390. #endif
  391. #ifndef WIFI1_DNS
  392. #define WIFI1_DNS ""
  393. #endif
  394. #ifndef WIFI2_SSID
  395. #define WIFI2_SSID ""
  396. #endif
  397. #ifndef WIFI2_PASS
  398. #define WIFI2_PASS ""
  399. #endif
  400. #ifndef WIFI2_IP
  401. #define WIFI2_IP ""
  402. #endif
  403. #ifndef WIFI2_GW
  404. #define WIFI2_GW ""
  405. #endif
  406. #ifndef WIFI2_MASK
  407. #define WIFI2_MASK ""
  408. #endif
  409. #ifndef WIFI2_DNS
  410. #define WIFI2_DNS ""
  411. #endif
  412. #ifndef WIFI3_SSID
  413. #define WIFI3_SSID ""
  414. #endif
  415. #ifndef WIFI3_PASS
  416. #define WIFI3_PASS ""
  417. #endif
  418. #ifndef WIFI3_IP
  419. #define WIFI3_IP ""
  420. #endif
  421. #ifndef WIFI3_GW
  422. #define WIFI3_GW ""
  423. #endif
  424. #ifndef WIFI3_MASK
  425. #define WIFI3_MASK ""
  426. #endif
  427. #ifndef WIFI3_DNS
  428. #define WIFI3_DNS ""
  429. #endif
  430. #ifndef WIFI4_SSID
  431. #define WIFI4_SSID ""
  432. #endif
  433. #ifndef WIFI4_PASS
  434. #define WIFI4_PASS ""
  435. #endif
  436. #ifndef WIFI4_IP
  437. #define WIFI4_IP ""
  438. #endif
  439. #ifndef WIFI4_GW
  440. #define WIFI4_GW ""
  441. #endif
  442. #ifndef WIFI4_MASK
  443. #define WIFI4_MASK ""
  444. #endif
  445. #ifndef WIFI4_DNS
  446. #define WIFI4_DNS ""
  447. #endif
  448. #ifndef WIFI5_SSID
  449. #define WIFI5_SSID ""
  450. #endif
  451. #ifndef WIFI5_PASS
  452. #define WIFI5_PASS ""
  453. #endif
  454. #ifndef WIFI5_IP
  455. #define WIFI5_IP ""
  456. #endif
  457. #ifndef WIFI5_GW
  458. #define WIFI5_GW ""
  459. #endif
  460. #ifndef WIFI5_MASK
  461. #define WIFI5_MASK ""
  462. #endif
  463. #ifndef WIFI5_DNS
  464. #define WIFI5_DNS ""
  465. #endif
  466. #ifndef WIFI_RSSI_1M
  467. #define WIFI_RSSI_1M -30 // Calibrate it with your router reading the RSSI at 1m
  468. #endif
  469. #ifndef WIFI_PROPAGATION_CONST
  470. #define WIFI_PROPAGATION_CONST 4 // This is typically something between 2.7 to 4.3 (free space is 2)
  471. #endif
  472. // ref: https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/kconfig.html#config-lwip-esp-gratuitous-arp
  473. // ref: https://github.com/xoseperez/espurna/pull/1877#issuecomment-525612546
  474. //
  475. // Broadcast gratuitous ARP periodically to update ARP tables on the AP and all devices on the same network.
  476. // Helps to solve compatibility issues when ESP fails to timely reply to ARP requests, causing the device's ARP table entry to expire.
  477. #ifndef WIFI_GRATUITOUS_ARP_SUPPORT
  478. #define WIFI_GRATUITOUS_ARP_SUPPORT 1
  479. #endif
  480. // Interval is randomized on each boot in range from ..._MIN to ..._MAX (ms)
  481. #ifndef WIFI_GRATUITOUS_ARP_INTERVAL_MIN
  482. #define WIFI_GRATUITOUS_ARP_INTERVAL_MIN 15000
  483. #endif
  484. #ifndef WIFI_GRATUITOUS_ARP_INTERVAL_MAX
  485. #define WIFI_GRATUITOUS_ARP_INTERVAL_MAX 30000
  486. #endif
  487. // ref: https://github.com/esp8266/Arduino/issues/6471
  488. // ref: https://github.com/esp8266/Arduino/issues/6366
  489. //
  490. // Issue #6366 turned out to be high tx power causing weird behavior. Lowering tx power achieved stability.
  491. #ifndef WIFI_OUTPUT_POWER_DBM
  492. #define WIFI_OUTPUT_POWER_DBM 20.0f
  493. #endif
  494. // -----------------------------------------------------------------------------
  495. // WEB
  496. // -----------------------------------------------------------------------------
  497. #ifndef WEB_SUPPORT
  498. #define WEB_SUPPORT 1 // Enable web support (http, api, 121.65Kb)
  499. #endif
  500. #ifndef WEB_EMBEDDED
  501. #define WEB_EMBEDDED 1 // Build the firmware with the web interface embedded in
  502. #endif
  503. // Requires ESPAsyncTCP to be built with ASYNC_TCP_SSL_ENABLED=1 and Arduino Core version >= 2.4.0
  504. // XXX: This is not working at the moment!! Pending https://github.com/me-no-dev/ESPAsyncTCP/issues/95
  505. #ifndef WEB_SSL_ENABLED
  506. #define WEB_SSL_ENABLED 0 // Use HTTPS web interface
  507. #endif
  508. #ifndef WEB_USERNAME
  509. #define WEB_USERNAME "admin" // HTTP username
  510. #endif
  511. #ifndef WEB_FORCE_PASS_CHANGE
  512. #define WEB_FORCE_PASS_CHANGE 1 // Force the user to change the password if default one
  513. #endif
  514. #ifndef WEB_PORT
  515. #define WEB_PORT 80 // HTTP port
  516. #endif
  517. // Defining a WEB_REMOTE_DOMAIN will enable Cross-Origin Resource Sharing (CORS)
  518. // so you will be able to login to this device from another domain. This will allow
  519. // you to manage all ESPurna devices in your local network from a unique installation
  520. // of the web UI. This installation could be in a local server (a Raspberry Pi, for instance)
  521. // or in the Internet. Since the WebUI is just one compressed file with HTML, CSS and JS
  522. // there are no special requirements. Any static web server will do (NGinx, Apache, Lighttpd,...).
  523. // The only requirement is that the resource must be available under this domain.
  524. #ifndef WEB_REMOTE_DOMAIN
  525. #define WEB_REMOTE_DOMAIN "http://espurna.io"
  526. #endif
  527. // -----------------------------------------------------------------------------
  528. // WEBSOCKETS
  529. // -----------------------------------------------------------------------------
  530. // This will only be enabled if WEB_SUPPORT is 1 (this is the default value)
  531. #ifndef WS_AUTHENTICATION
  532. #define WS_AUTHENTICATION 1 // WS authentication ON by default (see #507)
  533. #endif
  534. #ifndef WS_BUFFER_SIZE
  535. #define WS_BUFFER_SIZE 5 // Max number of secured websocket connections
  536. #endif
  537. #ifndef WS_TIMEOUT
  538. #define WS_TIMEOUT 1800000 // Timeout for secured websocket
  539. #endif
  540. #ifndef WS_UPDATE_INTERVAL
  541. #define WS_UPDATE_INTERVAL 30000 // Update clients every 30 seconds
  542. #endif
  543. // -----------------------------------------------------------------------------
  544. // API
  545. // -----------------------------------------------------------------------------
  546. #ifndef API_SUPPORT
  547. #define API_SUPPORT 1 // API (REST & RPC) support built in
  548. #endif
  549. // This will only be enabled if WEB_SUPPORT is 1 (this is the default value)
  550. #ifndef API_ENABLED
  551. #define API_ENABLED 0 // Do not enable API by default
  552. #endif
  553. #ifndef API_KEY
  554. #define API_KEY "" // Do not enable API by default. WebUI will automatically generate the key
  555. #endif
  556. #ifndef API_RESTFUL
  557. #define API_RESTFUL 1 // A restful API requires changes to be issued as PUT requests
  558. // Setting this to 0 will allow using GET to change relays, for instance
  559. #endif
  560. #ifndef API_BUFFER_SIZE
  561. #define API_BUFFER_SIZE 64 // Size of the buffer for HTTP GET API responses
  562. #endif
  563. #ifndef API_REAL_TIME_VALUES
  564. #define API_REAL_TIME_VALUES 0 // Show filtered/median values by default (0 => median, 1 => real time)
  565. #endif
  566. // -----------------------------------------------------------------------------
  567. // MDNS / LLMNR / NETBIOS / SSDP
  568. // -----------------------------------------------------------------------------
  569. #ifndef MDNS_SERVER_SUPPORT
  570. #define MDNS_SERVER_SUPPORT 1 // Publish services using mDNS by default (1.48Kb)
  571. #endif
  572. #ifndef MDNS_CLIENT_SUPPORT
  573. #define MDNS_CLIENT_SUPPORT 0 // Resolve mDNS names (3.44Kb)
  574. #endif
  575. #ifndef LLMNR_SUPPORT
  576. #define LLMNR_SUPPORT 0 // Publish device using LLMNR protocol by default (1.95Kb) - requires Core version >= 2.4.0
  577. #endif
  578. #ifndef NETBIOS_SUPPORT
  579. #define NETBIOS_SUPPORT 0 // Publish device using NetBIOS protocol by default (1.26Kb) - requires Core version >= 2.4.0
  580. #endif
  581. #ifndef SSDP_SUPPORT
  582. #define SSDP_SUPPORT 0 // Publish device using SSDP protocol by default (4.59Kb)
  583. // Not compatible with ALEXA_SUPPORT at the moment
  584. #endif
  585. #ifndef SSDP_DEVICE_TYPE
  586. #define SSDP_DEVICE_TYPE "upnp:rootdevice"
  587. //#define SSDP_DEVICE_TYPE "urn:schemas-upnp-org:device:BinaryLight:1"
  588. #endif
  589. // -----------------------------------------------------------------------------
  590. // SPIFFS
  591. // -----------------------------------------------------------------------------
  592. #ifndef SPIFFS_SUPPORT
  593. #define SPIFFS_SUPPORT 0 // Do not add support for SPIFFS by default
  594. #endif
  595. // -----------------------------------------------------------------------------
  596. // SSL Client ** EXPERIMENTAL **
  597. // -----------------------------------------------------------------------------
  598. #ifndef SECURE_CLIENT
  599. #define SECURE_CLIENT SECURE_CLIENT_NONE // What variant of WiFiClient to use
  600. // SECURE_CLIENT_NONE - No secure client support (default)
  601. // SECURE_CLIENT_AXTLS - axTLS client secure support (All Core versions, ONLY TLS 1.1)
  602. // SECURE_CLIENT_BEARSSL - BearSSL client secure support (starting with 2.5.0, TLS 1.2)
  603. //
  604. // axTLS marked for derecation since Arduino Core 2.4.2 and **will** be removed in the future
  605. #endif
  606. // Security check that is performed when the connection is established:
  607. // SECURE_CLIENT_CHECK_CA - Use Trust Anchor / Root Certificate
  608. // Supported only by the SECURE_CLIENT_BEARSSL
  609. // (See respective ..._SECURE_CLIENT_INCLUDE_CA options per-module)
  610. // SECURE_CLIENT_CHECK_FINGERPRINT - Check certificate fingerprint
  611. // SECURE_CLIENT_CHECK_NONE - Allow insecure connections
  612. #ifndef SECURE_CLIENT_CHECK
  613. #if SECURE_CLIENT == SECURE_CLIENT_BEARSSL
  614. #define SECURE_CLIENT_CHECK SECURE_CLIENT_CHECK_CA
  615. #else
  616. #define SECURE_CLIENT_CHECK SECURE_CLIENT_CHECK_FINGERPRINT
  617. #endif
  618. #endif // SECURE_CLIENT_CHECK
  619. // Support Maximum Fragment Length Negotiation TLS extension
  620. // "...negotiate a smaller maximum fragment length due to memory limitations or bandwidth limitations."
  621. // - https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/bearssl-client-secure-class.html#mfln-or-maximum-fragment-length-negotiation-saving-ram
  622. // - https://tools.ietf.org/html/rfc6066#section-4
  623. #ifndef SECURE_CLIENT_MFLN
  624. #define SECURE_CLIENT_MFLN 0 // The only possible values are: 512, 1024, 2048 and 4096
  625. // Set to 0 to disable (default)
  626. #endif
  627. // -----------------------------------------------------------------------------
  628. // OTA
  629. // -----------------------------------------------------------------------------
  630. #ifndef OTA_PORT
  631. #define OTA_PORT 8266 // Port for ArduinoOTA
  632. #endif
  633. #ifndef OTA_MQTT_SUPPORT
  634. #define OTA_MQTT_SUPPORT 0 // Listen for HTTP(s) URLs at '<root topic>/ota'. Depends on OTA_CLIENT
  635. #endif
  636. #ifndef OTA_ARDUINOOTA_SUPPORT
  637. #define OTA_ARDUINOOTA_SUPPORT 1 // Support ArduinoOTA by default (4.2Kb)
  638. // Implicitly depends on ESP8266mDNS library, thus increasing firmware size
  639. #endif
  640. #ifndef OTA_CLIENT
  641. #define OTA_CLIENT OTA_CLIENT_ASYNCTCP // Terminal / MQTT OTA support
  642. // OTA_CLIENT_ASYNCTCP (ESPAsyncTCP library)
  643. // OTA_CLIENT_HTTPUPDATE (Arduino Core library)
  644. #endif
  645. #define OTA_GITHUB_FP "CA:06:F5:6B:25:8B:7A:0D:4F:2B:05:47:09:39:47:86:51:15:19:84"
  646. #ifndef OTA_FINGERPRINT
  647. #define OTA_FINGERPRINT OTA_GITHUB_FP
  648. #endif
  649. #ifndef OTA_SECURE_CLIENT_CHECK
  650. #define OTA_SECURE_CLIENT_CHECK SECURE_CLIENT_CHECK
  651. #endif
  652. #ifndef OTA_SECURE_CLIENT_MFLN
  653. #define OTA_SECURE_CLIENT_MFLN SECURE_CLIENT_MFLN
  654. #endif
  655. #ifndef OTA_SECURE_CLIENT_INCLUDE_CA
  656. #define OTA_SECURE_CLIENT_INCLUDE_CA 0 // Use user-provided CA. Only PROGMEM PEM option is supported.
  657. // TODO: eventually should be replaced with pre-parsed structs, read directly from flash
  658. // (ref: https://github.com/earlephilhower/bearssl-esp8266/pull/14)
  659. //
  660. // When enabled, current implementation includes "static/ota_client_trusted_root_ca.h" with
  661. // const char _ota_client_trusted_root_ca[] PROGMEM = "...PEM data...";
  662. // By default, using DigiCert root in "static/digicert_evroot_pem.h" (for https://github.com)
  663. #endif
  664. // -----------------------------------------------------------------------------
  665. // NOFUSS
  666. // -----------------------------------------------------------------------------
  667. #ifndef NOFUSS_SUPPORT
  668. #define NOFUSS_SUPPORT 0 // Do not enable support for NoFuss by default (12.65Kb)
  669. #endif
  670. #ifndef NOFUSS_ENABLED
  671. #define NOFUSS_ENABLED 0 // Do not perform NoFUSS updates by default
  672. #endif
  673. #ifndef NOFUSS_SERVER
  674. #define NOFUSS_SERVER "" // Default NoFuss Server
  675. #endif
  676. #ifndef NOFUSS_INTERVAL
  677. #define NOFUSS_INTERVAL 3600000 // Check for updates every hour
  678. #endif
  679. // -----------------------------------------------------------------------------
  680. // UART <-> MQTT
  681. // -----------------------------------------------------------------------------
  682. #ifndef UART_MQTT_SUPPORT
  683. #define UART_MQTT_SUPPORT 0 // No support by default
  684. #endif
  685. #ifndef UART_MQTT_USE_SOFT
  686. #define UART_MQTT_USE_SOFT 0 // Use SoftwareSerial
  687. #endif
  688. #ifndef UART_MQTT_HW_PORT
  689. #define UART_MQTT_HW_PORT Serial // Hardware serial port (if UART_MQTT_USE_SOFT == 0)
  690. #endif
  691. #ifndef UART_MQTT_RX_PIN
  692. #define UART_MQTT_RX_PIN 4 // RX PIN (if UART_MQTT_USE_SOFT == 1)
  693. #endif
  694. #ifndef UART_MQTT_TX_PIN
  695. #define UART_MQTT_TX_PIN 5 // TX PIN (if UART_MQTT_USE_SOFT == 1)
  696. #endif
  697. #ifndef UART_MQTT_BAUDRATE
  698. #define UART_MQTT_BAUDRATE 115200 // Serial speed
  699. #endif
  700. #ifndef UART_MQTT_TERMINATION
  701. #define UART_MQTT_TERMINATION '\n' // Termination character
  702. #endif
  703. #define UART_MQTT_BUFFER_SIZE 100 // UART buffer size
  704. // -----------------------------------------------------------------------------
  705. // MQTT
  706. // -----------------------------------------------------------------------------
  707. #ifndef MQTT_SUPPORT
  708. #define MQTT_SUPPORT 1 // MQTT support (22.38Kb async, 12.48Kb sync)
  709. #endif
  710. #ifndef MQTT_LIBRARY
  711. #define MQTT_LIBRARY MQTT_LIBRARY_ASYNCMQTTCLIENT // MQTT_LIBRARY_ASYNCMQTTCLIENT (default, https://github.com/marvinroger/async-mqtt-client)
  712. // MQTT_LIBRARY_PUBSUBCLIENT (https://github.com/knolleary/pubsubclient)
  713. // MQTT_LIBRARY_ARDUINOMQTT (https://github.com/256dpi/arduino-mqtt)
  714. #endif
  715. // -----------------------------------------------------------------------------
  716. // MQTT OVER SSL
  717. // -----------------------------------------------------------------------------
  718. //
  719. // Requires SECURE_CLIENT set to SECURE_CLIENT_AXTLS or SECURE_CLIENT_BEARSSL
  720. // It is recommended to use MQTT_LIBRARY_ARDUINOMQTT or MQTT_LIBRARY_PUBSUBCLIENT
  721. // It is recommended to use SECURE_CLIENT_BEARSSL
  722. // It is recommended to use ESP8266 Arduino Core >= 2.5.2 with SECURE_CLIENT_BEARSSL
  723. //
  724. // Current version of MQTT_LIBRARY_ASYNCMQTTCLIENT only supports SECURE_CLIENT_AXTLS
  725. //
  726. // It is recommended to use WEB_SUPPORT=0 with either SECURE_CLIENT option, as there are miscellaneous problems when using them simultaneously
  727. // (although, things might've improved, and I'd encourage to check whether this is true or not)
  728. //
  729. // When using MQTT_LIBRARY_PUBSUBCLIENT or MQTT_LIBRARY_ARDUINOMQTT, you will have to disable every module that uses ESPAsyncTCP:
  730. // ALEXA_SUPPORT=0, INFLUXDB_SUPPORT=0, TELNET_SUPPORT=0, THINGSPEAK_SUPPORT=0, DEBUG_TELNET_SUPPORT=0 and WEB_SUPPORT=0
  731. // Or, use "sync" versions instead (note that not every module has this option):
  732. // THINGSPEAK_USE_ASYNC=0, TELNET_SERVER=TELNET_SERVER_WIFISERVER
  733. //
  734. // See SECURE_CLIENT_CHECK for all possible connection verification options.
  735. //
  736. // The simpliest way to verify SSL connection is to use fingerprinting.
  737. // For example, to get Google's MQTT server certificate fingerprint, run the following command:
  738. // $ echo -n | openssl s_client -connect mqtt.googleapis.com:8883 2>&1 | openssl x509 -noout -fingerprint -sha1 | cut -d\= -f2
  739. // Note that fingerprint will change when certificate changes e.g. LetsEncrypt renewals or when the CSR updates
  740. #ifndef MQTT_SSL_ENABLED
  741. #define MQTT_SSL_ENABLED 0 // By default MQTT over SSL will not be enabled
  742. #endif
  743. #ifndef MQTT_SSL_FINGERPRINT
  744. #define MQTT_SSL_FINGERPRINT "" // SSL fingerprint of the server
  745. #endif
  746. #ifndef MQTT_SECURE_CLIENT_CHECK
  747. #define MQTT_SECURE_CLIENT_CHECK SECURE_CLIENT_CHECK // Use global verification setting by default
  748. #endif
  749. #ifndef MQTT_SECURE_CLIENT_MFLN
  750. #define MQTT_SECURE_CLIENT_MFLN SECURE_CLIENT_MFLN // Use global MFLN setting by default
  751. #endif
  752. #ifndef MQTT_SECURE_CLIENT_INCLUDE_CA
  753. #define MQTT_SECURE_CLIENT_INCLUDE_CA 0 // Use user-provided CA. Only PROGMEM PEM option is supported.
  754. // When enabled, current implementation includes "static/mqtt_client_trusted_root_ca.h" with
  755. // const char _mqtt_client_trusted_root_ca[] PROGMEM = "...PEM data...";
  756. // By default, using LetsEncrypt X3 root in "static/letsencrypt_isrgroot_pem.h"
  757. #endif
  758. #ifndef MQTT_ENABLED
  759. #define MQTT_ENABLED 0 // Do not enable MQTT connection by default
  760. #endif
  761. #ifndef MQTT_AUTOCONNECT
  762. #define MQTT_AUTOCONNECT 1 // If enabled and MDNS_SERVER_SUPPORT=1 will perform an autodiscover and
  763. // autoconnect to the first MQTT broker found if none defined
  764. #endif
  765. #ifndef MQTT_SERVER
  766. #define MQTT_SERVER "" // Default MQTT broker address
  767. #endif
  768. #ifndef MQTT_USER
  769. #define MQTT_USER "" // Default MQTT broker usename
  770. #endif
  771. #ifndef MQTT_PASS
  772. #define MQTT_PASS "" // Default MQTT broker password
  773. #endif
  774. #ifndef MQTT_PORT
  775. #define MQTT_PORT 1883 // MQTT broker port
  776. #endif
  777. #ifndef MQTT_TOPIC
  778. #define MQTT_TOPIC "{hostname}" // Default MQTT base topic
  779. #endif
  780. #ifndef MQTT_RETAIN
  781. #define MQTT_RETAIN true // MQTT retain flag
  782. #endif
  783. #ifndef MQTT_QOS
  784. #define MQTT_QOS 0 // MQTT QoS value for all messages
  785. #endif
  786. #ifndef MQTT_KEEPALIVE
  787. #define MQTT_KEEPALIVE 300 // MQTT keepalive value
  788. #endif
  789. #ifndef MQTT_RECONNECT_DELAY_MIN
  790. #define MQTT_RECONNECT_DELAY_MIN 5000 // Try to reconnect in 5 seconds upon disconnection
  791. #endif
  792. #ifndef MQTT_RECONNECT_DELAY_STEP
  793. #define MQTT_RECONNECT_DELAY_STEP 5000 // Increase the reconnect delay in 5 seconds after each failed attempt
  794. #endif
  795. #ifndef MQTT_RECONNECT_DELAY_MAX
  796. #define MQTT_RECONNECT_DELAY_MAX 120000 // Set reconnect time to 2 minutes at most
  797. #endif
  798. #ifndef MQTT_SKIP_RETAINED
  799. #define MQTT_SKIP_RETAINED 1 // Skip retained messages on connection
  800. #endif
  801. #ifndef MQTT_SKIP_TIME
  802. #define MQTT_SKIP_TIME 1000 // Skip messages for 1 second anter connection
  803. #endif
  804. #if THERMOSTAT_SUPPORT == 1
  805. #ifndef MQTT_USE_JSON
  806. #define MQTT_USE_JSON 1 // Group messages in a JSON body
  807. #endif
  808. #else
  809. #ifndef MQTT_USE_JSON
  810. #define MQTT_USE_JSON 0 // Don't group messages in a JSON body (default)
  811. #endif
  812. #endif
  813. #ifndef MQTT_USE_JSON_DELAY
  814. #define MQTT_USE_JSON_DELAY 100 // Wait this many ms before grouping messages
  815. #endif
  816. #ifndef MQTT_QUEUE_MAX_SIZE
  817. #define MQTT_QUEUE_MAX_SIZE 20 // Size of the MQTT queue when MQTT_USE_JSON is enabled
  818. #endif
  819. // These are the properties that will be sent when useJson is true
  820. #ifndef MQTT_ENQUEUE_IP
  821. #define MQTT_ENQUEUE_IP 1
  822. #endif
  823. #ifndef MQTT_ENQUEUE_MAC
  824. #define MQTT_ENQUEUE_MAC 1
  825. #endif
  826. #ifndef MQTT_ENQUEUE_HOSTNAME
  827. #define MQTT_ENQUEUE_HOSTNAME 1
  828. #endif
  829. #ifndef MQTT_ENQUEUE_DATETIME
  830. #define MQTT_ENQUEUE_DATETIME 1
  831. #endif
  832. #ifndef MQTT_ENQUEUE_MESSAGE_ID
  833. #define MQTT_ENQUEUE_MESSAGE_ID 1
  834. #endif
  835. // These particles will be concatenated to the MQTT_TOPIC base to form the actual topic
  836. #define MQTT_TOPIC_JSON "data"
  837. #define MQTT_TOPIC_ACTION "action"
  838. #define MQTT_TOPIC_RELAY "relay"
  839. #define MQTT_TOPIC_LED "led"
  840. #define MQTT_TOPIC_BUTTON "button"
  841. #define MQTT_TOPIC_IP "ip"
  842. #define MQTT_TOPIC_SSID "ssid"
  843. #define MQTT_TOPIC_BSSID "bssid"
  844. #define MQTT_TOPIC_VERSION "version"
  845. #define MQTT_TOPIC_UPTIME "uptime"
  846. #define MQTT_TOPIC_DATETIME "datetime"
  847. #define MQTT_TOPIC_TIMESTAMP "timestamp"
  848. #define MQTT_TOPIC_FREEHEAP "freeheap"
  849. #define MQTT_TOPIC_VCC "vcc"
  850. #ifndef MQTT_TOPIC_STATUS
  851. #define MQTT_TOPIC_STATUS "status"
  852. #endif
  853. #define MQTT_TOPIC_MAC "mac"
  854. #define MQTT_TOPIC_RSSI "rssi"
  855. #define MQTT_TOPIC_MESSAGE_ID "id"
  856. #define MQTT_TOPIC_APP "app"
  857. #define MQTT_TOPIC_INTERVAL "interval"
  858. #define MQTT_TOPIC_HOSTNAME "host"
  859. #define MQTT_TOPIC_DESCRIPTION "desc"
  860. #define MQTT_TOPIC_TIME "time"
  861. #define MQTT_TOPIC_RFOUT "rfout"
  862. #define MQTT_TOPIC_RFIN "rfin"
  863. #define MQTT_TOPIC_RFLEARN "rflearn"
  864. #define MQTT_TOPIC_RFRAW "rfraw"
  865. #define MQTT_TOPIC_UARTIN "uartin"
  866. #define MQTT_TOPIC_UARTOUT "uartout"
  867. #define MQTT_TOPIC_LOADAVG "loadavg"
  868. #define MQTT_TOPIC_BOARD "board"
  869. #define MQTT_TOPIC_PULSE "pulse"
  870. #define MQTT_TOPIC_SPEED "speed"
  871. #define MQTT_TOPIC_IRIN "irin"
  872. #define MQTT_TOPIC_IROUT "irout"
  873. #define MQTT_TOPIC_OTA "ota"
  874. #define MQTT_TOPIC_TELNET_REVERSE "telnet_reverse"
  875. // Light module
  876. #define MQTT_TOPIC_CHANNEL "channel"
  877. #define MQTT_TOPIC_COLOR_RGB "rgb"
  878. #define MQTT_TOPIC_COLOR_HSV "hsv"
  879. #define MQTT_TOPIC_ANIM_MODE "anim_mode"
  880. #define MQTT_TOPIC_ANIM_SPEED "anim_speed"
  881. #define MQTT_TOPIC_BRIGHTNESS "brightness"
  882. #define MQTT_TOPIC_MIRED "mired"
  883. #define MQTT_TOPIC_KELVIN "kelvin"
  884. #define MQTT_TOPIC_TRANSITION "transition"
  885. // Thermostat module
  886. #define MQTT_TOPIC_HOLD_TEMP "hold_temp"
  887. #define MQTT_TOPIC_HOLD_TEMP_MIN "min"
  888. #define MQTT_TOPIC_HOLD_TEMP_MAX "max"
  889. #define MQTT_TOPIC_REMOTE_TEMP "remote_temp"
  890. #define MQTT_TOPIC_ASK_TEMP_RANGE "ask_temp_range"
  891. #define MQTT_TOPIC_NOTIFY_TEMP_RANGE_MIN "notify_temp_range_min"
  892. #define MQTT_TOPIC_NOTIFY_TEMP_RANGE_MAX "notify_temp_range_max"
  893. #ifndef MQTT_STATUS_ONLINE
  894. #define MQTT_STATUS_ONLINE "1" // Value for the device ON message
  895. #endif
  896. #ifndef MQTT_STATUS_OFFLINE
  897. #define MQTT_STATUS_OFFLINE "0" // Value for the device OFF message (will)
  898. #endif
  899. #define MQTT_ACTION_RESET "reboot" // RESET MQTT topic particle
  900. // Custom get and set postfixes
  901. // Use something like "/status" or "/set", with leading slash
  902. // Since 1.9.0 the default value is "" for getter and "/set" for setter
  903. #ifndef MQTT_GETTER
  904. #define MQTT_GETTER ""
  905. #endif
  906. #ifndef MQTT_SETTER
  907. #define MQTT_SETTER "/set"
  908. #endif
  909. // -----------------------------------------------------------------------------
  910. // BROKER
  911. // -----------------------------------------------------------------------------
  912. #ifndef BROKER_SUPPORT
  913. #define BROKER_SUPPORT 1 // The broker is a poor-man's pubsub manager
  914. #endif
  915. // -----------------------------------------------------------------------------
  916. // SETTINGS
  917. // -----------------------------------------------------------------------------
  918. #ifndef SETTINGS_AUTOSAVE
  919. #define SETTINGS_AUTOSAVE 1 // Autosave settings or force manual commit
  920. #endif
  921. #define SETTINGS_MAX_LIST_COUNT 16 // Maximum index for settings lists
  922. // -----------------------------------------------------------------------------
  923. // LIGHT
  924. // -----------------------------------------------------------------------------
  925. // LIGHT_PROVIDER_DIMMER can have from 1 to 5 different channels.
  926. // They have to be defined for each device in the hardware.h file.
  927. // If 3 or more channels first 3 will be considered RGB.
  928. // Usual configurations are:
  929. // 1 channels => W
  930. // 2 channels => WW
  931. // 3 channels => RGB
  932. // 4 channels => RGBW
  933. // 5 channels => RGBWW
  934. #ifndef LIGHT_SAVE_ENABLED
  935. #define LIGHT_SAVE_ENABLED 1 // Light channel values saved by default after each change
  936. #endif
  937. #ifndef LIGHT_COMMS_DELAY
  938. #define LIGHT_COMMS_DELAY 100 // Delay communication after light update (in ms)
  939. #endif
  940. #ifndef LIGHT_SAVE_DELAY
  941. #define LIGHT_SAVE_DELAY 5 // Persist color after 5 seconds to avoid wearing out
  942. #endif
  943. #ifndef LIGHT_MIN_PWM
  944. #define LIGHT_MIN_PWM 0
  945. #endif
  946. #ifndef LIGHT_MAX_PWM
  947. #if LIGHT_PROVIDER == LIGHT_PROVIDER_MY92XX
  948. #define LIGHT_MAX_PWM 255
  949. #elif LIGHT_PROVIDER == LIGHT_PROVIDER_DIMMER
  950. #define LIGHT_MAX_PWM 10000 // 10000 * 200ns => 2 kHz
  951. #else
  952. #define LIGHT_MAX_PWM 0
  953. #endif
  954. #endif // LIGHT_MAX_PWM
  955. #ifndef LIGHT_LIMIT_PWM
  956. #define LIGHT_LIMIT_PWM LIGHT_MAX_PWM // Limit PWM to this value (prevent 100% power)
  957. #endif
  958. #ifndef LIGHT_MIN_VALUE
  959. #define LIGHT_MIN_VALUE 0 // Minimum light value
  960. #endif
  961. #ifndef LIGHT_MAX_VALUE
  962. #define LIGHT_MAX_VALUE 255 // Maximum light value
  963. #endif
  964. #ifndef LIGHT_MIN_BRIGHTNESS
  965. #define LIGHT_MIN_BRIGHTNESS 0 // Minimum brightness value
  966. #endif
  967. #ifndef LIGHT_MAX_BRIGHTNESS
  968. #define LIGHT_MAX_BRIGHTNESS 255 // Maximum brightness value
  969. #endif
  970. // Default mireds & kelvin to the Philips Hue limits
  971. // https://developers.meethue.com/documentation/core-concepts
  972. //
  973. // Home Assistant also uses these, see Light::min_mireds, Light::max_mireds
  974. // https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/light/__init__.py
  975. // Used when LIGHT_USE_WHITE AND LIGHT_USE_CCT is 1 - (1000000/Kelvin = MiReds)
  976. // Warning! Don't change this yet, NOT FULLY IMPLEMENTED!
  977. #ifndef LIGHT_COLDWHITE_MIRED
  978. #define LIGHT_COLDWHITE_MIRED 153 // Coldwhite Strip, Value must be __BELOW__ W2!! (Default: 6535 Kelvin/153 MiRed)
  979. #endif
  980. #ifndef LIGHT_WARMWHITE_MIRED
  981. #define LIGHT_WARMWHITE_MIRED 500 // Warmwhite Strip, Value must be __ABOVE__ W1!! (Default: 2000 Kelvin/500 MiRed)
  982. #endif
  983. #ifndef LIGHT_STEP
  984. #define LIGHT_STEP 32 // Step size
  985. #endif
  986. #ifndef LIGHT_USE_COLOR
  987. #define LIGHT_USE_COLOR 1 // Use 3 first channels as RGB
  988. #endif
  989. #ifndef LIGHT_USE_WHITE
  990. #define LIGHT_USE_WHITE 0 // Use the 4th channel as (Warm-)White LEDs
  991. #endif
  992. #ifndef LIGHT_USE_CCT
  993. #define LIGHT_USE_CCT 0 // Use the 5th channel as Coldwhite LEDs, LIGHT_USE_WHITE must be 1.
  994. #endif
  995. #ifndef LIGHT_USE_GAMMA
  996. #define LIGHT_USE_GAMMA 0 // Use gamma correction for color channels
  997. #endif
  998. #ifndef LIGHT_USE_CSS
  999. #define LIGHT_USE_CSS 1 // Use CSS style to report colors (1=> "#FF0000", 0=> "255,0,0")
  1000. #endif
  1001. #ifndef LIGHT_USE_RGB
  1002. #define LIGHT_USE_RGB 0 // Use RGB color selector (1=> RGB, 0=> HSV)
  1003. #endif
  1004. #ifndef LIGHT_WHITE_FACTOR
  1005. #define LIGHT_WHITE_FACTOR 1 // When using LIGHT_USE_WHITE with uneven brightness LEDs,
  1006. // this factor is used to scale the white channel to match brightness
  1007. #endif
  1008. #ifndef LIGHT_USE_TRANSITIONS
  1009. #define LIGHT_USE_TRANSITIONS 1 // Transitions between colors
  1010. #endif
  1011. #ifndef LIGHT_TRANSITION_STEP
  1012. #define LIGHT_TRANSITION_STEP 10 // Time in millis between each transtion step
  1013. #endif
  1014. #ifndef LIGHT_TRANSITION_TIME
  1015. #define LIGHT_TRANSITION_TIME 500 // Time in millis from color to color
  1016. #endif
  1017. // -----------------------------------------------------------------------------
  1018. // DOMOTICZ
  1019. // -----------------------------------------------------------------------------
  1020. #ifndef DOMOTICZ_SUPPORT
  1021. #define DOMOTICZ_SUPPORT MQTT_SUPPORT // Build with domoticz (if MQTT) support (1.72Kb)
  1022. #endif
  1023. #ifndef DOMOTICZ_ENABLED
  1024. #define DOMOTICZ_ENABLED 0 // Disable domoticz by default
  1025. #endif
  1026. #ifndef DOMOTICZ_IN_TOPIC
  1027. #define DOMOTICZ_IN_TOPIC "domoticz/in" // Default subscription topic
  1028. #endif
  1029. #ifndef DOMOTICZ_OUT_TOPIC
  1030. #define DOMOTICZ_OUT_TOPIC "domoticz/out" // Default publication topic
  1031. #endif
  1032. // -----------------------------------------------------------------------------
  1033. // HOME ASSISTANT
  1034. // -----------------------------------------------------------------------------
  1035. #ifndef HOMEASSISTANT_SUPPORT
  1036. #define HOMEASSISTANT_SUPPORT MQTT_SUPPORT // Build with home assistant support (if MQTT, 1.64Kb)
  1037. #endif
  1038. #ifndef HOMEASSISTANT_ENABLED
  1039. #define HOMEASSISTANT_ENABLED 0 // Integration not enabled by default
  1040. #endif
  1041. #ifndef HOMEASSISTANT_PREFIX
  1042. #define HOMEASSISTANT_PREFIX "homeassistant" // Default MQTT prefix
  1043. #endif
  1044. // -----------------------------------------------------------------------------
  1045. // INFLUXDB
  1046. // -----------------------------------------------------------------------------
  1047. #ifndef INFLUXDB_SUPPORT
  1048. #define INFLUXDB_SUPPORT 0 // Disable InfluxDB support by default (4.38Kb)
  1049. #endif
  1050. #ifndef INFLUXDB_ENABLED
  1051. #define INFLUXDB_ENABLED 0 // InfluxDB disabled by default
  1052. #endif
  1053. #ifndef INFLUXDB_HOST
  1054. #define INFLUXDB_HOST "" // Default server
  1055. #endif
  1056. #ifndef INFLUXDB_PORT
  1057. #define INFLUXDB_PORT 8086 // Default InfluxDB port
  1058. #endif
  1059. #ifndef INFLUXDB_DATABASE
  1060. #define INFLUXDB_DATABASE "" // Default database
  1061. #endif
  1062. #ifndef INFLUXDB_USERNAME
  1063. #define INFLUXDB_USERNAME "" // Default username
  1064. #endif
  1065. #ifndef INFLUXDB_PASSWORD
  1066. #define INFLUXDB_PASSWORD "" // Default password
  1067. #endif
  1068. // -----------------------------------------------------------------------------
  1069. // THINGSPEAK
  1070. // -----------------------------------------------------------------------------
  1071. #ifndef THINGSPEAK_SUPPORT
  1072. #define THINGSPEAK_SUPPORT 1 // Enable Thingspeak support by default (2.56Kb)
  1073. #endif
  1074. #ifndef THINGSPEAK_ENABLED
  1075. #define THINGSPEAK_ENABLED 0 // Thingspeak disabled by default
  1076. #endif
  1077. #ifndef THINGSPEAK_APIKEY
  1078. #define THINGSPEAK_APIKEY "" // Default API KEY
  1079. #endif
  1080. #ifndef THINGSPEAK_CLEAR_CACHE
  1081. #define THINGSPEAK_CLEAR_CACHE 1 // Clear cache after sending values
  1082. // Not clearing it will result in latest values for each field being sent every time
  1083. #endif
  1084. #define THINGSPEAK_USE_ASYNC 1 // Use AsyncClient instead of WiFiClientSecure
  1085. // THINGSPEAK OVER SSL
  1086. // Using THINGSPEAK over SSL works well but generates problems with the web interface,
  1087. // so you should compile it with WEB_SUPPORT to 0.
  1088. // When THINGSPEAK_USE_ASYNC is 1, requires EspAsyncTCP to be built with ASYNC_TCP_SSL_ENABLED=1 and ESP8266 Arduino Core >= 2.4.0.
  1089. #define THINGSPEAK_USE_SSL 0 // Use secure connection
  1090. #define THINGSPEAK_FINGERPRINT "78 60 18 44 81 35 BF DF 77 84 D4 0A 22 0D 9B 4E 6C DC 57 2C"
  1091. #define THINGSPEAK_HOST "api.thingspeak.com"
  1092. #if THINGSPEAK_USE_SSL
  1093. #define THINGSPEAK_PORT 443
  1094. #else
  1095. #define THINGSPEAK_PORT 80
  1096. #endif
  1097. #define THINGSPEAK_URL "/update"
  1098. #define THINGSPEAK_MIN_INTERVAL 15000 // Minimum interval between POSTs (in millis)
  1099. #define THINGSPEAK_FIELDS 8 // Number of fields
  1100. #ifndef THINGSPEAK_TRIES
  1101. #define THINGSPEAK_TRIES 3 // Number of tries when sending data (minimum 1)
  1102. #endif
  1103. // -----------------------------------------------------------------------------
  1104. // SCHEDULER
  1105. // -----------------------------------------------------------------------------
  1106. #ifndef SCHEDULER_SUPPORT
  1107. #define SCHEDULER_SUPPORT 1 // Enable scheduler (2.45Kb)
  1108. #endif
  1109. #ifndef SCHEDULER_MAX_SCHEDULES
  1110. #define SCHEDULER_MAX_SCHEDULES 10 // Max schedules alowed
  1111. #endif
  1112. #ifndef SCHEDULER_RESTORE_LAST_SCHEDULE
  1113. #define SCHEDULER_RESTORE_LAST_SCHEDULE 0 // Restore the last schedule state on the device boot
  1114. #endif
  1115. #ifndef SCHEDULER_WEEKDAYS
  1116. #define SCHEDULER_WEEKDAYS "1,2,3,4,5,6,7" // (Default - Run the schedules every day)
  1117. #endif
  1118. // -----------------------------------------------------------------------------
  1119. // RPN RULES
  1120. // -----------------------------------------------------------------------------
  1121. #ifndef RPN_RULES_SUPPORT
  1122. #define RPN_RULES_SUPPORT 0 // Enable RPN Rules (8.6Kb)
  1123. #endif
  1124. #ifndef RPN_DELAY
  1125. #define RPN_DELAY 100 // Execute rules after 100ms without messages
  1126. #endif
  1127. #ifndef RPN_STICKY
  1128. #define RPN_STICKY 1 // Keeps variable after rule execution
  1129. #endif
  1130. // -----------------------------------------------------------------------------
  1131. // NTP
  1132. // -----------------------------------------------------------------------------
  1133. #ifndef NTP_SUPPORT
  1134. #define NTP_SUPPORT 1 // Build with NTP support by default (6.78Kb)
  1135. #endif
  1136. #ifndef NTP_SERVER
  1137. #define NTP_SERVER "pool.ntp.org" // Default NTP server
  1138. #endif
  1139. #ifndef NTP_TIMEOUT
  1140. #define NTP_TIMEOUT 1000 // Set NTP request timeout to 2 seconds (issue #452)
  1141. #endif
  1142. #ifndef NTP_TIME_OFFSET
  1143. #define NTP_TIME_OFFSET 60 // Default timezone offset (GMT+1)
  1144. #endif
  1145. #ifndef NTP_DAY_LIGHT
  1146. #define NTP_DAY_LIGHT 1 // Enable daylight time saving by default
  1147. #endif
  1148. #ifndef NTP_SYNC_INTERVAL
  1149. #define NTP_SYNC_INTERVAL 60 // NTP initial check every minute
  1150. #endif
  1151. #ifndef NTP_UPDATE_INTERVAL
  1152. #define NTP_UPDATE_INTERVAL 1800 // NTP check every 30 minutes
  1153. #endif
  1154. #ifndef NTP_START_DELAY
  1155. #define NTP_START_DELAY 1000 // Delay NTP start 1 second
  1156. #endif
  1157. #ifndef NTP_DST_REGION
  1158. #define NTP_DST_REGION 0 // 0 for Europe, 1 for USA (defined in NtpClientLib)
  1159. #endif
  1160. #ifndef NTP_WAIT_FOR_SYNC
  1161. #define NTP_WAIT_FOR_SYNC 1 // Do not report any datetime until NTP sync'ed
  1162. #endif
  1163. // -----------------------------------------------------------------------------
  1164. // ALEXA
  1165. // -----------------------------------------------------------------------------
  1166. // This setting defines whether Alexa support should be built into the firmware
  1167. #ifndef ALEXA_SUPPORT
  1168. #define ALEXA_SUPPORT 1 // Enable Alexa support by default (10.84Kb)
  1169. #endif
  1170. // This is default value for the alexaEnabled setting that defines whether
  1171. // this device should be discoberable and respond to Alexa commands.
  1172. // Both ALEXA_SUPPORT and alexaEnabled should be 1 for Alexa support to work.
  1173. #ifndef ALEXA_ENABLED
  1174. #define ALEXA_ENABLED 1
  1175. #endif
  1176. #ifndef ALEXA_HOSTNAME
  1177. #define ALEXA_HOSTNAME ""
  1178. #endif
  1179. // -----------------------------------------------------------------------------
  1180. // MQTT RF BRIDGE
  1181. // -----------------------------------------------------------------------------
  1182. #ifndef RF_SUPPORT
  1183. #define RF_SUPPORT 0
  1184. #endif
  1185. #ifndef RF_DEBOUNCE
  1186. #define RF_DEBOUNCE 500
  1187. #endif
  1188. #ifndef RF_LEARN_TIMEOUT
  1189. #define RF_LEARN_TIMEOUT 60000
  1190. #endif
  1191. #ifndef RF_SEND_TIMES
  1192. #define RF_SEND_TIMES 4 // How many times to send the message
  1193. #endif
  1194. #ifndef RF_SEND_DELAY
  1195. #define RF_SEND_DELAY 500 // Interval between sendings in ms
  1196. #endif
  1197. #ifndef RF_RECEIVE_DELAY
  1198. #define RF_RECEIVE_DELAY 500 // Interval between recieving in ms (avoid debouncing)
  1199. #endif
  1200. // Enable RCSwitch support
  1201. // Originally implemented for SONOFF BASIC
  1202. // https://tinkerman.cat/adding-rf-to-a-non-rf-itead-sonoff/
  1203. // Also possible to use with SONOFF RF BRIDGE, thanks to @wildwiz
  1204. // https://github.com/xoseperez/espurna/wiki/Hardware-Itead-Sonoff-RF-Bridge---Direct-Hack
  1205. #ifndef RFB_DIRECT
  1206. #define RFB_DIRECT 0
  1207. #endif
  1208. #ifndef RFB_RX_PIN
  1209. #define RFB_RX_PIN GPIO_NONE
  1210. #endif
  1211. #ifndef RFB_TX_PIN
  1212. #define RFB_TX_PIN GPIO_NONE
  1213. #endif
  1214. // -----------------------------------------------------------------------------
  1215. // IR Bridge
  1216. // -----------------------------------------------------------------------------
  1217. #ifndef IR_SUPPORT
  1218. #define IR_SUPPORT 0 // Do not build with IR support by default (10.25Kb)
  1219. #endif
  1220. //#define IR_RX_PIN 5 // GPIO the receiver is connected to
  1221. //#define IR_TX_PIN 4 // GPIO the transmitter is connected to
  1222. #ifndef IR_USE_RAW
  1223. #define IR_USE_RAW 0 // Use raw codes
  1224. #endif
  1225. #ifndef IR_BUFFER_SIZE
  1226. #define IR_BUFFER_SIZE 1024
  1227. #endif
  1228. #ifndef IR_TIMEOUT
  1229. #define IR_TIMEOUT 15U
  1230. #endif
  1231. #ifndef IR_REPEAT
  1232. #define IR_REPEAT 1
  1233. #endif
  1234. #ifndef IR_DELAY
  1235. #define IR_DELAY 100
  1236. #endif
  1237. #ifndef IR_DEBOUNCE
  1238. #define IR_DEBOUNCE 500 // IR debounce time in milliseconds
  1239. #endif
  1240. #ifndef IR_BUTTON_SET
  1241. #define IR_BUTTON_SET 0 // IR button set to use (see below)
  1242. #endif
  1243. // -----------------------------------------------------------------------------
  1244. // Remote Buttons SET 1 (for the original Remote shipped with the controller)
  1245. #if IR_BUTTON_SET == 1
  1246. /*
  1247. +------+------+------+------+
  1248. | UP | Down | OFF | ON |
  1249. +------+------+------+------+
  1250. | R | G | B | W |
  1251. +------+------+------+------+
  1252. | 1 | 2 | 3 |FLASH |
  1253. +------+------+------+------+
  1254. | 4 | 5 | 6 |STROBE|
  1255. +------+------+------+------+
  1256. | 7 | 8 | 9 | FADE |
  1257. +------+------+------+------+
  1258. | 10 | 11 | 12 |SMOOTH|
  1259. +------+------+------+------+
  1260. */
  1261. #define IR_BUTTON_COUNT 24
  1262. const uint32_t IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {
  1263. { 0xFF906F, IR_BUTTON_MODE_BRIGHTER, 1 },
  1264. { 0xFFB847, IR_BUTTON_MODE_BRIGHTER, 0 },
  1265. { 0xFFF807, IR_BUTTON_MODE_STATE, 0 },
  1266. { 0xFFB04F, IR_BUTTON_MODE_STATE, 1 },
  1267. { 0xFF9867, IR_BUTTON_MODE_RGB, 0xFF0000 },
  1268. { 0xFFD827, IR_BUTTON_MODE_RGB, 0x00FF00 },
  1269. { 0xFF8877, IR_BUTTON_MODE_RGB, 0x0000FF },
  1270. { 0xFFA857, IR_BUTTON_MODE_RGB, 0xFFFFFF },
  1271. { 0xFFE817, IR_BUTTON_MODE_RGB, 0xD13A01 },
  1272. { 0xFF48B7, IR_BUTTON_MODE_RGB, 0x00E644 },
  1273. { 0xFF6897, IR_BUTTON_MODE_RGB, 0x0040A7 },
  1274. { 0xFFB24D, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FLASH },
  1275. { 0xFF02FD, IR_BUTTON_MODE_RGB, 0xE96F2A },
  1276. { 0xFF32CD, IR_BUTTON_MODE_RGB, 0x00BEBF },
  1277. { 0xFF20DF, IR_BUTTON_MODE_RGB, 0x56406F },
  1278. { 0xFF00FF, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_STROBE },
  1279. { 0xFF50AF, IR_BUTTON_MODE_RGB, 0xEE9819 },
  1280. { 0xFF7887, IR_BUTTON_MODE_RGB, 0x00799A },
  1281. { 0xFF708F, IR_BUTTON_MODE_RGB, 0x944E80 },
  1282. { 0xFF58A7, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FADE },
  1283. { 0xFF38C7, IR_BUTTON_MODE_RGB, 0xFFFF00 },
  1284. { 0xFF28D7, IR_BUTTON_MODE_RGB, 0x0060A1 },
  1285. { 0xFFF00F, IR_BUTTON_MODE_RGB, 0xEF45AD },
  1286. { 0xFF30CF, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_SMOOTH }
  1287. };
  1288. #endif
  1289. //Remote Buttons SET 2 (another identical IR Remote shipped with another controller)
  1290. #if IR_BUTTON_SET == 2
  1291. /*
  1292. +------+------+------+------+
  1293. | UP | Down | OFF | ON |
  1294. +------+------+------+------+
  1295. | R | G | B | W |
  1296. +------+------+------+------+
  1297. | 1 | 2 | 3 |FLASH |
  1298. +------+------+------+------+
  1299. | 4 | 5 | 6 |STROBE|
  1300. +------+------+------+------+
  1301. | 7 | 8 | 9 | FADE |
  1302. +------+------+------+------+
  1303. | 10 | 11 | 12 |SMOOTH|
  1304. +------+------+------+------+
  1305. */
  1306. #define IR_BUTTON_COUNT 24
  1307. const unsigned long IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {
  1308. { 0xFF00FF, IR_BUTTON_MODE_BRIGHTER, 1 },
  1309. { 0xFF807F, IR_BUTTON_MODE_BRIGHTER, 0 },
  1310. { 0xFF40BF, IR_BUTTON_MODE_STATE, 0 },
  1311. { 0xFFC03F, IR_BUTTON_MODE_STATE, 1 },
  1312. { 0xFF20DF, IR_BUTTON_MODE_RGB, 0xFF0000 },
  1313. { 0xFFA05F, IR_BUTTON_MODE_RGB, 0x00FF00 },
  1314. { 0xFF609F, IR_BUTTON_MODE_RGB, 0x0000FF },
  1315. { 0xFFE01F, IR_BUTTON_MODE_RGB, 0xFFFFFF },
  1316. { 0xFF10EF, IR_BUTTON_MODE_RGB, 0xD13A01 },
  1317. { 0xFF906F, IR_BUTTON_MODE_RGB, 0x00E644 },
  1318. { 0xFF50AF, IR_BUTTON_MODE_RGB, 0x0040A7 },
  1319. { 0xFFD02F, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FLASH },
  1320. { 0xFF30CF, IR_BUTTON_MODE_RGB, 0xE96F2A },
  1321. { 0xFFB04F, IR_BUTTON_MODE_RGB, 0x00BEBF },
  1322. { 0xFF708F, IR_BUTTON_MODE_RGB, 0x56406F },
  1323. { 0xFFF00F, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_STROBE },
  1324. { 0xFF08F7, IR_BUTTON_MODE_RGB, 0xEE9819 },
  1325. { 0xFF8877, IR_BUTTON_MODE_RGB, 0x00799A },
  1326. { 0xFF48B7, IR_BUTTON_MODE_RGB, 0x944E80 },
  1327. { 0xFFC837, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FADE },
  1328. { 0xFF28D7, IR_BUTTON_MODE_RGB, 0xFFFF00 },
  1329. { 0xFFA857, IR_BUTTON_MODE_RGB, 0x0060A1 },
  1330. { 0xFF6897, IR_BUTTON_MODE_RGB, 0xEF45AD },
  1331. { 0xFFE817, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_SMOOTH }
  1332. };
  1333. #endif
  1334. //Remote Buttons SET 3 (samsung AA59-00608A 8 Toggle Buttons for generic 8CH module)
  1335. #if IR_BUTTON_SET == 3
  1336. /*
  1337. +------+------+------+
  1338. | 1 | 2 | 3 |
  1339. +------+------+------+
  1340. | 4 | 5 | 6 |
  1341. +------+------+------+
  1342. | 7 | 8 | 9 |
  1343. +------+------+------+
  1344. | | 0 | |
  1345. +------+------+------+
  1346. */
  1347. #define IR_BUTTON_COUNT 10
  1348. const unsigned long IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {
  1349. { 0xE0E020DF, IR_BUTTON_MODE_TOGGLE, 0 }, // Toggle Relay #0
  1350. { 0xE0E0A05F, IR_BUTTON_MODE_TOGGLE, 1 }, // Toggle Relay #1
  1351. { 0xE0E0609F, IR_BUTTON_MODE_TOGGLE, 2 }, // Toggle Relay #2
  1352. { 0xE0E010EF, IR_BUTTON_MODE_TOGGLE, 3 }, // Toggle Relay #3
  1353. { 0xE0E0906F, IR_BUTTON_MODE_TOGGLE, 4 }, // Toggle Relay #4
  1354. { 0xE0E050AF, IR_BUTTON_MODE_TOGGLE, 5 }, // Toggle Relay #5
  1355. { 0xE0E030CF, IR_BUTTON_MODE_TOGGLE, 6 }, // Toggle Relay #6
  1356. { 0xE0E0B04F, IR_BUTTON_MODE_TOGGLE, 7 } // Toggle Relay #7
  1357. //{ 0xE0E0708F, IR_BUTTON_MODE_TOGGLE, 8 } //Extra Button
  1358. //{ 0xE0E08877, IR_BUTTON_MODE_TOGGLE, 9 } //Extra Button
  1359. };
  1360. #endif
  1361. //Remote Buttons SET 4
  1362. #if IR_BUTTON_SET == 4
  1363. /*
  1364. +------+------+------+
  1365. | OFF | SRC | MUTE |
  1366. +------+------+------+
  1367. ...
  1368. +------+------+------+
  1369. */
  1370. #define IR_BUTTON_COUNT 1
  1371. const unsigned long IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {
  1372. { 0xFFB24D, IR_BUTTON_MODE_TOGGLE, 0 } // Toggle Relay #0
  1373. };
  1374. #endif
  1375. //Remote Buttons SET 5 (another identical IR Remote shipped with another controller as SET 1 and 2)
  1376. #if IR_BUTTON_SET == 5
  1377. /*
  1378. +------+------+------+------+
  1379. | UP | Down | OFF | ON |
  1380. +------+------+------+------+
  1381. | R | G | B | W |
  1382. +------+------+------+------+
  1383. | 1 | 2 | 3 |FLASH |
  1384. +------+------+------+------+
  1385. | 4 | 5 | 6 |STROBE|
  1386. +------+------+------+------+
  1387. | 7 | 8 | 9 | FADE |
  1388. +------+------+------+------+
  1389. | 10 | 11 | 12 |SMOOTH|
  1390. +------+------+------+------+
  1391. */
  1392. #define IR_BUTTON_COUNT 24
  1393. const unsigned long IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {
  1394. { 0xF700FF, IR_BUTTON_MODE_BRIGHTER, 1 },
  1395. { 0xF7807F, IR_BUTTON_MODE_BRIGHTER, 0 },
  1396. { 0xF740BF, IR_BUTTON_MODE_STATE, 0 },
  1397. { 0xF7C03F, IR_BUTTON_MODE_STATE, 1 },
  1398. { 0xF720DF, IR_BUTTON_MODE_RGB, 0xFF0000 },
  1399. { 0xF7A05F, IR_BUTTON_MODE_RGB, 0x00FF00 },
  1400. { 0xF7609F, IR_BUTTON_MODE_RGB, 0x0000FF },
  1401. { 0xF7E01F, IR_BUTTON_MODE_RGB, 0xFFFFFF },
  1402. { 0xF710EF, IR_BUTTON_MODE_RGB, 0xD13A01 },
  1403. { 0xF7906F, IR_BUTTON_MODE_RGB, 0x00E644 },
  1404. { 0xF750AF, IR_BUTTON_MODE_RGB, 0x0040A7 },
  1405. { 0xF7D02F, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FLASH },
  1406. { 0xF730CF, IR_BUTTON_MODE_RGB, 0xE96F2A },
  1407. { 0xF7B04F, IR_BUTTON_MODE_RGB, 0x00BEBF },
  1408. { 0xF7708F, IR_BUTTON_MODE_RGB, 0x56406F },
  1409. { 0xF7F00F, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_STROBE },
  1410. { 0xF708F7, IR_BUTTON_MODE_RGB, 0xEE9819 },
  1411. { 0xF78877, IR_BUTTON_MODE_RGB, 0x00799A },
  1412. { 0xF748B7, IR_BUTTON_MODE_RGB, 0x944E80 },
  1413. { 0xF7C837, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FADE },
  1414. { 0xF728D7, IR_BUTTON_MODE_RGB, 0xFFFF00 },
  1415. { 0xF7A857, IR_BUTTON_MODE_RGB, 0x0060A1 },
  1416. { 0xF76897, IR_BUTTON_MODE_RGB, 0xEF45AD },
  1417. { 0xF7E817, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_SMOOTH }
  1418. };
  1419. #endif
  1420. #ifndef IR_BUTTON_COUNT
  1421. #define IR_BUTTON_COUNT 0
  1422. #endif
  1423. //--------------------------------------------------------------------------------
  1424. // Custom RFM69 to MQTT bridge
  1425. // Check http://tinkerman.cat/rfm69-wifi-gateway/
  1426. // Enable support by passing RFM69_SUPPORT=1 build flag
  1427. //--------------------------------------------------------------------------------
  1428. #ifndef RFM69_SUPPORT
  1429. #define RFM69_SUPPORT 0
  1430. #endif
  1431. #ifndef RFM69_MAX_TOPICS
  1432. #define RFM69_MAX_TOPICS 50
  1433. #endif
  1434. #ifndef RFM69_MAX_NODES
  1435. #define RFM69_MAX_NODES 255
  1436. #endif
  1437. #ifndef RFM69_DEFAULT_TOPIC
  1438. #define RFM69_DEFAULT_TOPIC "/rfm69gw/{node}/{key}"
  1439. #endif
  1440. #ifndef RFM69_NODE_ID
  1441. #define RFM69_NODE_ID 1
  1442. #endif
  1443. #ifndef RFM69_GATEWAY_ID
  1444. #define RFM69_GATEWAY_ID 1
  1445. #endif
  1446. #ifndef RFM69_NETWORK_ID
  1447. #define RFM69_NETWORK_ID 164
  1448. #endif
  1449. #ifndef RFM69_PROMISCUOUS
  1450. #define RFM69_PROMISCUOUS 0
  1451. #endif
  1452. #ifndef RFM69_PROMISCUOUS_SENDS
  1453. #define RFM69_PROMISCUOUS_SENDS 0
  1454. #endif
  1455. #ifndef RFM69_FREQUENCY
  1456. #define RFM69_FREQUENCY RF69_868MHZ
  1457. #endif
  1458. #ifndef RFM69_ENCRYPTKEY
  1459. #define RFM69_ENCRYPTKEY "fibonacci0123456"
  1460. #endif
  1461. #ifndef RFM69_CS_PIN
  1462. #define RFM69_CS_PIN SS
  1463. #endif
  1464. #ifndef RFM69_IRQ_PIN
  1465. #define RFM69_IRQ_PIN 5
  1466. #endif
  1467. #ifndef RFM69_RESET_PIN
  1468. #define RFM69_RESET_PIN 7
  1469. #endif
  1470. #ifndef RFM69_IS_RFM69HW
  1471. #define RFM69_IS_RFM69HW 0
  1472. #endif
  1473. //--------------------------------------------------------------------------------
  1474. // TUYA switch & dimmer support
  1475. //--------------------------------------------------------------------------------
  1476. #ifndef TUYA_SUPPORT
  1477. #define TUYA_SUPPORT 0
  1478. #endif
  1479. #ifndef TUYA_SERIAL
  1480. #define TUYA_SERIAL Serial
  1481. #endif