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.

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