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.

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