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.

1554 lines
50 KiB

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