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.

1606 lines
51 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
7 years ago
8 years ago
8 years ago
7 years ago
6 years ago
6 years ago
6 years ago
8 years ago
7 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. // Serial debug log
  29. #ifndef DEBUG_SERIAL_SUPPORT
  30. #define DEBUG_SERIAL_SUPPORT 1 // Enable serial debug log
  31. #endif
  32. #ifndef DEBUG_PORT
  33. #define DEBUG_PORT Serial // Default debugging port
  34. #endif
  35. #ifndef SERIAL_BAUDRATE
  36. #define SERIAL_BAUDRATE 115200 // Default baudrate
  37. #endif
  38. #ifndef DEBUG_ADD_TIMESTAMP
  39. #define DEBUG_ADD_TIMESTAMP 1 // Add timestamp to debug messages
  40. // (in millis overflowing every 1000 seconds)
  41. #endif
  42. // Second serial port (used for RX)
  43. #ifndef SERIAL_RX_ENABLED
  44. #define SERIAL_RX_ENABLED 0 // Secondary serial port for RX
  45. #endif
  46. #ifndef SERIAL_RX_PORT
  47. #define SERIAL_RX_PORT Serial // This setting is usually defined
  48. // in the hardware.h file for those
  49. // boards that require it
  50. #endif
  51. #ifndef SERIAL_RX_BAUDRATE
  52. #define SERIAL_RX_BAUDRATE 115200 // Default baudrate
  53. #endif
  54. //------------------------------------------------------------------------------
  55. // UDP debug log
  56. // To receive the message son the destination computer use nc:
  57. // nc -ul 8113
  58. #ifndef DEBUG_UDP_SUPPORT
  59. #define DEBUG_UDP_SUPPORT 0 // Enable UDP debug log
  60. #endif
  61. #ifndef DEBUG_UDP_IP
  62. #define DEBUG_UDP_IP IPAddress(192, 168, 1, 100)
  63. #endif
  64. #ifndef DEBUG_UDP_PORT
  65. #define DEBUG_UDP_PORT 514
  66. #endif
  67. // If DEBUG_UDP_PORT is set to 514 syslog format is assumed
  68. // (https://tools.ietf.org/html/rfc3164)
  69. // DEBUG_UDP_FAC_PRI is the facility+priority
  70. #define DEBUG_UDP_FAC_PRI (SYSLOG_LOCAL0 | SYSLOG_DEBUG)
  71. //------------------------------------------------------------------------------
  72. #ifndef DEBUG_TELNET_SUPPORT
  73. #define DEBUG_TELNET_SUPPORT 1 // Enable telnet debug log (will only work if TELNET_SUPPORT is also 1)
  74. #endif
  75. //------------------------------------------------------------------------------
  76. #ifndef DEBUG_WEB_SUPPORT
  77. #define DEBUG_WEB_SUPPORT 1 // Enable web debug log (will only work if WEB_SUPPORT is also 1)
  78. #endif
  79. //------------------------------------------------------------------------------
  80. // TELNET
  81. //------------------------------------------------------------------------------
  82. #ifndef TELNET_SUPPORT
  83. #define TELNET_SUPPORT 1 // Enable telnet support by default (3.34Kb)
  84. #endif
  85. #ifndef TELNET_STA
  86. #define TELNET_STA 0 // By default, disallow connections via STA interface
  87. #endif
  88. #ifndef TELNET_AUTHENTICATION
  89. #define TELNET_AUTHENTICATION 1 // Request password to start telnet session by default
  90. #endif
  91. #define TELNET_PORT 23 // Port to listen to telnet clients
  92. #define TELNET_MAX_CLIENTS 1 // Max number of concurrent telnet clients
  93. //------------------------------------------------------------------------------
  94. // TERMINAL
  95. //------------------------------------------------------------------------------
  96. #ifndef TERMINAL_SUPPORT
  97. #define TERMINAL_SUPPORT 1 // Enable terminal commands (0.97Kb)
  98. #endif
  99. #define TERMINAL_BUFFER_SIZE 128 // Max size for commands commands
  100. //------------------------------------------------------------------------------
  101. // SYSTEM CHECK
  102. //------------------------------------------------------------------------------
  103. #ifndef SYSTEM_CHECK_ENABLED
  104. #define SYSTEM_CHECK_ENABLED 1 // Enable crash check by default
  105. #endif
  106. #ifndef SYSTEM_CHECK_TIME
  107. #define SYSTEM_CHECK_TIME 60000 // The system is considered stable after these many millis
  108. #endif
  109. #ifndef SYSTEM_CHECK_MAX
  110. #define SYSTEM_CHECK_MAX 5 // After this many crashes on boot
  111. // the system is flagged as unstable
  112. #endif
  113. //------------------------------------------------------------------------------
  114. // EEPROM
  115. //------------------------------------------------------------------------------
  116. #define EEPROM_SIZE SPI_FLASH_SEC_SIZE // EEPROM size in bytes (1 sector = 4096 bytes)
  117. //#define EEPROM_RORATE_SECTORS 2 // Number of sectors to use for EEPROM rotation
  118. // If not defined the firmware will use a number based
  119. // on the number of available sectors
  120. #define EEPROM_RELAY_STATUS 0 // Address for the relay status (1 byte)
  121. #define EEPROM_ENERGY_COUNT 1 // Address for the energy counter (4 bytes)
  122. #define EEPROM_CUSTOM_RESET 5 // Address for the reset reason (1 byte)
  123. #define EEPROM_CRASH_COUNTER 6 // Address for the crash counter (1 byte)
  124. #define EEPROM_MESSAGE_ID 7 // Address for the MQTT message id (4 bytes)
  125. #define EEPROM_ROTATE_DATA 11 // Reserved for the EEPROM_ROTATE library (3 bytes)
  126. #define EEPROM_DATA_END 14 // End of custom EEPROM data block
  127. //------------------------------------------------------------------------------
  128. // THERMOSTAT
  129. //------------------------------------------------------------------------------
  130. #ifndef THERMOSTAT_SUPPORT
  131. #define THERMOSTAT_SUPPORT 0
  132. #endif
  133. #ifndef THERMOSTAT_DISPLAY_SUPPORT
  134. #define THERMOSTAT_DISPLAY_SUPPORT 0
  135. #endif
  136. #define THERMOSTAT_SERVER_LOST_INTERVAL 120000 //server means lost after 2 min from last response
  137. #define THERMOSTAT_REMOTE_TEMP_MAX_WAIT 120 // 2 min
  138. //------------------------------------------------------------------------------
  139. // HEARTBEAT
  140. //------------------------------------------------------------------------------
  141. #define HEARTBEAT_NONE 0 // Never send heartbeat
  142. #define HEARTBEAT_ONCE 1 // Send it only once upon MQTT connection
  143. #define HEARTBEAT_REPEAT 2 // Send it upon MQTT connection and every HEARTBEAT_INTERVAL
  144. #define HEARTBEAT_REPEAT_STATUS 3 // Send it upon MQTT connection and every HEARTBEAT_INTERVAL only STATUS report
  145. // Backwards compatibility check
  146. #if defined(HEARTBEAT_ENABLED) && (HEARTBEAT_ENABLED == 0)
  147. #define HEARTBEAT_MODE HEARTBEAT_NONE
  148. #endif
  149. #ifndef HEARTBEAT_MODE
  150. #define HEARTBEAT_MODE HEARTBEAT_REPEAT
  151. #endif
  152. #ifndef HEARTBEAT_INTERVAL
  153. #define HEARTBEAT_INTERVAL 300 // Interval between heartbeat messages (in sec)
  154. #endif
  155. #define UPTIME_OVERFLOW 4294967295 // Uptime overflow value
  156. // Values that will be reported in heartbeat
  157. #ifndef HEARTBEAT_REPORT_STATUS
  158. #define HEARTBEAT_REPORT_STATUS 1
  159. #endif
  160. #ifndef HEARTBEAT_REPORT_SSID
  161. #define HEARTBEAT_REPORT_SSID 1
  162. #endif
  163. #ifndef HEARTBEAT_REPORT_IP
  164. #define HEARTBEAT_REPORT_IP 1
  165. #endif
  166. #ifndef HEARTBEAT_REPORT_MAC
  167. #define HEARTBEAT_REPORT_MAC 1
  168. #endif
  169. #ifndef HEARTBEAT_REPORT_RSSI
  170. #define HEARTBEAT_REPORT_RSSI 1
  171. #endif
  172. #ifndef HEARTBEAT_REPORT_UPTIME
  173. #define HEARTBEAT_REPORT_UPTIME 1
  174. #endif
  175. #ifndef HEARTBEAT_REPORT_DATETIME
  176. #define HEARTBEAT_REPORT_DATETIME 1
  177. #endif
  178. #ifndef HEARTBEAT_REPORT_FREEHEAP
  179. #define HEARTBEAT_REPORT_FREEHEAP 1
  180. #endif
  181. #ifndef HEARTBEAT_REPORT_VCC
  182. #define HEARTBEAT_REPORT_VCC 1
  183. #endif
  184. #ifndef HEARTBEAT_REPORT_RELAY
  185. #define HEARTBEAT_REPORT_RELAY 1
  186. #endif
  187. #ifndef HEARTBEAT_REPORT_LIGHT
  188. #define HEARTBEAT_REPORT_LIGHT 1
  189. #endif
  190. #ifndef HEARTBEAT_REPORT_HOSTNAME
  191. #define HEARTBEAT_REPORT_HOSTNAME 1
  192. #endif
  193. #ifndef HEARTBEAT_REPORT_DESCRIPTION
  194. #define HEARTBEAT_REPORT_DESCRIPTION 1
  195. #endif
  196. #ifndef HEARTBEAT_REPORT_APP
  197. #define HEARTBEAT_REPORT_APP 1
  198. #endif
  199. #ifndef HEARTBEAT_REPORT_VERSION
  200. #define HEARTBEAT_REPORT_VERSION 1
  201. #endif
  202. #ifndef HEARTBEAT_REPORT_BOARD
  203. #define HEARTBEAT_REPORT_BOARD 1
  204. #endif
  205. #ifndef HEARTBEAT_REPORT_LOADAVG
  206. #define HEARTBEAT_REPORT_LOADAVG 1
  207. #endif
  208. #ifndef HEARTBEAT_REPORT_INTERVAL
  209. #define HEARTBEAT_REPORT_INTERVAL 0
  210. #endif
  211. #if THERMOSTAT_SUPPORT && ! defined HEARTBEAT_REPORT_RANGE
  212. #define HEARTBEAT_REPORT_RANGE 1
  213. #else
  214. #define HEARTBEAT_REPORT_RANGE 0
  215. #endif
  216. #if THERMOSTAT_SUPPORT && ! defined HEARTBEAT_REPORT_REMOTE_TEMP
  217. #define HEARTBEAT_REPORT_REMOTE_TEMP 1
  218. #else
  219. #define HEARTBEAT_REPORT_REMOTE_TEMP 0
  220. #endif
  221. //------------------------------------------------------------------------------
  222. // Load average
  223. //------------------------------------------------------------------------------
  224. #ifndef LOADAVG_INTERVAL
  225. #define LOADAVG_INTERVAL 30000 // Interval between calculating load average (in ms)
  226. #endif
  227. //------------------------------------------------------------------------------
  228. // BUTTON
  229. //------------------------------------------------------------------------------
  230. #ifndef BUTTON_SUPPORT
  231. #define BUTTON_SUPPORT 1
  232. #endif
  233. #ifndef BUTTON_DEBOUNCE_DELAY
  234. #define BUTTON_DEBOUNCE_DELAY 50 // Debounce delay (ms)
  235. #endif
  236. #ifndef BUTTON_DBLCLICK_DELAY
  237. #define BUTTON_DBLCLICK_DELAY 500 // Time in ms to wait for a second (or third...) click
  238. #endif
  239. #ifndef BUTTON_LNGCLICK_DELAY
  240. #define BUTTON_LNGCLICK_DELAY 1000 // Time in ms holding the button down to get a long click
  241. #endif
  242. #ifndef BUTTON_LNGLNGCLICK_DELAY
  243. #define BUTTON_LNGLNGCLICK_DELAY 10000 // Time in ms holding the button down to get a long-long click
  244. #endif
  245. #ifndef BUTTON_MQTT_SEND_ALL_EVENTS
  246. #define BUTTON_MQTT_SEND_ALL_EVENTS 0 // 0 - to send only events the are bound to actions
  247. // 1 - to send all button events to MQTT
  248. #endif
  249. //------------------------------------------------------------------------------
  250. // ENCODER
  251. //------------------------------------------------------------------------------
  252. #ifndef ENCODER_SUPPORT
  253. #define ENCODER_SUPPORT 0
  254. #endif
  255. #ifndef ENCODER_MINIMUM_DELTA
  256. #define ENCODER_MINIMUM_DELTA 1
  257. #endif
  258. //------------------------------------------------------------------------------
  259. // LED
  260. //------------------------------------------------------------------------------
  261. #ifndef LED_SUPPORT
  262. #define LED_SUPPORT 1
  263. #endif
  264. //------------------------------------------------------------------------------
  265. // RELAY
  266. //------------------------------------------------------------------------------
  267. // Default boot mode: 0 means OFF, 1 ON and 2 whatever was before
  268. #ifndef RELAY_BOOT_MODE
  269. #define RELAY_BOOT_MODE RELAY_BOOT_OFF
  270. #endif
  271. // 0 means ANY, 1 zero or one and 2 one and only one
  272. #ifndef RELAY_SYNC
  273. #define RELAY_SYNC RELAY_SYNC_ANY
  274. #endif
  275. // Default pulse mode: 0 means no pulses, 1 means normally off, 2 normally on
  276. #ifndef RELAY_PULSE_MODE
  277. #define RELAY_PULSE_MODE RELAY_PULSE_NONE
  278. #endif
  279. // Default pulse time in seconds
  280. #ifndef RELAY_PULSE_TIME
  281. #define RELAY_PULSE_TIME 1.0
  282. #endif
  283. // Relay requests flood protection window - in seconds
  284. #ifndef RELAY_FLOOD_WINDOW
  285. #define RELAY_FLOOD_WINDOW 3
  286. #endif
  287. // Allowed actual relay changes inside requests flood protection window
  288. #ifndef RELAY_FLOOD_CHANGES
  289. #define RELAY_FLOOD_CHANGES 5
  290. #endif
  291. // Pulse with in milliseconds for a latched relay
  292. #ifndef RELAY_LATCHING_PULSE
  293. #define RELAY_LATCHING_PULSE 10
  294. #endif
  295. // Do not save relay state after these many milliseconds
  296. #ifndef RELAY_SAVE_DELAY
  297. #define RELAY_SAVE_DELAY 1000
  298. #endif
  299. #ifndef RELAY_REPORT_STATUS
  300. #define RELAY_REPORT_STATUS 1
  301. #endif
  302. // Configure the MQTT payload for ON/OFF
  303. #ifndef RELAY_MQTT_ON
  304. #define RELAY_MQTT_ON "1"
  305. #endif
  306. #ifndef RELAY_MQTT_OFF
  307. #define RELAY_MQTT_OFF "0"
  308. #endif
  309. // TODO Only single EEPROM address is used to store state, which is 1 byte
  310. // Relay status is stored using bitfield.
  311. // This means that, atm, we are only storing the status of the first 8 relays.
  312. #define RELAY_SAVE_MASK_MAX 8
  313. // -----------------------------------------------------------------------------
  314. // WIFI
  315. // -----------------------------------------------------------------------------
  316. #ifndef WIFI_CONNECT_TIMEOUT
  317. #define WIFI_CONNECT_TIMEOUT 60000 // Connecting timeout for WIFI in ms
  318. #endif
  319. #ifndef WIFI_RECONNECT_INTERVAL
  320. #define WIFI_RECONNECT_INTERVAL 180000 // If could not connect to WIFI, retry after this time in ms
  321. #endif
  322. #ifndef WIFI_MAX_NETWORKS
  323. #define WIFI_MAX_NETWORKS 5 // Max number of WIFI connection configurations
  324. #endif
  325. #ifndef WIFI_AP_CAPTIVE
  326. #define WIFI_AP_CAPTIVE 1 // Captive portal enabled when in AP mode
  327. #endif
  328. #ifndef WIFI_FALLBACK_APMODE
  329. #define WIFI_FALLBACK_APMODE 1 // Fallback to AP mode if no STA connection
  330. #endif
  331. #ifndef WIFI_SLEEP_MODE
  332. #define WIFI_SLEEP_MODE WIFI_NONE_SLEEP // WIFI_NONE_SLEEP, WIFI_LIGHT_SLEEP or WIFI_MODEM_SLEEP
  333. #endif
  334. #ifndef WIFI_SCAN_NETWORKS
  335. #define WIFI_SCAN_NETWORKS 1 // Perform a network scan before connecting
  336. #endif
  337. // Optional hardcoded configuration (up to 2 networks)
  338. #ifndef WIFI1_SSID
  339. #define WIFI1_SSID ""
  340. #endif
  341. #ifndef WIFI1_PASS
  342. #define WIFI1_PASS ""
  343. #endif
  344. #ifndef WIFI1_IP
  345. #define WIFI1_IP ""
  346. #endif
  347. #ifndef WIFI1_GW
  348. #define WIFI1_GW ""
  349. #endif
  350. #ifndef WIFI1_MASK
  351. #define WIFI1_MASK ""
  352. #endif
  353. #ifndef WIFI1_DNS
  354. #define WIFI1_DNS ""
  355. #endif
  356. #ifndef WIFI2_SSID
  357. #define WIFI2_SSID ""
  358. #endif
  359. #ifndef WIFI2_PASS
  360. #define WIFI2_PASS ""
  361. #endif
  362. #ifndef WIFI2_IP
  363. #define WIFI2_IP ""
  364. #endif
  365. #ifndef WIFI2_GW
  366. #define WIFI2_GW ""
  367. #endif
  368. #ifndef WIFI2_MASK
  369. #define WIFI2_MASK ""
  370. #endif
  371. #ifndef WIFI2_DNS
  372. #define WIFI2_DNS ""
  373. #endif
  374. #ifndef WIFI3_SSID
  375. #define WIFI3_SSID ""
  376. #endif
  377. #ifndef WIFI3_PASS
  378. #define WIFI3_PASS ""
  379. #endif
  380. #ifndef WIFI3_IP
  381. #define WIFI3_IP ""
  382. #endif
  383. #ifndef WIFI3_GW
  384. #define WIFI3_GW ""
  385. #endif
  386. #ifndef WIFI3_MASK
  387. #define WIFI3_MASK ""
  388. #endif
  389. #ifndef WIFI3_DNS
  390. #define WIFI3_DNS ""
  391. #endif
  392. #ifndef WIFI4_SSID
  393. #define WIFI4_SSID ""
  394. #endif
  395. #ifndef WIFI4_PASS
  396. #define WIFI4_PASS ""
  397. #endif
  398. #ifndef WIFI4_IP
  399. #define WIFI4_IP ""
  400. #endif
  401. #ifndef WIFI4_GW
  402. #define WIFI4_GW ""
  403. #endif
  404. #ifndef WIFI4_MASK
  405. #define WIFI4_MASK ""
  406. #endif
  407. #ifndef WIFI4_DNS
  408. #define WIFI4_DNS ""
  409. #endif
  410. #ifndef WIFI_RSSI_1M
  411. #define WIFI_RSSI_1M -30 // Calibrate it with your router reading the RSSI at 1m
  412. #endif
  413. #ifndef WIFI_PROPAGATION_CONST
  414. #define WIFI_PROPAGATION_CONST 4 // This is typically something between 2.7 to 4.3 (free space is 2)
  415. #endif
  416. // -----------------------------------------------------------------------------
  417. // WEB
  418. // -----------------------------------------------------------------------------
  419. #ifndef WEB_SUPPORT
  420. #define WEB_SUPPORT 1 // Enable web support (http, api, 121.65Kb)
  421. #endif
  422. #ifndef WEB_EMBEDDED
  423. #define WEB_EMBEDDED 1 // Build the firmware with the web interface embedded in
  424. #endif
  425. // This is not working at the moment!!
  426. // Requires ASYNC_TCP_SSL_ENABLED to 1 and ESP8266 Arduino Core 2.4.0
  427. #ifndef WEB_SSL_ENABLED
  428. #define WEB_SSL_ENABLED 0 // Use HTTPS web interface
  429. #endif
  430. #ifndef WEB_USERNAME
  431. #define WEB_USERNAME "admin" // HTTP username
  432. #endif
  433. #ifndef WEB_FORCE_PASS_CHANGE
  434. #define WEB_FORCE_PASS_CHANGE 1 // Force the user to change the password if default one
  435. #endif
  436. #ifndef WEB_PORT
  437. #define WEB_PORT 80 // HTTP port
  438. #endif
  439. // Defining a WEB_REMOTE_DOMAIN will enable Cross-Origin Resource Sharing (CORS)
  440. // so you will be able to login to this device from another domain. This will allow
  441. // you to manage all ESPurna devices in your local network from a unique installation
  442. // of the web UI. This installation could be in a local server (a Raspberry Pi, for instance)
  443. // or in the Internet. Since the WebUI is just one compressed file with HTML, CSS and JS
  444. // there are no special requirements. Any static web server will do (NGinx, Apache, Lighttpd,...).
  445. // The only requirement is that the resource must be available under this domain.
  446. #ifndef WEB_REMOTE_DOMAIN
  447. #define WEB_REMOTE_DOMAIN "http://espurna.io"
  448. #endif
  449. // -----------------------------------------------------------------------------
  450. // WEBSOCKETS
  451. // -----------------------------------------------------------------------------
  452. // This will only be enabled if WEB_SUPPORT is 1 (this is the default value)
  453. #ifndef WS_AUTHENTICATION
  454. #define WS_AUTHENTICATION 1 // WS authentication ON by default (see #507)
  455. #endif
  456. #ifndef WS_BUFFER_SIZE
  457. #define WS_BUFFER_SIZE 5 // Max number of secured websocket connections
  458. #endif
  459. #ifndef WS_TIMEOUT
  460. #define WS_TIMEOUT 1800000 // Timeout for secured websocket
  461. #endif
  462. #ifndef WS_UPDATE_INTERVAL
  463. #define WS_UPDATE_INTERVAL 30000 // Update clients every 30 seconds
  464. #endif
  465. // -----------------------------------------------------------------------------
  466. // API
  467. // -----------------------------------------------------------------------------
  468. #ifndef API_SUPPORT
  469. #define API_SUPPORT 1 // API (REST & RPC) support built in
  470. #endif
  471. // This will only be enabled if WEB_SUPPORT is 1 (this is the default value)
  472. #ifndef API_ENABLED
  473. #define API_ENABLED 0 // Do not enable API by default
  474. #endif
  475. #ifndef API_RESTFUL
  476. #define API_RESTFUL 1 // A restful API requires changes to be issued as PUT requests
  477. // Setting this to 0 will allow using GET to change relays, for instance
  478. #endif
  479. #ifndef API_BUFFER_SIZE
  480. #define API_BUFFER_SIZE 15 // Size of the buffer for HTTP GET API responses
  481. #endif
  482. #ifndef API_REAL_TIME_VALUES
  483. #define API_REAL_TIME_VALUES 0 // Show filtered/median values by default (0 => median, 1 => real time)
  484. #endif
  485. // -----------------------------------------------------------------------------
  486. // MDNS / LLMNR / NETBIOS / SSDP
  487. // -----------------------------------------------------------------------------
  488. #ifndef MDNS_SERVER_SUPPORT
  489. #define MDNS_SERVER_SUPPORT 1 // Publish services using mDNS by default (1.48Kb)
  490. #endif
  491. #ifndef MDNS_CLIENT_SUPPORT
  492. #define MDNS_CLIENT_SUPPORT 0 // Resolve mDNS names (3.44Kb)
  493. #endif
  494. #ifndef LLMNR_SUPPORT
  495. #define LLMNR_SUPPORT 0 // Publish device using LLMNR protocol by default (1.95Kb) - requires 2.4.0
  496. #endif
  497. #ifndef NETBIOS_SUPPORT
  498. #define NETBIOS_SUPPORT 0 // Publish device using NetBIOS protocol by default (1.26Kb) - requires 2.4.0
  499. #endif
  500. #ifndef SSDP_SUPPORT
  501. #define SSDP_SUPPORT 0 // Publish device using SSDP protocol by default (4.59Kb)
  502. // Not compatible with ALEXA_SUPPORT at the moment
  503. #endif
  504. #ifndef SSDP_DEVICE_TYPE
  505. #define SSDP_DEVICE_TYPE "upnp:rootdevice"
  506. //#define SSDP_DEVICE_TYPE "urn:schemas-upnp-org:device:BinaryLight:1"
  507. #endif
  508. // -----------------------------------------------------------------------------
  509. // SPIFFS
  510. // -----------------------------------------------------------------------------
  511. #ifndef SPIFFS_SUPPORT
  512. #define SPIFFS_SUPPORT 0 // Do not add support for SPIFFS by default
  513. #endif
  514. // -----------------------------------------------------------------------------
  515. // OTA
  516. // -----------------------------------------------------------------------------
  517. #ifndef OTA_PORT
  518. #define OTA_PORT 8266 // OTA port
  519. #endif
  520. #ifndef OTA_MQTT_SUPPORT
  521. #define OTA_MQTT_SUPPORT 0 // No support by default
  522. #endif
  523. #define OTA_GITHUB_FP "D7:9F:07:61:10:B3:92:93:E3:49:AC:89:84:5B:03:80:C1:9E:2F:8B"
  524. // -----------------------------------------------------------------------------
  525. // NOFUSS
  526. // -----------------------------------------------------------------------------
  527. #ifndef NOFUSS_SUPPORT
  528. #define NOFUSS_SUPPORT 0 // Do not enable support for NoFuss by default (12.65Kb)
  529. #endif
  530. #ifndef NOFUSS_ENABLED
  531. #define NOFUSS_ENABLED 0 // Do not perform NoFUSS updates by default
  532. #endif
  533. #ifndef NOFUSS_SERVER
  534. #define NOFUSS_SERVER "" // Default NoFuss Server
  535. #endif
  536. #ifndef NOFUSS_INTERVAL
  537. #define NOFUSS_INTERVAL 3600000 // Check for updates every hour
  538. #endif
  539. // -----------------------------------------------------------------------------
  540. // UART <-> MQTT
  541. // -----------------------------------------------------------------------------
  542. #ifndef UART_MQTT_SUPPORT
  543. #define UART_MQTT_SUPPORT 0 // No support by default
  544. #endif
  545. #ifndef UART_MQTT_USE_SOFT
  546. #define UART_MQTT_USE_SOFT 0 // Use SoftwareSerial
  547. #endif
  548. #ifndef UART_MQTT_HW_PORT
  549. #define UART_MQTT_HW_PORT Serial // Hardware serial port (if UART_MQTT_USE_SOFT == 0)
  550. #endif
  551. #ifndef UART_MQTT_RX_PIN
  552. #define UART_MQTT_RX_PIN 4 // RX PIN (if UART_MQTT_USE_SOFT == 1)
  553. #endif
  554. #ifndef UART_MQTT_TX_PIN
  555. #define UART_MQTT_TX_PIN 5 // TX PIN (if UART_MQTT_USE_SOFT == 1)
  556. #endif
  557. #ifndef UART_MQTT_BAUDRATE
  558. #define UART_MQTT_BAUDRATE 115200 // Serial speed
  559. #endif
  560. #ifndef UART_MQTT_TERMINATION
  561. #define UART_MQTT_TERMINATION '\n' // Termination character
  562. #endif
  563. #define UART_MQTT_BUFFER_SIZE 100 // UART buffer size
  564. // -----------------------------------------------------------------------------
  565. // MQTT
  566. // -----------------------------------------------------------------------------
  567. #ifndef MQTT_SUPPORT
  568. #define MQTT_SUPPORT 1 // MQTT support (22.38Kb async, 12.48Kb sync)
  569. #endif
  570. #ifndef MQTT_USE_ASYNC
  571. #define MQTT_USE_ASYNC 1 // Use AysncMQTTClient (1) or PubSubClient (0)
  572. #endif
  573. // MQTT OVER SSL
  574. // Using MQTT over SSL works pretty well but generates problems with the web interface.
  575. // It could be a good idea to use it in conjuntion with WEB_SUPPORT=0.
  576. // Requires ASYNC_TCP_SSL_ENABLED to 1 and ESP8266 Arduino Core 2.4.0.
  577. //
  578. // You can use SSL with MQTT_USE_ASYNC=1 (AsyncMqttClient library)
  579. // but you might experience hiccups on the web interface, so my recommendation is:
  580. // WEB_SUPPORT=0
  581. //
  582. // If you use SSL with MQTT_USE_ASYNC=0 (PubSubClient library)
  583. // you will have to disable all the modules that use ESPAsyncTCP, that is:
  584. // ALEXA_SUPPORT=0, INFLUXDB_SUPPORT=0, TELNET_SUPPORT=0, THINGSPEAK_SUPPORT=0 and WEB_SUPPORT=0
  585. //
  586. // You will need the fingerprint for your MQTT server, example for CloudMQTT:
  587. // $ echo -n | openssl s_client -connect m11.cloudmqtt.com:24055 > cloudmqtt.pem
  588. // $ openssl x509 -noout -in cloudmqtt.pem -fingerprint -sha1
  589. #ifndef MQTT_SSL_ENABLED
  590. #define MQTT_SSL_ENABLED 0 // By default MQTT over SSL will not be enabled
  591. #endif
  592. #ifndef MQTT_SSL_FINGERPRINT
  593. #define MQTT_SSL_FINGERPRINT "" // SSL fingerprint of the server
  594. #endif
  595. #ifndef MQTT_ENABLED
  596. #define MQTT_ENABLED 0 // Do not enable MQTT connection by default
  597. #endif
  598. #ifndef MQTT_AUTOCONNECT
  599. #define MQTT_AUTOCONNECT 1 // If enabled and MDNS_SERVER_SUPPORT=1 will perform an autodiscover and
  600. // autoconnect to the first MQTT broker found if none defined
  601. #endif
  602. #ifndef MQTT_SERVER
  603. #define MQTT_SERVER "" // Default MQTT broker address
  604. #endif
  605. #ifndef MQTT_USER
  606. #define MQTT_USER "" // Default MQTT broker usename
  607. #endif
  608. #ifndef MQTT_PASS
  609. #define MQTT_PASS "" // Default MQTT broker password
  610. #endif
  611. #ifndef MQTT_PORT
  612. #define MQTT_PORT 1883 // MQTT broker port
  613. #endif
  614. #ifndef MQTT_TOPIC
  615. #define MQTT_TOPIC "{hostname}" // Default MQTT base topic
  616. #endif
  617. #ifndef MQTT_RETAIN
  618. #define MQTT_RETAIN true // MQTT retain flag
  619. #endif
  620. #ifndef MQTT_QOS
  621. #define MQTT_QOS 0 // MQTT QoS value for all messages
  622. #endif
  623. #ifndef MQTT_KEEPALIVE
  624. #define MQTT_KEEPALIVE 300 // MQTT keepalive value
  625. #endif
  626. #ifndef MQTT_RECONNECT_DELAY_MIN
  627. #define MQTT_RECONNECT_DELAY_MIN 5000 // Try to reconnect in 5 seconds upon disconnection
  628. #endif
  629. #ifndef MQTT_RECONNECT_DELAY_STEP
  630. #define MQTT_RECONNECT_DELAY_STEP 5000 // Increase the reconnect delay in 5 seconds after each failed attempt
  631. #endif
  632. #ifndef MQTT_RECONNECT_DELAY_MAX
  633. #define MQTT_RECONNECT_DELAY_MAX 120000 // Set reconnect time to 2 minutes at most
  634. #endif
  635. #ifndef MQTT_SKIP_RETAINED
  636. #define MQTT_SKIP_RETAINED 1 // Skip retained messages on connection
  637. #endif
  638. #ifndef MQTT_SKIP_TIME
  639. #define MQTT_SKIP_TIME 1000 // Skip messages for 1 second anter connection
  640. #endif
  641. #if THERMOSTAT_SUPPORT == 1
  642. #ifndef MQTT_USE_JSON
  643. #define MQTT_USE_JSON 1 // Group messages in a JSON body
  644. #endif
  645. #else
  646. #ifndef MQTT_USE_JSON
  647. #define MQTT_USE_JSON 0 // Don't group messages in a JSON body (default)
  648. #endif
  649. #endif
  650. #ifndef MQTT_USE_JSON_DELAY
  651. #define MQTT_USE_JSON_DELAY 100 // Wait this many ms before grouping messages
  652. #endif
  653. #ifndef MQTT_QUEUE_MAX_SIZE
  654. #define MQTT_QUEUE_MAX_SIZE 20 // Size of the MQTT queue when MQTT_USE_JSON is enabled
  655. #endif
  656. // These are the properties that will be sent when useJson is true
  657. #ifndef MQTT_ENQUEUE_IP
  658. #define MQTT_ENQUEUE_IP 1
  659. #endif
  660. #ifndef MQTT_ENQUEUE_MAC
  661. #define MQTT_ENQUEUE_MAC 1
  662. #endif
  663. #ifndef MQTT_ENQUEUE_HOSTNAME
  664. #define MQTT_ENQUEUE_HOSTNAME 1
  665. #endif
  666. #ifndef MQTT_ENQUEUE_DATETIME
  667. #define MQTT_ENQUEUE_DATETIME 1
  668. #endif
  669. #ifndef MQTT_ENQUEUE_MESSAGE_ID
  670. #define MQTT_ENQUEUE_MESSAGE_ID 1
  671. #endif
  672. // These particles will be concatenated to the MQTT_TOPIC base to form the actual topic
  673. #define MQTT_TOPIC_JSON "data"
  674. #define MQTT_TOPIC_ACTION "action"
  675. #define MQTT_TOPIC_RELAY "relay"
  676. #define MQTT_TOPIC_LED "led"
  677. #define MQTT_TOPIC_BUTTON "button"
  678. #define MQTT_TOPIC_IP "ip"
  679. #define MQTT_TOPIC_SSID "ssid"
  680. #define MQTT_TOPIC_VERSION "version"
  681. #define MQTT_TOPIC_UPTIME "uptime"
  682. #define MQTT_TOPIC_DATETIME "datetime"
  683. #define MQTT_TOPIC_FREEHEAP "freeheap"
  684. #define MQTT_TOPIC_VCC "vcc"
  685. #define MQTT_TOPIC_STATUS "status"
  686. #define MQTT_TOPIC_MAC "mac"
  687. #define MQTT_TOPIC_RSSI "rssi"
  688. #define MQTT_TOPIC_MESSAGE_ID "id"
  689. #define MQTT_TOPIC_APP "app"
  690. #define MQTT_TOPIC_INTERVAL "interval"
  691. #define MQTT_TOPIC_HOSTNAME "host"
  692. #define MQTT_TOPIC_DESCRIPTION "desc"
  693. #define MQTT_TOPIC_TIME "time"
  694. #define MQTT_TOPIC_RFOUT "rfout"
  695. #define MQTT_TOPIC_RFIN "rfin"
  696. #define MQTT_TOPIC_RFLEARN "rflearn"
  697. #define MQTT_TOPIC_RFRAW "rfraw"
  698. #define MQTT_TOPIC_UARTIN "uartin"
  699. #define MQTT_TOPIC_UARTOUT "uartout"
  700. #define MQTT_TOPIC_LOADAVG "loadavg"
  701. #define MQTT_TOPIC_BOARD "board"
  702. #define MQTT_TOPIC_PULSE "pulse"
  703. #define MQTT_TOPIC_SPEED "speed"
  704. #define MQTT_TOPIC_IRIN "irin"
  705. #define MQTT_TOPIC_IROUT "irout"
  706. #define MQTT_TOPIC_OTA "ota"
  707. // Light module
  708. #define MQTT_TOPIC_CHANNEL "channel"
  709. #define MQTT_TOPIC_COLOR_RGB "rgb"
  710. #define MQTT_TOPIC_COLOR_HSV "hsv"
  711. #define MQTT_TOPIC_ANIM_MODE "anim_mode"
  712. #define MQTT_TOPIC_ANIM_SPEED "anim_speed"
  713. #define MQTT_TOPIC_BRIGHTNESS "brightness"
  714. #define MQTT_TOPIC_MIRED "mired"
  715. #define MQTT_TOPIC_KELVIN "kelvin"
  716. #define MQTT_TOPIC_TRANSITION "transition"
  717. // Thermostat module
  718. #define MQTT_TOPIC_HOLD_TEMP "hold_temp"
  719. #define MQTT_TOPIC_HOLD_TEMP_MIN "min"
  720. #define MQTT_TOPIC_HOLD_TEMP_MAX "max"
  721. #define MQTT_TOPIC_REMOTE_TEMP "remote_temp"
  722. #define MQTT_TOPIC_ASK_TEMP_RANGE "ask_temp_range"
  723. #define MQTT_TOPIC_NOTIFY_TEMP_RANGE_MIN "notify_temp_range_min"
  724. #define MQTT_TOPIC_NOTIFY_TEMP_RANGE_MAX "notify_temp_range_max"
  725. #define MQTT_STATUS_ONLINE "1" // Value for the device ON message
  726. #define MQTT_STATUS_OFFLINE "0" // Value for the device OFF message (will)
  727. #define MQTT_ACTION_RESET "reboot" // RESET MQTT topic particle
  728. #define MQTT_MESSAGE_ID_SHIFT 1000 // Store MQTT message id into EEPROM every these many
  729. // Custom get and set postfixes
  730. // Use something like "/status" or "/set", with leading slash
  731. // Since 1.9.0 the default value is "" for getter and "/set" for setter
  732. #ifndef MQTT_GETTER
  733. #define MQTT_GETTER ""
  734. #endif
  735. #ifndef MQTT_SETTER
  736. #define MQTT_SETTER "/set"
  737. #endif
  738. // -----------------------------------------------------------------------------
  739. // BROKER
  740. // -----------------------------------------------------------------------------
  741. #ifndef BROKER_SUPPORT
  742. #define BROKER_SUPPORT 1 // The broker is a poor-man's pubsub manager
  743. #endif
  744. // -----------------------------------------------------------------------------
  745. // SETTINGS
  746. // -----------------------------------------------------------------------------
  747. #ifndef SETTINGS_AUTOSAVE
  748. #define SETTINGS_AUTOSAVE 1 // Autosave settings or force manual commit
  749. #endif
  750. #define SETTINGS_MAX_LIST_COUNT 10 // Maximum index for settings lists
  751. // -----------------------------------------------------------------------------
  752. // LIGHT
  753. // -----------------------------------------------------------------------------
  754. // LIGHT_PROVIDER_DIMMER can have from 1 to 5 different channels.
  755. // They have to be defined for each device in the hardware.h file.
  756. // If 3 or more channels first 3 will be considered RGB.
  757. // Usual configurations are:
  758. // 1 channels => W
  759. // 2 channels => WW
  760. // 3 channels => RGB
  761. // 4 channels => RGBW
  762. // 5 channels => RGBWW
  763. #ifndef LIGHT_SAVE_ENABLED
  764. #define LIGHT_SAVE_ENABLED 1 // Light channel values saved by default after each change
  765. #endif
  766. #ifndef LIGHT_COMMS_DELAY
  767. #define LIGHT_COMMS_DELAY 100 // Delay communication after light update (in ms)
  768. #endif
  769. #ifndef LIGHT_SAVE_DELAY
  770. #define LIGHT_SAVE_DELAY 5 // Persist color after 5 seconds to avoid wearing out
  771. #endif
  772. #ifndef LIGHT_MAX_PWM
  773. #if LIGHT_PROVIDER == LIGHT_PROVIDER_MY92XX
  774. #define LIGHT_MAX_PWM 255
  775. #endif
  776. #if LIGHT_PROVIDER == LIGHT_PROVIDER_DIMMER
  777. #define LIGHT_MAX_PWM 10000 // 10000 * 200ns => 2 kHz
  778. #endif
  779. #endif // LIGHT_MAX_PWM
  780. #ifndef LIGHT_LIMIT_PWM
  781. #define LIGHT_LIMIT_PWM LIGHT_MAX_PWM // Limit PWM to this value (prevent 100% power)
  782. #endif
  783. #ifndef LIGHT_MAX_VALUE
  784. #define LIGHT_MAX_VALUE 255 // Maximum light value
  785. #endif
  786. #ifndef LIGHT_MAX_BRIGHTNESS
  787. #define LIGHT_MAX_BRIGHTNESS 255 // Maximun brightness value
  788. #endif
  789. #define LIGHT_MIN_MIREDS 153 // Default to the Philips Hue value that HA also use.
  790. #define LIGHT_MAX_MIREDS 500 // https://developers.meethue.com/documentation/core-concepts
  791. #ifndef LIGHT_STEP
  792. #define LIGHT_STEP 32 // Step size
  793. #endif
  794. #ifndef LIGHT_USE_COLOR
  795. #define LIGHT_USE_COLOR 1 // Use 3 first channels as RGB
  796. #endif
  797. #ifndef LIGHT_USE_WHITE
  798. #define LIGHT_USE_WHITE 0 // Use the 4th channel as (Warm-)White LEDs
  799. #endif
  800. #ifndef LIGHT_USE_CCT
  801. #define LIGHT_USE_CCT 0 // Use the 5th channel as Coldwhite LEDs, LIGHT_USE_WHITE must be 1.
  802. #endif
  803. // Used when LIGHT_USE_WHITE AND LIGHT_USE_CCT is 1 - (1000000/Kelvin = MiReds)
  804. // Warning! Don't change this yet, NOT FULLY IMPLEMENTED!
  805. #define LIGHT_COLDWHITE_MIRED 153 // Coldwhite Strip, Value must be __BELOW__ W2!! (Default: 6535 Kelvin/153 MiRed)
  806. #define LIGHT_WARMWHITE_MIRED 500 // Warmwhite Strip, Value must be __ABOVE__ W1!! (Default: 2000 Kelvin/500 MiRed)
  807. #ifndef LIGHT_USE_GAMMA
  808. #define LIGHT_USE_GAMMA 0 // Use gamma correction for color channels
  809. #endif
  810. #ifndef LIGHT_USE_CSS
  811. #define LIGHT_USE_CSS 1 // Use CSS style to report colors (1=> "#FF0000", 0=> "255,0,0")
  812. #endif
  813. #ifndef LIGHT_USE_RGB
  814. #define LIGHT_USE_RGB 0 // Use RGB color selector (1=> RGB, 0=> HSV)
  815. #endif
  816. #ifndef LIGHT_WHITE_FACTOR
  817. #define LIGHT_WHITE_FACTOR 1 // When using LIGHT_USE_WHITE with uneven brightness LEDs,
  818. // this factor is used to scale the white channel to match brightness
  819. #endif
  820. #ifndef LIGHT_USE_TRANSITIONS
  821. #define LIGHT_USE_TRANSITIONS 1 // Transitions between colors
  822. #endif
  823. #ifndef LIGHT_TRANSITION_STEP
  824. #define LIGHT_TRANSITION_STEP 10 // Time in millis between each transtion step
  825. #endif
  826. #ifndef LIGHT_TRANSITION_TIME
  827. #define LIGHT_TRANSITION_TIME 500 // Time in millis from color to color
  828. #endif
  829. // -----------------------------------------------------------------------------
  830. // DOMOTICZ
  831. // -----------------------------------------------------------------------------
  832. #ifndef DOMOTICZ_SUPPORT
  833. #define DOMOTICZ_SUPPORT MQTT_SUPPORT // Build with domoticz (if MQTT) support (1.72Kb)
  834. #endif
  835. #define DOMOTICZ_ENABLED 0 // Disable domoticz by default
  836. #define DOMOTICZ_IN_TOPIC "domoticz/in" // Default subscription topic
  837. #define DOMOTICZ_OUT_TOPIC "domoticz/out" // Default publication topic
  838. // -----------------------------------------------------------------------------
  839. // HOME ASSISTANT
  840. // -----------------------------------------------------------------------------
  841. #ifndef HOMEASSISTANT_SUPPORT
  842. #define HOMEASSISTANT_SUPPORT MQTT_SUPPORT // Build with home assistant support (if MQTT, 1.64Kb)
  843. #endif
  844. #ifndef HOMEASSISTANT_ENABLED
  845. #define HOMEASSISTANT_ENABLED 0 // Integration not enabled by default
  846. #endif
  847. #ifndef HOMEASSISTANT_PREFIX
  848. #define HOMEASSISTANT_PREFIX "homeassistant" // Default MQTT prefix
  849. #endif
  850. #ifndef HOMEASSISTANT_PAYLOAD_ON
  851. #define HOMEASSISTANT_PAYLOAD_ON "1" // Payload for ON and available messages
  852. #endif
  853. #ifndef HOMEASSISTANT_PAYLOAD_OFF
  854. #define HOMEASSISTANT_PAYLOAD_OFF "0" // Payload for OFF and unavailable messages
  855. #endif
  856. #ifndef HOMEASSISTANT_PAYLOAD_AVAILABLE
  857. #define HOMEASSISTANT_PAYLOAD_AVAILABLE "1" // Payload for available messages
  858. #endif
  859. #ifndef HOMEASSISTANT_PAYLOAD_NOT_AVAILABLE
  860. #define HOMEASSISTANT_PAYLOAD_NOT_AVAILABLE "0" // Payload for available messages
  861. #endif
  862. // -----------------------------------------------------------------------------
  863. // INFLUXDB
  864. // -----------------------------------------------------------------------------
  865. #ifndef INFLUXDB_SUPPORT
  866. #define INFLUXDB_SUPPORT 0 // Disable InfluxDB support by default (4.38Kb)
  867. #endif
  868. #ifndef INFLUXDB_ENABLED
  869. #define INFLUXDB_ENABLED 0 // InfluxDB disabled by default
  870. #endif
  871. #ifndef INFLUXDB_HOST
  872. #define INFLUXDB_HOST "" // Default server
  873. #endif
  874. #ifndef INFLUXDB_PORT
  875. #define INFLUXDB_PORT 8086 // Default InfluxDB port
  876. #endif
  877. #ifndef INFLUXDB_DATABASE
  878. #define INFLUXDB_DATABASE "" // Default database
  879. #endif
  880. #ifndef INFLUXDB_USERNAME
  881. #define INFLUXDB_USERNAME "" // Default username
  882. #endif
  883. #ifndef INFLUXDB_PASSWORD
  884. #define INFLUXDB_PASSWORD "" // Default password
  885. #endif
  886. // -----------------------------------------------------------------------------
  887. // THINGSPEAK
  888. // -----------------------------------------------------------------------------
  889. #ifndef THINGSPEAK_SUPPORT
  890. #define THINGSPEAK_SUPPORT 1 // Enable Thingspeak support by default (2.56Kb)
  891. #endif
  892. #ifndef THINGSPEAK_ENABLED
  893. #define THINGSPEAK_ENABLED 0 // Thingspeak disabled by default
  894. #endif
  895. #ifndef THINGSPEAK_APIKEY
  896. #define THINGSPEAK_APIKEY "" // Default API KEY
  897. #endif
  898. #ifndef THINGSPEAK_CLEAR_CACHE
  899. #define THINGSPEAK_CLEAR_CACHE 1 // Clear cache after sending values
  900. // Not clearing it will result in latest values for each field being sent every time
  901. #endif
  902. #define THINGSPEAK_USE_ASYNC 1 // Use AsyncClient instead of WiFiClientSecure
  903. // THINGSPEAK OVER SSL
  904. // Using THINGSPEAK over SSL works well but generates problems with the web interface,
  905. // so you should compile it with WEB_SUPPORT to 0.
  906. // When THINGSPEAK_USE_ASYNC is 1, requires ASYNC_TCP_SSL_ENABLED to 1 and ESP8266 Arduino Core 2.4.0.
  907. #define THINGSPEAK_USE_SSL 0 // Use secure connection
  908. #define THINGSPEAK_FINGERPRINT "78 60 18 44 81 35 BF DF 77 84 D4 0A 22 0D 9B 4E 6C DC 57 2C"
  909. #define THINGSPEAK_HOST "api.thingspeak.com"
  910. #if THINGSPEAK_USE_SSL
  911. #define THINGSPEAK_PORT 443
  912. #else
  913. #define THINGSPEAK_PORT 80
  914. #endif
  915. #define THINGSPEAK_URL "/update"
  916. #define THINGSPEAK_MIN_INTERVAL 15000 // Minimum interval between POSTs (in millis)
  917. #define THINGSPEAK_FIELDS 8 // Number of fields
  918. #ifndef THINGSPEAK_TRIES
  919. #define THINGSPEAK_TRIES 3 // Number of tries when sending data (minimum 1)
  920. #endif
  921. // -----------------------------------------------------------------------------
  922. // SCHEDULER
  923. // -----------------------------------------------------------------------------
  924. #ifndef SCHEDULER_SUPPORT
  925. #define SCHEDULER_SUPPORT 1 // Enable scheduler (1.77Kb)
  926. #endif
  927. #ifndef SCHEDULER_MAX_SCHEDULES
  928. #define SCHEDULER_MAX_SCHEDULES 10 // Max schedules alowed
  929. #endif
  930. // -----------------------------------------------------------------------------
  931. // NTP
  932. // -----------------------------------------------------------------------------
  933. #ifndef NTP_SUPPORT
  934. #define NTP_SUPPORT 1 // Build with NTP support by default (6.78Kb)
  935. #endif
  936. #ifndef NTP_SERVER
  937. #define NTP_SERVER "pool.ntp.org" // Default NTP server
  938. #endif
  939. #ifndef NTP_TIMEOUT
  940. #define NTP_TIMEOUT 1000 // Set NTP request timeout to 2 seconds (issue #452)
  941. #endif
  942. #ifndef NTP_TIME_OFFSET
  943. #define NTP_TIME_OFFSET 60 // Default timezone offset (GMT+1)
  944. #endif
  945. #ifndef NTP_DAY_LIGHT
  946. #define NTP_DAY_LIGHT 1 // Enable daylight time saving by default
  947. #endif
  948. #ifndef NTP_SYNC_INTERVAL
  949. #define NTP_SYNC_INTERVAL 60 // NTP initial check every minute
  950. #endif
  951. #ifndef NTP_UPDATE_INTERVAL
  952. #define NTP_UPDATE_INTERVAL 1800 // NTP check every 30 minutes
  953. #endif
  954. #ifndef NTP_START_DELAY
  955. #define NTP_START_DELAY 1000 // Delay NTP start 1 second
  956. #endif
  957. #ifndef NTP_DST_REGION
  958. #define NTP_DST_REGION 0 // 0 for Europe, 1 for USA (defined in NtpClientLib)
  959. #endif
  960. #ifndef NTP_WAIT_FOR_SYNC
  961. #define NTP_WAIT_FOR_SYNC 1 // Do not report any datetime until NTP sync'ed
  962. #endif
  963. // -----------------------------------------------------------------------------
  964. // ALEXA
  965. // -----------------------------------------------------------------------------
  966. // This setting defines whether Alexa support should be built into the firmware
  967. #ifndef ALEXA_SUPPORT
  968. #define ALEXA_SUPPORT 1 // Enable Alexa support by default (10.84Kb)
  969. #endif
  970. // This is default value for the alexaEnabled setting that defines whether
  971. // this device should be discoberable and respond to Alexa commands.
  972. // Both ALEXA_SUPPORT and alexaEnabled should be 1 for Alexa support to work.
  973. #ifndef ALEXA_ENABLED
  974. #define ALEXA_ENABLED 1
  975. #endif
  976. #ifndef ALEXA_HOSTNAME
  977. #define ALEXA_HOSTNAME ""
  978. #endif
  979. // -----------------------------------------------------------------------------
  980. // MQTT RF BRIDGE
  981. // -----------------------------------------------------------------------------
  982. #ifndef RF_SUPPORT
  983. #define RF_SUPPORT 0
  984. #endif
  985. #ifndef RF_DEBOUNCE
  986. #define RF_DEBOUNCE 500
  987. #endif
  988. #ifndef RF_LEARN_TIMEOUT
  989. #define RF_LEARN_TIMEOUT 60000
  990. #endif
  991. #ifndef RF_SEND_TIMES
  992. #define RF_SEND_TIMES 4 // How many times to send the message
  993. #endif
  994. #ifndef RF_SEND_DELAY
  995. #define RF_SEND_DELAY 500 // Interval between sendings in ms
  996. #endif
  997. #ifndef RF_RECEIVE_DELAY
  998. #define RF_RECEIVE_DELAY 500 // Interval between recieving in ms (avoid debouncing)
  999. #endif
  1000. // Enable RCSwitch support
  1001. // Also possible to use with SONOFF RF BRIDGE, thanks to @wildwiz
  1002. // https://github.com/xoseperez/espurna/wiki/Hardware-Itead-Sonoff-RF-Bridge---Direct-Hack
  1003. #ifndef RFB_DIRECT
  1004. #define RFB_DIRECT 0
  1005. #endif
  1006. #ifndef RFB_RX_PIN
  1007. #define RFB_RX_PIN GPIO_NONE
  1008. #endif
  1009. #ifndef RFB_TX_PIN
  1010. #define RFB_TX_PIN GPIO_NONE
  1011. #endif
  1012. // -----------------------------------------------------------------------------
  1013. // IR Bridge
  1014. // -----------------------------------------------------------------------------
  1015. #ifndef IR_SUPPORT
  1016. #define IR_SUPPORT 0 // Do not build with IR support by default (10.25Kb)
  1017. #endif
  1018. //#define IR_RX_PIN 5 // GPIO the receiver is connected to
  1019. //#define IR_TX_PIN 4 // GPIO the transmitter is connected to
  1020. #ifndef IR_USE_RAW
  1021. #define IR_USE_RAW 0 // Use raw codes
  1022. #endif
  1023. #ifndef IR_BUFFER_SIZE
  1024. #define IR_BUFFER_SIZE 1024
  1025. #endif
  1026. #ifndef IR_TIMEOUT
  1027. #define IR_TIMEOUT 15U
  1028. #endif
  1029. #ifndef IR_REPEAT
  1030. #define IR_REPEAT 1
  1031. #endif
  1032. #ifndef IR_DELAY
  1033. #define IR_DELAY 100
  1034. #endif
  1035. #ifndef IR_DEBOUNCE
  1036. #define IR_DEBOUNCE 500 // IR debounce time in milliseconds
  1037. #endif
  1038. #ifndef IR_BUTTON_SET
  1039. #define IR_BUTTON_SET 0 // IR button set to use (see below)
  1040. #endif
  1041. // -----------------------------------------------------------------------------
  1042. // Remote Buttons SET 1 (for the original Remote shipped with the controller)
  1043. #if IR_BUTTON_SET == 1
  1044. /*
  1045. +------+------+------+------+
  1046. | UP | Down | OFF | ON |
  1047. +------+------+------+------+
  1048. | R | G | B | W |
  1049. +------+------+------+------+
  1050. | 1 | 2 | 3 |FLASH |
  1051. +------+------+------+------+
  1052. | 4 | 5 | 6 |STROBE|
  1053. +------+------+------+------+
  1054. | 7 | 8 | 9 | FADE |
  1055. +------+------+------+------+
  1056. | 10 | 11 | 12 |SMOOTH|
  1057. +------+------+------+------+
  1058. */
  1059. #define IR_BUTTON_COUNT 24
  1060. const uint32_t IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {
  1061. { 0xFF906F, IR_BUTTON_MODE_BRIGHTER, 1 },
  1062. { 0xFFB847, IR_BUTTON_MODE_BRIGHTER, 0 },
  1063. { 0xFFF807, IR_BUTTON_MODE_STATE, 0 },
  1064. { 0xFFB04F, IR_BUTTON_MODE_STATE, 1 },
  1065. { 0xFF9867, IR_BUTTON_MODE_RGB, 0xFF0000 },
  1066. { 0xFFD827, IR_BUTTON_MODE_RGB, 0x00FF00 },
  1067. { 0xFF8877, IR_BUTTON_MODE_RGB, 0x0000FF },
  1068. { 0xFFA857, IR_BUTTON_MODE_RGB, 0xFFFFFF },
  1069. { 0xFFE817, IR_BUTTON_MODE_RGB, 0xD13A01 },
  1070. { 0xFF48B7, IR_BUTTON_MODE_RGB, 0x00E644 },
  1071. { 0xFF6897, IR_BUTTON_MODE_RGB, 0x0040A7 },
  1072. { 0xFFB24D, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FLASH },
  1073. { 0xFF02FD, IR_BUTTON_MODE_RGB, 0xE96F2A },
  1074. { 0xFF32CD, IR_BUTTON_MODE_RGB, 0x00BEBF },
  1075. { 0xFF20DF, IR_BUTTON_MODE_RGB, 0x56406F },
  1076. { 0xFF00FF, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_STROBE },
  1077. { 0xFF50AF, IR_BUTTON_MODE_RGB, 0xEE9819 },
  1078. { 0xFF7887, IR_BUTTON_MODE_RGB, 0x00799A },
  1079. { 0xFF708F, IR_BUTTON_MODE_RGB, 0x944E80 },
  1080. { 0xFF58A7, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FADE },
  1081. { 0xFF38C7, IR_BUTTON_MODE_RGB, 0xFFFF00 },
  1082. { 0xFF28D7, IR_BUTTON_MODE_RGB, 0x0060A1 },
  1083. { 0xFFF00F, IR_BUTTON_MODE_RGB, 0xEF45AD },
  1084. { 0xFF30CF, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_SMOOTH }
  1085. };
  1086. #endif
  1087. //Remote Buttons SET 2 (another identical IR Remote shipped with another controller)
  1088. #if IR_BUTTON_SET == 2
  1089. /*
  1090. +------+------+------+------+
  1091. | UP | Down | OFF | ON |
  1092. +------+------+------+------+
  1093. | R | G | B | W |
  1094. +------+------+------+------+
  1095. | 1 | 2 | 3 |FLASH |
  1096. +------+------+------+------+
  1097. | 4 | 5 | 6 |STROBE|
  1098. +------+------+------+------+
  1099. | 7 | 8 | 9 | FADE |
  1100. +------+------+------+------+
  1101. | 10 | 11 | 12 |SMOOTH|
  1102. +------+------+------+------+
  1103. */
  1104. #define IR_BUTTON_COUNT 24
  1105. const unsigned long IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {
  1106. { 0xFF00FF, IR_BUTTON_MODE_BRIGHTER, 1 },
  1107. { 0xFF807F, IR_BUTTON_MODE_BRIGHTER, 0 },
  1108. { 0xFF40BF, IR_BUTTON_MODE_STATE, 0 },
  1109. { 0xFFC03F, IR_BUTTON_MODE_STATE, 1 },
  1110. { 0xFF20DF, IR_BUTTON_MODE_RGB, 0xFF0000 },
  1111. { 0xFFA05F, IR_BUTTON_MODE_RGB, 0x00FF00 },
  1112. { 0xFF609F, IR_BUTTON_MODE_RGB, 0x0000FF },
  1113. { 0xFFE01F, IR_BUTTON_MODE_RGB, 0xFFFFFF },
  1114. { 0xFF10EF, IR_BUTTON_MODE_RGB, 0xD13A01 },
  1115. { 0xFF906F, IR_BUTTON_MODE_RGB, 0x00E644 },
  1116. { 0xFF50AF, IR_BUTTON_MODE_RGB, 0x0040A7 },
  1117. { 0xFFD02F, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FLASH },
  1118. { 0xFF30CF, IR_BUTTON_MODE_RGB, 0xE96F2A },
  1119. { 0xFFB04F, IR_BUTTON_MODE_RGB, 0x00BEBF },
  1120. { 0xFF708F, IR_BUTTON_MODE_RGB, 0x56406F },
  1121. { 0xFFF00F, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_STROBE },
  1122. { 0xFF08F7, IR_BUTTON_MODE_RGB, 0xEE9819 },
  1123. { 0xFF8877, IR_BUTTON_MODE_RGB, 0x00799A },
  1124. { 0xFF48B7, IR_BUTTON_MODE_RGB, 0x944E80 },
  1125. { 0xFFC837, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FADE },
  1126. { 0xFF28D7, IR_BUTTON_MODE_RGB, 0xFFFF00 },
  1127. { 0xFFA857, IR_BUTTON_MODE_RGB, 0x0060A1 },
  1128. { 0xFF6897, IR_BUTTON_MODE_RGB, 0xEF45AD },
  1129. { 0xFFE817, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_SMOOTH }
  1130. };
  1131. #endif
  1132. //Remote Buttons SET 3 (samsung AA59-00608A 8 Toggle Buttons for generic 8CH module)
  1133. #if IR_BUTTON_SET == 3
  1134. /*
  1135. +------+------+------+
  1136. | 1 | 2 | 3 |
  1137. +------+------+------+
  1138. | 4 | 5 | 6 |
  1139. +------+------+------+
  1140. | 7 | 8 | 9 |
  1141. +------+------+------+
  1142. | | 0 | |
  1143. +------+------+------+
  1144. */
  1145. #define IR_BUTTON_COUNT 10
  1146. const unsigned long IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {
  1147. { 0xE0E020DF, IR_BUTTON_MODE_TOGGLE, 0 }, // Toggle Relay #0
  1148. { 0xE0E0A05F, IR_BUTTON_MODE_TOGGLE, 1 }, // Toggle Relay #1
  1149. { 0xE0E0609F, IR_BUTTON_MODE_TOGGLE, 2 }, // Toggle Relay #2
  1150. { 0xE0E010EF, IR_BUTTON_MODE_TOGGLE, 3 }, // Toggle Relay #3
  1151. { 0xE0E0906F, IR_BUTTON_MODE_TOGGLE, 4 }, // Toggle Relay #4
  1152. { 0xE0E050AF, IR_BUTTON_MODE_TOGGLE, 5 }, // Toggle Relay #5
  1153. { 0xE0E030CF, IR_BUTTON_MODE_TOGGLE, 6 }, // Toggle Relay #6
  1154. { 0xE0E0B04F, IR_BUTTON_MODE_TOGGLE, 7 } // Toggle Relay #7
  1155. //{ 0xE0E0708F, IR_BUTTON_MODE_TOGGLE, 8 } //Extra Button
  1156. //{ 0xE0E08877, IR_BUTTON_MODE_TOGGLE, 9 } //Extra Button
  1157. };
  1158. #endif
  1159. //Remote Buttons SET 4
  1160. #if IR_BUTTON_SET == 4
  1161. /*
  1162. +------+------+------+
  1163. | OFF | SRC | MUTE |
  1164. +------+------+------+
  1165. ...
  1166. +------+------+------+
  1167. */
  1168. #define IR_BUTTON_COUNT 1
  1169. const unsigned long IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {
  1170. { 0xFFB24D, IR_BUTTON_MODE_TOGGLE, 0 } // Toggle Relay #0
  1171. };
  1172. #endif
  1173. #ifndef IR_BUTTON_COUNT
  1174. #define IR_BUTTON_COUNT 0
  1175. #endif
  1176. //--------------------------------------------------------------------------------
  1177. // Custom RFM69 to MQTT bridge
  1178. // Check http://tinkerman.cat/rfm69-wifi-gateway/
  1179. // Enable support by passing RFM69_SUPPORT=1 build flag
  1180. //--------------------------------------------------------------------------------
  1181. #ifndef RFM69_SUPPORT
  1182. #define RFM69_SUPPORT 0
  1183. #endif
  1184. #ifndef RFM69_MAX_TOPICS
  1185. #define RFM69_MAX_TOPICS 50
  1186. #endif
  1187. #ifndef RFM69_MAX_NODES
  1188. #define RFM69_MAX_NODES 255
  1189. #endif
  1190. #ifndef RFM69_DEFAULT_TOPIC
  1191. #define RFM69_DEFAULT_TOPIC "/rfm69gw/{node}/{key}"
  1192. #endif
  1193. #ifndef RFM69_NODE_ID
  1194. #define RFM69_NODE_ID 1
  1195. #endif
  1196. #ifndef RFM69_GATEWAY_ID
  1197. #define RFM69_GATEWAY_ID 1
  1198. #endif
  1199. #ifndef RFM69_NETWORK_ID
  1200. #define RFM69_NETWORK_ID 164
  1201. #endif
  1202. #ifndef RFM69_PROMISCUOUS
  1203. #define RFM69_PROMISCUOUS 0
  1204. #endif
  1205. #ifndef RFM69_PROMISCUOUS_SENDS
  1206. #define RFM69_PROMISCUOUS_SENDS 0
  1207. #endif
  1208. #ifndef RFM69_FREQUENCY
  1209. #define RFM69_FREQUENCY RF69_868MHZ
  1210. #endif
  1211. #ifndef RFM69_ENCRYPTKEY
  1212. #define RFM69_ENCRYPTKEY "fibonacci0123456"
  1213. #endif
  1214. #ifndef RFM69_CS_PIN
  1215. #define RFM69_CS_PIN SS
  1216. #endif
  1217. #ifndef RFM69_IRQ_PIN
  1218. #define RFM69_IRQ_PIN 5
  1219. #endif
  1220. #ifndef RFM69_RESET_PIN
  1221. #define RFM69_RESET_PIN 7
  1222. #endif
  1223. #ifndef RFM69_IS_RFM69HW
  1224. #define RFM69_IS_RFM69HW 0
  1225. #endif