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.

1145 lines
38 KiB

7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
6 years ago
7 years ago
7 years ago
8 years ago
8 years ago
6 years ago
6 years ago
8 years ago
8 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
8 years ago
8 years ago
6 years ago
6 years ago
  1. //------------------------------------------------------------------------------
  2. // Do not change this file unless you know what you are doing
  3. // Configuration settings are in the settings.h file
  4. //------------------------------------------------------------------------------
  5. //------------------------------------------------------------------------------
  6. // GENERAL
  7. //------------------------------------------------------------------------------
  8. #define DEVICE_NAME MANUFACTURER "_" DEVICE // Concatenate both to get a unique device name
  9. #ifndef ADMIN_PASS
  10. #define ADMIN_PASS "fibonacci" // Default password (WEB, OTA, WIFI)
  11. #endif
  12. #ifndef USE_PASSWORD
  13. #define USE_PASSWORD 1 // Insecurity caution! Disabling this will disable password querying completely.
  14. #endif
  15. #ifndef LOOP_DELAY_TIME
  16. #define LOOP_DELAY_TIME 10 // Delay for this millis in the main loop [0-250]
  17. #endif
  18. //------------------------------------------------------------------------------
  19. // TELNET
  20. //------------------------------------------------------------------------------
  21. #ifndef TELNET_SUPPORT
  22. #define TELNET_SUPPORT 1 // Enable telnet support by default (3.34Kb)
  23. #endif
  24. #ifndef TELNET_STA
  25. #define TELNET_STA 0 // By default, disallow connections via STA interface
  26. #endif
  27. #define TELNET_PORT 23 // Port to listen to telnet clients
  28. #define TELNET_MAX_CLIENTS 1 // Max number of concurrent telnet clients
  29. //------------------------------------------------------------------------------
  30. // DEBUG
  31. //------------------------------------------------------------------------------
  32. // Serial debug log
  33. #ifndef DEBUG_SERIAL_SUPPORT
  34. #define DEBUG_SERIAL_SUPPORT 1 // Enable serial debug log
  35. #endif
  36. #ifndef DEBUG_PORT
  37. #define DEBUG_PORT Serial // Default debugging port
  38. #endif
  39. #ifndef SERIAL_BAUDRATE
  40. #define SERIAL_BAUDRATE 115200 // Default baudrate
  41. #endif
  42. #ifndef DEBUG_ADD_TIMESTAMP
  43. #define DEBUG_ADD_TIMESTAMP 1 // Add timestamp to debug messages
  44. // (in millis overflowing every 1000 seconds)
  45. #endif
  46. // Second serial port (used for RX)
  47. #ifndef SERIAL_RX_ENABLED
  48. #define SERIAL_RX_ENABLED 0 // Secondary serial port for RX
  49. #endif
  50. #ifndef SERIAL_RX_PORT
  51. #define SERIAL_RX_PORT Serial // This setting is usually defined
  52. // in the hardware.h file for those
  53. // boards that require it
  54. #endif
  55. #ifndef SERIAL_RX_BAUDRATE
  56. #define SERIAL_RX_BAUDRATE 115200 // Default baudrate
  57. #endif
  58. //------------------------------------------------------------------------------
  59. // UDP debug log
  60. // To receive the message son the destination computer use nc:
  61. // nc -ul 8113
  62. #ifndef DEBUG_UDP_SUPPORT
  63. #define DEBUG_UDP_SUPPORT 0 // Enable UDP debug log
  64. #endif
  65. #ifndef DEBUG_UDP_IP
  66. #define DEBUG_UDP_IP IPAddress(192, 168, 1, 100)
  67. #endif
  68. #ifndef DEBUG_UDP_PORT
  69. #define DEBUG_UDP_PORT 8113
  70. #endif
  71. //------------------------------------------------------------------------------
  72. #ifndef DEBUG_TELNET_SUPPORT
  73. #define DEBUG_TELNET_SUPPORT TELNET_SUPPORT // Enable telnet debug log if telnet is enabled too
  74. #endif
  75. #ifndef DEBUG_UDP_SUPPORT
  76. #define DEBUG_UDP_SUPPORT 0 // Enable UDP debug log
  77. #endif
  78. #define DEBUG_UDP_IP IPAddress(192, 168, 1, 100)
  79. #define DEBUG_UDP_PORT 8113
  80. #ifndef DEBUG_WEB_ENABLED
  81. #define DEBUG_WEB_ENABLED 1 // Enable debug output by default
  82. #endif
  83. //------------------------------------------------------------------------------
  84. // General debug options and macros
  85. #define DEBUG_SUPPORT DEBUG_SERIAL_SUPPORT || DEBUG_UDP_SUPPORT || DEBUG_TELNET_SUPPORT
  86. //------------------------------------------------------------------------------
  87. // TERMINAL
  88. //------------------------------------------------------------------------------
  89. #ifndef TERMINAL_SUPPORT
  90. #define TERMINAL_SUPPORT 1 // Enable terminal commands (0.97Kb)
  91. #endif
  92. #define TERMINAL_BUFFER_SIZE 128 // Max size for commands commands
  93. //------------------------------------------------------------------------------
  94. // SYSTEM CHECK
  95. //------------------------------------------------------------------------------
  96. #ifndef SYSTEM_CHECK_ENABLED
  97. #define SYSTEM_CHECK_ENABLED 1 // Enable crash check by default
  98. #endif
  99. #define SYSTEM_CHECK_TIME 60000 // The system is considered stable after these many millis
  100. #ifndef SYSTEM_CHECK_MAX
  101. #define SYSTEM_CHECK_MAX 5 // After this many crashes on boot
  102. // the system is flagged as unstable
  103. #endif
  104. //------------------------------------------------------------------------------
  105. // EEPROM
  106. //------------------------------------------------------------------------------
  107. #define EEPROM_SIZE 4096 // EEPROM size in bytes
  108. #define EEPROM_RELAY_STATUS 0 // Address for the relay status (1 byte)
  109. #define EEPROM_ENERGY_COUNT 1 // Address for the energy counter (4 bytes)
  110. #define EEPROM_CUSTOM_RESET 5 // Address for the reset reason (1 byte)
  111. #define EEPROM_CRASH_COUNTER 6 // Address for the crash counter (1 byte)
  112. #define EEPROM_MESSAGE_ID 7 // Address for the MQTT message id (4 bytes)
  113. #define EEPROM_DATA_END 11 // End of custom EEPROM data block
  114. //------------------------------------------------------------------------------
  115. // HEARTBEAT
  116. //------------------------------------------------------------------------------
  117. #ifndef HEARTBEAT_ENABLED
  118. #define HEARTBEAT_ENABLED 1
  119. #endif
  120. #define HEARTBEAT_INTERVAL 300000 // Interval between heartbeat messages (in ms)
  121. #define UPTIME_OVERFLOW 4294967295 // Uptime overflow value
  122. // Topics that will be reported in heartbeat
  123. #define HEARTBEAT_REPORT_STATUS 1
  124. #define HEARTBEAT_REPORT_IP 1
  125. #define HEARTBEAT_REPORT_MAC 1
  126. #define HEARTBEAT_REPORT_RSSI 1
  127. #define HEARTBEAT_REPORT_UPTIME 1
  128. #define HEARTBEAT_REPORT_DATETIME 1
  129. #define HEARTBEAT_REPORT_FREEHEAP 1
  130. #define HEARTBEAT_REPORT_VCC 1
  131. #define HEARTBEAT_REPORT_RELAY 1
  132. #define HEARTBEAT_REPORT_LIGHT 1
  133. #define HEARTBEAT_REPORT_HOSTNAME 1
  134. #define HEARTBEAT_REPORT_APP 1
  135. #define HEARTBEAT_REPORT_VERSION 1
  136. #define HEARTBEAT_REPORT_BOARD 1
  137. #define HEARTBEAT_REPORT_INTERVAL 0
  138. //------------------------------------------------------------------------------
  139. // Load average
  140. //------------------------------------------------------------------------------
  141. #ifndef LOADAVG_INTERVAL
  142. #define LOADAVG_INTERVAL 30000 // Interval between calculating load average (in ms)
  143. #endif
  144. #ifndef LOADAVG_REPORT
  145. #define LOADAVG_REPORT 1 // Should we report Load average over MQTT?
  146. #endif
  147. //------------------------------------------------------------------------------
  148. // BUTTON
  149. //------------------------------------------------------------------------------
  150. #ifndef BUTTON_DEBOUNCE_DELAY
  151. #define BUTTON_DEBOUNCE_DELAY 50 // Debounce delay (ms)
  152. #endif
  153. #ifndef BUTTON_DBLCLICK_DELAY
  154. #define BUTTON_DBLCLICK_DELAY 500 // Time in ms to wait for a second (or third...) click
  155. #endif
  156. #ifndef BUTTON_LNGCLICK_DELAY
  157. #define BUTTON_LNGCLICK_DELAY 1000 // Time in ms holding the button down to get a long click
  158. #endif
  159. #ifndef BUTTON_LNGLNGCLICK_DELAY
  160. #define BUTTON_LNGLNGCLICK_DELAY 10000 // Time in ms holding the button down to get a long-long click
  161. #endif
  162. //------------------------------------------------------------------------------
  163. // RELAY
  164. //------------------------------------------------------------------------------
  165. // Default boot mode: 0 means OFF, 1 ON and 2 whatever was before
  166. #ifndef RELAY_BOOT_MODE
  167. #define RELAY_BOOT_MODE RELAY_BOOT_OFF
  168. #endif
  169. // 0 means ANY, 1 zero or one and 2 one and only one
  170. #ifndef RELAY_SYNC
  171. #define RELAY_SYNC RELAY_SYNC_ANY
  172. #endif
  173. // Default pulse mode: 0 means no pulses, 1 means normally off, 2 normally on
  174. #ifndef RELAY_PULSE_MODE
  175. #define RELAY_PULSE_MODE RELAY_PULSE_NONE
  176. #endif
  177. // Default pulse time in seconds
  178. #ifndef RELAY_PULSE_TIME
  179. #define RELAY_PULSE_TIME 1.0
  180. #endif
  181. // Relay requests flood protection window - in seconds
  182. #ifndef RELAY_FLOOD_WINDOW
  183. #define RELAY_FLOOD_WINDOW 3
  184. #endif
  185. // Allowed actual relay changes inside requests flood protection window
  186. #ifndef RELAY_FLOOD_CHANGES
  187. #define RELAY_FLOOD_CHANGES 5
  188. #endif
  189. // Pulse with in milliseconds for a latched relay
  190. #ifndef RELAY_LATCHING_PULSE
  191. #define RELAY_LATCHING_PULSE 10
  192. #endif
  193. // Do not save relay state after these many milliseconds
  194. #ifndef RELAY_SAVE_DELAY
  195. #define RELAY_SAVE_DELAY 1000
  196. #endif
  197. // -----------------------------------------------------------------------------
  198. // WIFI
  199. // -----------------------------------------------------------------------------
  200. #ifndef WIFI_CONNECT_TIMEOUT
  201. #define WIFI_CONNECT_TIMEOUT 60000 // Connecting timeout for WIFI in ms
  202. #endif
  203. #ifndef WIFI_RECONNECT_INTERVAL
  204. #define WIFI_RECONNECT_INTERVAL 180000 // If could not connect to WIFI, retry after this time in ms
  205. #endif
  206. #define WIFI_MAX_NETWORKS 5 // Max number of WIFI connection configurations
  207. #ifndef WIFI_AP_MODE
  208. #define WIFI_AP_MODE AP_MODE_ALONE
  209. #endif
  210. #ifndef WIFI_SLEEP_MODE
  211. #define WIFI_SLEEP_MODE WIFI_NONE_SLEEP // WIFI_NONE_SLEEP, WIFI_LIGHT_SLEEP or WIFI_MODEM_SLEEP
  212. #endif
  213. #ifndef WIFI_SCAN_NETWORKS
  214. #define WIFI_SCAN_NETWORKS 1 // Perform a network scan before connecting
  215. #endif
  216. // Optional hardcoded configuration (up to 2 networks)
  217. #ifndef WIFI1_SSID
  218. #define WIFI1_SSID ""
  219. #endif
  220. #ifndef WIFI1_PASS
  221. #define WIFI1_PASS ""
  222. #endif
  223. #ifndef WIFI1_IP
  224. #define WIFI1_IP ""
  225. #endif
  226. #ifndef WIFI1_GW
  227. #define WIFI1_GW ""
  228. #endif
  229. #ifndef WIFI1_MASK
  230. #define WIFI1_MASK ""
  231. #endif
  232. #ifndef WIFI1_DNS
  233. #define WIFI1_DNS ""
  234. #endif
  235. #ifndef WIFI2_SSID
  236. #define WIFI2_SSID ""
  237. #endif
  238. #ifndef WIFI2_PASS
  239. #define WIFI2_PASS ""
  240. #endif
  241. #ifndef WIFI2_IP
  242. #define WIFI2_IP ""
  243. #endif
  244. #ifndef WIFI2_GW
  245. #define WIFI2_GW ""
  246. #endif
  247. #ifndef WIFI2_MASK
  248. #define WIFI2_MASK ""
  249. #endif
  250. #ifndef WIFI2_DNS
  251. #define WIFI2_DNS ""
  252. #endif
  253. #ifndef WIFI_RSSI_1M
  254. #define WIFI_RSSI_1M -30 // Calibrate it with your router reading the RSSI at 1m
  255. #endif
  256. #ifndef WIFI_PROPAGATION_CONST
  257. #define WIFI_PROPAGATION_CONST 4 // This is typically something between 2.7 to 4.3 (free space is 2)
  258. #endif
  259. // -----------------------------------------------------------------------------
  260. // WEB
  261. // -----------------------------------------------------------------------------
  262. #ifndef WEB_SUPPORT
  263. #define WEB_SUPPORT 1 // Enable web support (http, api, 121.65Kb)
  264. #endif
  265. #ifndef WEB_EMBEDDED
  266. #define WEB_EMBEDDED 1 // Build the firmware with the web interface embedded in
  267. #endif
  268. // This is not working at the moment!!
  269. // Requires ASYNC_TCP_SSL_ENABLED to 1 and ESP8266 Arduino Core 2.4.0
  270. #ifndef WEB_SSL_ENABLED
  271. #define WEB_SSL_ENABLED 0 // Use HTTPS web interface
  272. #endif
  273. #define WEB_MODE_NORMAL 0
  274. #define WEB_MODE_PASSWORD 1
  275. #ifndef WEB_USERNAME
  276. #define WEB_USERNAME "admin" // HTTP username
  277. #endif
  278. #ifndef WEB_FORCE_PASS_CHANGE
  279. #define WEB_FORCE_PASS_CHANGE 1 // Force the user to change the password if default one
  280. #endif
  281. #ifndef WEB_PORT
  282. #define WEB_PORT 80 // HTTP port
  283. #endif
  284. // -----------------------------------------------------------------------------
  285. // WEBSOCKETS
  286. // -----------------------------------------------------------------------------
  287. // This will only be enabled if WEB_SUPPORT is 1 (this is the default value)
  288. #ifndef WS_AUTHENTICATION
  289. #define WS_AUTHENTICATION 1 // WS authentication ON by default (see #507)
  290. #endif
  291. #ifndef WS_BUFFER_SIZE
  292. #define WS_BUFFER_SIZE 5 // Max number of secured websocket connections
  293. #endif
  294. #ifndef WS_TIMEOUT
  295. #define WS_TIMEOUT 1800000 // Timeout for secured websocket
  296. #endif
  297. #ifndef WS_UPDATE_INTERVAL
  298. #define WS_UPDATE_INTERVAL 30000 // Update clients every 30 seconds
  299. #endif
  300. // -----------------------------------------------------------------------------
  301. // API
  302. // -----------------------------------------------------------------------------
  303. // This will only be enabled if WEB_SUPPORT is 1 (this is the default value)
  304. #ifndef API_ENABLED
  305. #define API_ENABLED 0 // Do not enable API by default
  306. #endif
  307. #ifndef API_BUFFER_SIZE
  308. #define API_BUFFER_SIZE 15 // Size of the buffer for HTTP GET API responses
  309. #endif
  310. #ifndef API_REAL_TIME_VALUES
  311. #define API_REAL_TIME_VALUES 0 // Show filtered/median values by default (0 => median, 1 => real time)
  312. #endif
  313. // -----------------------------------------------------------------------------
  314. // MDNS / LLMNR / NETBIOS / SSDP
  315. // -----------------------------------------------------------------------------
  316. #ifndef MDNS_SERVER_SUPPORT
  317. #define MDNS_SERVER_SUPPORT 1 // Publish services using mDNS by default (1.48Kb)
  318. #endif
  319. #ifndef MDNS_CLIENT_SUPPORT
  320. #define MDNS_CLIENT_SUPPORT 0 // Resolve mDNS names (3.44Kb)
  321. #endif
  322. #ifndef LLMNR_SUPPORT
  323. #define LLMNR_SUPPORT 0 // Publish device using LLMNR protocol by default (1.95Kb) - requires 2.4.0
  324. #endif
  325. #ifndef NETBIOS_SUPPORT
  326. #define NETBIOS_SUPPORT 0 // Publish device using NetBIOS protocol by default (1.26Kb) - requires 2.4.0
  327. #endif
  328. #ifndef SSDP_SUPPORT
  329. #define SSDP_SUPPORT 0 // Publish device using SSDP protocol by default (4.59Kb)
  330. // Not compatible with ALEXA_SUPPORT at the moment
  331. #endif
  332. #ifndef SSDP_DEVICE_TYPE
  333. #define SSDP_DEVICE_TYPE "upnp:rootdevice"
  334. //#define SSDP_DEVICE_TYPE "urn:schemas-upnp-org:device:BinaryLight:1"
  335. #endif
  336. // -----------------------------------------------------------------------------
  337. // SPIFFS
  338. // -----------------------------------------------------------------------------
  339. #ifndef SPIFFS_SUPPORT
  340. #define SPIFFS_SUPPORT 0 // Do not add support for SPIFFS by default
  341. #endif
  342. // -----------------------------------------------------------------------------
  343. // OTA
  344. // -----------------------------------------------------------------------------
  345. #ifndef OTA_PORT
  346. #define OTA_PORT 8266 // OTA port
  347. #endif
  348. #define OTA_GITHUB_FP "D7:9F:07:61:10:B3:92:93:E3:49:AC:89:84:5B:03:80:C1:9E:2F:8B"
  349. // -----------------------------------------------------------------------------
  350. // NOFUSS
  351. // -----------------------------------------------------------------------------
  352. #ifndef NOFUSS_SUPPORT
  353. #define NOFUSS_SUPPORT 0 // Do not enable support for NoFuss by default (12.65Kb)
  354. #endif
  355. #ifndef NOFUSS_ENABLED
  356. #define NOFUSS_ENABLED 0 // Do not perform NoFUSS updates by default
  357. #endif
  358. #ifndef NOFUSS_SERVER
  359. #define NOFUSS_SERVER "" // Default NoFuss Server
  360. #endif
  361. #ifndef NOFUSS_INTERVAL
  362. #define NOFUSS_INTERVAL 3600000 // Check for updates every hour
  363. #endif
  364. // -----------------------------------------------------------------------------
  365. // UART <-> MQTT
  366. // -----------------------------------------------------------------------------
  367. #ifndef UART_MQTT_SUPPORT
  368. #define UART_MQTT_SUPPORT 0 // No support by default
  369. #endif
  370. #ifndef UART_MQTT_USE_SOFT
  371. #define UART_MQTT_USE_SOFT 0 // Use SoftwareSerial
  372. #endif
  373. #ifndef UART_MQTT_HW_PORT
  374. #define UART_MQTT_HW_PORT Serial // Hardware serial port (if UART_MQTT_USE_SOFT == 0)
  375. #endif
  376. #ifndef UART_MQTT_RX_PIN
  377. #define UART_MQTT_RX_PIN 4 // RX PIN (if UART_MQTT_USE_SOFT == 1)
  378. #endif
  379. #ifndef UART_MQTT_TX_PIN
  380. #define UART_MQTT_TX_PIN 5 // TX PIN (if UART_MQTT_USE_SOFT == 1)
  381. #endif
  382. #ifndef UART_MQTT_BAUDRATE
  383. #define UART_MQTT_BAUDRATE 115200 // Serial speed
  384. #endif
  385. #define UART_MQTT_BUFFER_SIZE 100 // UART buffer size
  386. // -----------------------------------------------------------------------------
  387. // MQTT
  388. // -----------------------------------------------------------------------------
  389. #ifndef MQTT_SUPPORT
  390. #define MQTT_SUPPORT 1 // MQTT support (22.38Kb async, 12.48Kb sync)
  391. #endif
  392. #ifndef MQTT_USE_ASYNC
  393. #define MQTT_USE_ASYNC 1 // Use AysncMQTTClient (1) or PubSubClient (0)
  394. #endif
  395. // MQTT OVER SSL
  396. // Using MQTT over SSL works pretty well but generates problems with the web interface.
  397. // It could be a good idea to use it in conjuntion with WEB_SUPPORT=0.
  398. // Requires ASYNC_TCP_SSL_ENABLED to 1 and ESP8266 Arduino Core 2.4.0.
  399. //
  400. // You can use SSL with MQTT_USE_ASYNC=1 (AsyncMqttClient library)
  401. // but you might experience hiccups on the web interface, so my recommendation is:
  402. // WEB_SUPPORT=0
  403. //
  404. // If you use SSL with MQTT_USE_ASYNC=0 (PubSubClient library)
  405. // you will have to disable all the modules that use ESPAsyncTCP, that is:
  406. // ALEXA_SUPPORT=0, INFLUXDB_SUPPORT=0, TELNET_SUPPORT=0, THINGSPEAK_SUPPORT=0 and WEB_SUPPORT=0
  407. //
  408. // You will need the fingerprint for your MQTT server, example for CloudMQTT:
  409. // $ echo -n | openssl s_client -connect m11.cloudmqtt.com:24055 > cloudmqtt.pem
  410. // $ openssl x509 -noout -in cloudmqtt.pem -fingerprint -sha1
  411. #ifndef MQTT_SSL_ENABLED
  412. #define MQTT_SSL_ENABLED 0 // By default MQTT over SSL will not be enabled
  413. #endif
  414. #ifndef MQTT_SSL_FINGERPRINT
  415. #define MQTT_SSL_FINGERPRINT "" // SSL fingerprint of the server
  416. #endif
  417. #ifndef MQTT_ENABLED
  418. #define MQTT_ENABLED 0 // Do not enable MQTT connection by default
  419. #endif
  420. #ifndef MQTT_AUTOCONNECT
  421. #define MQTT_AUTOCONNECT 1 // If enabled and MDNS_SERVER_SUPPORT=1 will perform an autodiscover and
  422. #endif
  423. // autoconnect to the first MQTT broker found if none defined
  424. #ifndef MQTT_SERVER
  425. #define MQTT_SERVER "" // Default MQTT broker address
  426. #endif
  427. #ifndef MQTT_USER
  428. #define MQTT_USER "" // Default MQTT broker usename
  429. #endif
  430. #ifndef MQTT_PASS
  431. #define MQTT_PASS "" // Default MQTT broker password
  432. #endif
  433. #ifndef MQTT_PORT
  434. #define MQTT_PORT 1883 // MQTT broker port
  435. #endif
  436. #ifndef MQTT_TOPIC
  437. #define MQTT_TOPIC "{hostname}" // Default MQTT base topic
  438. #endif
  439. #ifndef MQTT_RETAIN
  440. #define MQTT_RETAIN true // MQTT retain flag
  441. #endif
  442. #ifndef MQTT_QOS
  443. #define MQTT_QOS 0 // MQTT QoS value for all messages
  444. #endif
  445. #ifndef MQTT_KEEPALIVE
  446. #define MQTT_KEEPALIVE 30 // MQTT keepalive value
  447. #endif
  448. #ifndef MQTT_RECONNECT_DELAY_MIN
  449. #define MQTT_RECONNECT_DELAY_MIN 5000 // Try to reconnect in 5 seconds upon disconnection
  450. #endif
  451. #ifndef MQTT_RECONNECT_DELAY_STEP
  452. #define MQTT_RECONNECT_DELAY_STEP 5000 // Increase the reconnect delay in 5 seconds after each failed attempt
  453. #endif
  454. #ifndef MQTT_RECONNECT_DELAY_MAX
  455. #define MQTT_RECONNECT_DELAY_MAX 120000 // Set reconnect time to 2 minutes at most
  456. #endif
  457. #ifndef MQTT_SKIP_RETAINED
  458. #define MQTT_SKIP_RETAINED 1 // Skip retained messages on connection
  459. #endif
  460. #ifndef MQTT_SKIP_TIME
  461. #define MQTT_SKIP_TIME 1000 // Skip messages for 1 second anter connection
  462. #endif
  463. #ifndef MQTT_USE_JSON
  464. #define MQTT_USE_JSON 0 // Group messages in a JSON body
  465. #endif
  466. #ifndef MQTT_USE_JSON_DELAY
  467. #define MQTT_USE_JSON_DELAY 100 // Wait this many ms before grouping messages
  468. #endif
  469. #ifndef MQTT_QUEUE_MAX_SIZE
  470. #define MQTT_QUEUE_MAX_SIZE 20 // Size of the MQTT queue when MQTT_USE_JSON is enabled
  471. #endif
  472. // These are the properties that will be sent when useJson is true
  473. #ifndef MQTT_ENQUEUE_IP
  474. #define MQTT_ENQUEUE_IP 1
  475. #endif
  476. #ifndef MQTT_ENQUEUE_MAC
  477. #define MQTT_ENQUEUE_MAC 1
  478. #endif
  479. #ifndef MQTT_ENQUEUE_HOSTNAME
  480. #define MQTT_ENQUEUE_HOSTNAME 1
  481. #endif
  482. #ifndef MQTT_ENQUEUE_DATETIME
  483. #define MQTT_ENQUEUE_DATETIME 1
  484. #endif
  485. #ifndef MQTT_ENQUEUE_MESSAGE_ID
  486. #define MQTT_ENQUEUE_MESSAGE_ID 1
  487. #endif
  488. // These particles will be concatenated to the MQTT_TOPIC base to form the actual topic
  489. #define MQTT_TOPIC_JSON "data"
  490. #define MQTT_TOPIC_ACTION "action"
  491. #define MQTT_TOPIC_RELAY "relay"
  492. #define MQTT_TOPIC_LED "led"
  493. #define MQTT_TOPIC_BUTTON "button"
  494. #define MQTT_TOPIC_IP "ip"
  495. #define MQTT_TOPIC_VERSION "version"
  496. #define MQTT_TOPIC_UPTIME "uptime"
  497. #define MQTT_TOPIC_DATETIME "datetime"
  498. #define MQTT_TOPIC_FREEHEAP "freeheap"
  499. #define MQTT_TOPIC_VCC "vcc"
  500. #define MQTT_TOPIC_STATUS "status"
  501. #define MQTT_TOPIC_MAC "mac"
  502. #define MQTT_TOPIC_RSSI "rssi"
  503. #define MQTT_TOPIC_MESSAGE_ID "id"
  504. #define MQTT_TOPIC_APP "app"
  505. #define MQTT_TOPIC_INTERVAL "interval"
  506. #define MQTT_TOPIC_HOSTNAME "host"
  507. #define MQTT_TOPIC_TIME "time"
  508. #define MQTT_TOPIC_RFOUT "rfout"
  509. #define MQTT_TOPIC_RFIN "rfin"
  510. #define MQTT_TOPIC_RFLEARN "rflearn"
  511. #define MQTT_TOPIC_RFRAW "rfraw"
  512. #define MQTT_TOPIC_UARTIN "uartin"
  513. #define MQTT_TOPIC_UARTOUT "uartout"
  514. #define MQTT_TOPIC_LOADAVG "loadavg"
  515. #define MQTT_TOPIC_BOARD "board"
  516. // Light module
  517. #define MQTT_TOPIC_CHANNEL "channel"
  518. #define MQTT_TOPIC_COLOR_RGB "rgb"
  519. #define MQTT_TOPIC_COLOR_HSV "hsv"
  520. #define MQTT_TOPIC_ANIM_MODE "anim_mode"
  521. #define MQTT_TOPIC_ANIM_SPEED "anim_speed"
  522. #define MQTT_TOPIC_BRIGHTNESS "brightness"
  523. #define MQTT_TOPIC_MIRED "mired"
  524. #define MQTT_TOPIC_KELVIN "kelvin"
  525. #define MQTT_STATUS_ONLINE "1" // Value for the device ON message
  526. #define MQTT_STATUS_OFFLINE "0" // Value for the device OFF message (will)
  527. #define MQTT_ACTION_RESET "reboot" // RESET MQTT topic particle
  528. // Internal MQTT events (do not change)
  529. #define MQTT_CONNECT_EVENT 0
  530. #define MQTT_DISCONNECT_EVENT 1
  531. #define MQTT_MESSAGE_EVENT 2
  532. #define MQTT_MESSAGE_ID_SHIFT 1000 // Store MQTT message id into EEPROM every these many
  533. // Custom get and set postfixes
  534. // Use something like "/status" or "/set", with leading slash
  535. // Since 1.9.0 the default value is "" for getter and "/set" for setter
  536. #ifndef MQTT_GETTER
  537. #define MQTT_GETTER ""
  538. #endif
  539. #ifndef MQTT_SETTER
  540. #define MQTT_SETTER "/set"
  541. #endif
  542. // -----------------------------------------------------------------------------
  543. // BROKER
  544. // -----------------------------------------------------------------------------
  545. #ifndef BROKER_SUPPORT
  546. #define BROKER_SUPPORT 1 // The broker is a poor-man's pubsub manager
  547. #endif
  548. // -----------------------------------------------------------------------------
  549. // SETTINGS
  550. // -----------------------------------------------------------------------------
  551. #ifndef SETTINGS_AUTOSAVE
  552. #define SETTINGS_AUTOSAVE 1 // Autosave settings o force manual commit
  553. #endif
  554. #define SETTINGS_MAX_LIST_COUNT 10 // Maximum index for settings lists
  555. // -----------------------------------------------------------------------------
  556. // LIGHT
  557. // -----------------------------------------------------------------------------
  558. // LIGHT_PROVIDER_DIMMER can have from 1 to 5 different channels.
  559. // They have to be defined for each device in the hardware.h file.
  560. // If 3 or more channels first 3 will be considered RGB.
  561. // Usual configurations are:
  562. // 1 channels => W
  563. // 2 channels => WW
  564. // 3 channels => RGB
  565. // 4 channels => RGBW
  566. // 5 channels => RGBWW
  567. #ifndef LIGHT_SAVE_ENABLED
  568. #define LIGHT_SAVE_ENABLED 1 // Light channel values saved by default after each change
  569. #endif
  570. #ifndef LIGHT_SAVE_DELAY
  571. #define LIGHT_SAVE_DELAY 5 // Persist color after 5 seconds to avoid wearing out
  572. #endif
  573. #ifndef LIGHT_MAX_PWM
  574. #if LIGHT_PROVIDER == LIGHT_PROVIDER_MY92XX
  575. #define LIGHT_MAX_PWM 255
  576. #endif
  577. #if LIGHT_PROVIDER == LIGHT_PROVIDER_DIMMER
  578. #define LIGHT_MAX_PWM 10000 // 5000 * 200ns => 1 kHz
  579. #endif
  580. #endif // LIGHT_MAX_PWM
  581. #ifndef LIGHT_LIMIT_PWM
  582. #define LIGHT_LIMIT_PWM LIGHT_MAX_PWM // Limit PWM to this value (prevent 100% power)
  583. #endif
  584. #ifndef LIGHT_MAX_VALUE
  585. #define LIGHT_MAX_VALUE 255 // Maximum light value
  586. #endif
  587. #ifndef LIGHT_MAX_BRIGHTNESS
  588. #define LIGHT_MAX_BRIGHTNESS 255 // Maximun brightness value
  589. #endif
  590. //#define LIGHT_MIN_MIREDS 153 // NOT USED (yet)! // Default to the Philips Hue value that HA has always assumed
  591. //#define LIGHT_MAX_MIREDS 500 // NOT USED (yet)! // https://developers.meethue.com/documentation/core-concepts
  592. #ifndef LIGHT_DEFAULT_MIREDS
  593. #define LIGHT_DEFAULT_MIREDS 153 // Default value used by MQTT. This value is __NEVRER__ applied!
  594. #endif
  595. #ifndef LIGHT_STEP
  596. #define LIGHT_STEP 32 // Step size
  597. #endif
  598. #ifndef LIGHT_USE_COLOR
  599. #define LIGHT_USE_COLOR 1 // Use 3 first channels as RGB
  600. #endif
  601. #ifndef LIGHT_USE_WHITE
  602. #define LIGHT_USE_WHITE 0 // Use white channel whenever RGB have the same value
  603. #endif
  604. #ifndef LIGHT_USE_GAMMA
  605. #define LIGHT_USE_GAMMA 0 // Use gamma correction for color channels
  606. #endif
  607. #ifndef LIGHT_USE_CSS
  608. #define LIGHT_USE_CSS 1 // Use CSS style to report colors (1=> "#FF0000", 0=> "255,0,0")
  609. #endif
  610. #ifndef LIGHT_USE_RGB
  611. #define LIGHT_USE_RGB 0 // Use RGB color selector (1=> RGB, 0=> HSV)
  612. #endif
  613. #ifndef LIGHT_WHITE_FACTOR
  614. #define LIGHT_WHITE_FACTOR 1 // When using LIGHT_USE_WHITE with uneven brightness LEDs,
  615. // this factor is used to scale the white channel to match brightness
  616. #endif
  617. #ifndef LIGHT_USE_TRANSITIONS
  618. #define LIGHT_USE_TRANSITIONS 1 // Transitions between colors
  619. #endif
  620. #ifndef LIGHT_TRANSITION_STEP
  621. #define LIGHT_TRANSITION_STEP 10 // Time in millis between each transtion step
  622. #endif
  623. #ifndef LIGHT_TRANSITION_TIME
  624. #define LIGHT_TRANSITION_TIME 500 // Time in millis from color to color
  625. #endif
  626. // -----------------------------------------------------------------------------
  627. // DOMOTICZ
  628. // -----------------------------------------------------------------------------
  629. #ifndef DOMOTICZ_SUPPORT
  630. #define DOMOTICZ_SUPPORT MQTT_SUPPORT // Build with domoticz (if MQTT) support (1.72Kb)
  631. #endif
  632. #define DOMOTICZ_ENABLED 0 // Disable domoticz by default
  633. #define DOMOTICZ_IN_TOPIC "domoticz/in" // Default subscription topic
  634. #define DOMOTICZ_OUT_TOPIC "domoticz/out" // Default publication topic
  635. // -----------------------------------------------------------------------------
  636. // HOME ASSISTANT
  637. // -----------------------------------------------------------------------------
  638. #ifndef HOMEASSISTANT_SUPPORT
  639. #define HOMEASSISTANT_SUPPORT MQTT_SUPPORT // Build with home assistant support (if MQTT, 1.64Kb)
  640. #endif
  641. #define HOMEASSISTANT_ENABLED 0 // Integration not enabled by default
  642. #define HOMEASSISTANT_PREFIX "homeassistant" // Default MQTT prefix
  643. // -----------------------------------------------------------------------------
  644. // INFLUXDB
  645. // -----------------------------------------------------------------------------
  646. #ifndef INFLUXDB_SUPPORT
  647. #define INFLUXDB_SUPPORT 0 // Disable InfluxDB support by default (4.38Kb)
  648. #endif
  649. #ifndef INFLUXDB_ENABLED
  650. #define INFLUXDB_ENABLED 0 // InfluxDB disabled by default
  651. #endif
  652. #ifndef INFLUXDB_HOST
  653. #define INFLUXDB_HOST "" // Default server
  654. #endif
  655. #ifndef INFLUXDB_PORT
  656. #define INFLUXDB_PORT 8086 // Default InfluxDB port
  657. #endif
  658. #ifndef INFLUXDB_DATABASE
  659. #define INFLUXDB_DATABASE "" // Default database
  660. #endif
  661. #ifndef INFLUXDB_USERNAME
  662. #define INFLUXDB_USERNAME "" // Default username
  663. #endif
  664. #ifndef INFLUXDB_PASSWORD
  665. #define INFLUXDB_PASSWORD "" // Default password
  666. #endif
  667. // -----------------------------------------------------------------------------
  668. // THINGSPEAK
  669. // -----------------------------------------------------------------------------
  670. #ifndef THINGSPEAK_SUPPORT
  671. #define THINGSPEAK_SUPPORT 1 // Enable Thingspeak support by default (2.56Kb)
  672. #endif
  673. #define THINGSPEAK_ENABLED 0 // Thingspeak disabled by default
  674. #define THINGSPEAK_APIKEY "" // Default API KEY
  675. #define THINGSPEAK_USE_ASYNC 1 // Use AsyncClient instead of WiFiClientSecure
  676. // THINGSPEAK OVER SSL
  677. // Using THINGSPEAK over SSL works well but generates problems with the web interface,
  678. // so you should compile it with WEB_SUPPORT to 0.
  679. // When THINGSPEAK_USE_ASYNC is 1, requires ASYNC_TCP_SSL_ENABLED to 1 and ESP8266 Arduino Core 2.4.0.
  680. #define THINGSPEAK_USE_SSL 0 // Use secure connection
  681. #define THINGSPEAK_FINGERPRINT "78 60 18 44 81 35 BF DF 77 84 D4 0A 22 0D 9B 4E 6C DC 57 2C"
  682. #define THINGSPEAK_HOST "api.thingspeak.com"
  683. #if THINGSPEAK_USE_SSL
  684. #define THINGSPEAK_PORT 443
  685. #else
  686. #define THINGSPEAK_PORT 80
  687. #endif
  688. #define THINGSPEAK_URL "/update"
  689. #define THINGSPEAK_MIN_INTERVAL 15000 // Minimum interval between POSTs (in millis)
  690. // -----------------------------------------------------------------------------
  691. // SCHEDULER
  692. // -----------------------------------------------------------------------------
  693. #ifndef SCHEDULER_SUPPORT
  694. #define SCHEDULER_SUPPORT 1 // Enable scheduler (1.77Kb)
  695. #endif
  696. #define SCHEDULER_MAX_SCHEDULES 10 // Max schedules alowed
  697. // -----------------------------------------------------------------------------
  698. // NTP
  699. // -----------------------------------------------------------------------------
  700. #ifndef NTP_SUPPORT
  701. #define NTP_SUPPORT 1 // Build with NTP support by default (6.78Kb)
  702. #endif
  703. #ifndef NTP_SERVER
  704. #define NTP_SERVER "pool.ntp.org" // Default NTP server
  705. #endif
  706. #ifndef NTP_TIMEOUT
  707. #define NTP_TIMEOUT 2000 // Set NTP request timeout to 2 seconds (issue #452)
  708. #endif
  709. #ifndef NTP_TIME_OFFSET
  710. #define NTP_TIME_OFFSET 60 // Default timezone offset (GMT+1)
  711. #endif
  712. #ifndef NTP_DAY_LIGHT
  713. #define NTP_DAY_LIGHT true // Enable daylight time saving by default
  714. #endif
  715. #ifndef NTP_SYNC_INTERVAL
  716. #define NTP_SYNC_INTERVAL 60 // NTP initial check every minute
  717. #endif
  718. #ifndef NTP_UPDATE_INTERVAL
  719. #define NTP_UPDATE_INTERVAL 1800 // NTP check every 30 minutes
  720. #endif
  721. #ifndef NTP_START_DELAY
  722. #define NTP_START_DELAY 1000 // Delay NTP start 1 second
  723. #endif
  724. #ifndef NTP_DST_REGION
  725. #define NTP_DST_REGION 0 // 0 for Europe, 1 for USA (defined in NtpClientLib)
  726. #endif
  727. // -----------------------------------------------------------------------------
  728. // ALEXA
  729. // -----------------------------------------------------------------------------
  730. // This setting defines whether Alexa support should be built into the firmware
  731. #ifndef ALEXA_SUPPORT
  732. #define ALEXA_SUPPORT 1 // Enable Alexa support by default (10.84Kb)
  733. #endif
  734. // This is default value for the alexaEnabled setting that defines whether
  735. // this device should be discoberable and respond to Alexa commands.
  736. // Both ALEXA_SUPPORT and alexaEnabled should be 1 for Alexa support to work.
  737. #define ALEXA_ENABLED 1
  738. // -----------------------------------------------------------------------------
  739. // RFBRIDGE
  740. // This module is not compatible with RF_SUPPORT=1
  741. // -----------------------------------------------------------------------------
  742. #ifndef RF_SEND_TIMES
  743. #define RF_SEND_TIMES 4 // How many times to send the message
  744. #endif
  745. #ifndef RF_SEND_DELAY
  746. #define RF_SEND_DELAY 500 // Interval between sendings in ms
  747. #endif
  748. #ifndef RF_RECEIVE_DELAY
  749. #define RF_RECEIVE_DELAY 500 // Interval between recieving in ms (avoid debouncing)
  750. #endif
  751. #ifndef RF_RAW_SUPPORT
  752. #define RF_RAW_SUPPORT 0 // RF raw codes require a specific firmware for the EFM8BB1
  753. // https://github.com/rhx/RF-Bridge-EFM8BB1
  754. #endif
  755. // -----------------------------------------------------------------------------
  756. // IR
  757. // -----------------------------------------------------------------------------
  758. #ifndef IR_SUPPORT
  759. #define IR_SUPPORT 0 // Do not build with IR support by default (10.25Kb)
  760. #endif
  761. #ifndef IR_PIN
  762. #define IR_PIN 4 // IR LED
  763. #endif
  764. // 24 Buttons Set of the IR Remote
  765. #ifndef IR_BUTTON_SET
  766. #define IR_BUTTON_SET 1 // IR button set to use (see below)
  767. #endif
  768. //Remote Buttons SET 1 (for the original Remote shipped with the controller)
  769. #if IR_SUPPORT
  770. #if IR_BUTTON_SET == 1
  771. /*
  772. +------+------+------+------+
  773. | UP | Down | OFF | ON |
  774. +------+------+------+------+
  775. | R | G | B | W |
  776. +------+------+------+------+
  777. | 1 | 2 | 3 |FLASH |
  778. +------+------+------+------+
  779. | 4 | 5 | 6 |STROBE|
  780. +------+------+------+------+
  781. | 7 | 8 | 9 | FADE |
  782. +------+------+------+------+
  783. | 10 | 11 | 12 |SMOOTH|
  784. +------+------+------+------+
  785. */
  786. #define IR_BUTTON_COUNT 24
  787. const unsigned long IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {
  788. { 0xFF906F, IR_BUTTON_MODE_BRIGHTER, 1 },
  789. { 0xFFB847, IR_BUTTON_MODE_BRIGHTER, 0 },
  790. { 0xFFF807, IR_BUTTON_MODE_STATE, 0 },
  791. { 0xFFB04F, IR_BUTTON_MODE_STATE, 1 },
  792. { 0xFF9867, IR_BUTTON_MODE_RGB, 0xFF0000 },
  793. { 0xFFD827, IR_BUTTON_MODE_RGB, 0x00FF00 },
  794. { 0xFF8877, IR_BUTTON_MODE_RGB, 0x0000FF },
  795. { 0xFFA857, IR_BUTTON_MODE_RGB, 0xFFFFFF },
  796. { 0xFFE817, IR_BUTTON_MODE_RGB, 0xD13A01 },
  797. { 0xFF48B7, IR_BUTTON_MODE_RGB, 0x00E644 },
  798. { 0xFF6897, IR_BUTTON_MODE_RGB, 0x0040A7 },
  799. { 0xFFB24D, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FLASH },
  800. { 0xFF02FD, IR_BUTTON_MODE_RGB, 0xE96F2A },
  801. { 0xFF32CD, IR_BUTTON_MODE_RGB, 0x00BEBF },
  802. { 0xFF20DF, IR_BUTTON_MODE_RGB, 0x56406F },
  803. { 0xFF00FF, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_STROBE },
  804. { 0xFF50AF, IR_BUTTON_MODE_RGB, 0xEE9819 },
  805. { 0xFF7887, IR_BUTTON_MODE_RGB, 0x00799A },
  806. { 0xFF708F, IR_BUTTON_MODE_RGB, 0x944E80 },
  807. { 0xFF58A7, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FADE },
  808. { 0xFF38C7, IR_BUTTON_MODE_RGB, 0xFFFF00 },
  809. { 0xFF28D7, IR_BUTTON_MODE_RGB, 0x0060A1 },
  810. { 0xFFF00F, IR_BUTTON_MODE_RGB, 0xEF45AD },
  811. { 0xFF30CF, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_SMOOTH }
  812. };
  813. #endif
  814. //Remote Buttons SET 2 (another identical IR Remote shipped with another controller)
  815. #if IR_BUTTON_SET == 2
  816. /*
  817. +------+------+------+------+
  818. | UP | Down | OFF | ON |
  819. +------+------+------+------+
  820. | R | G | B | W |
  821. +------+------+------+------+
  822. | 1 | 2 | 3 |FLASH |
  823. +------+------+------+------+
  824. | 4 | 5 | 6 |STROBE|
  825. +------+------+------+------+
  826. | 7 | 8 | 9 | FADE |
  827. +------+------+------+------+
  828. | 10 | 11 | 12 |SMOOTH|
  829. +------+------+------+------+
  830. */
  831. #define IR_BUTTON_COUNT 24
  832. const unsigned long IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {
  833. { 0xFF00FF, IR_BUTTON_MODE_BRIGHTER, 1 },
  834. { 0xFF807F, IR_BUTTON_MODE_BRIGHTER, 0 },
  835. { 0xFF40BF, IR_BUTTON_MODE_STATE, 0 },
  836. { 0xFFC03F, IR_BUTTON_MODE_STATE, 1 },
  837. { 0xFF20DF, IR_BUTTON_MODE_RGB, 0xFF0000 },
  838. { 0xFFA05F, IR_BUTTON_MODE_RGB, 0x00FF00 },
  839. { 0xFF609F, IR_BUTTON_MODE_RGB, 0x0000FF },
  840. { 0xFFE01F, IR_BUTTON_MODE_RGB, 0xFFFFFF },
  841. { 0xFF10EF, IR_BUTTON_MODE_RGB, 0xD13A01 },
  842. { 0xFF906F, IR_BUTTON_MODE_RGB, 0x00E644 },
  843. { 0xFF50AF, IR_BUTTON_MODE_RGB, 0x0040A7 },
  844. { 0xFFD02F, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FLASH },
  845. { 0xFF30CF, IR_BUTTON_MODE_RGB, 0xE96F2A },
  846. { 0xFFB04F, IR_BUTTON_MODE_RGB, 0x00BEBF },
  847. { 0xFF708F, IR_BUTTON_MODE_RGB, 0x56406F },
  848. { 0xFFF00F, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_STROBE },
  849. { 0xFF08F7, IR_BUTTON_MODE_RGB, 0xEE9819 },
  850. { 0xFF8877, IR_BUTTON_MODE_RGB, 0x00799A },
  851. { 0xFF48B7, IR_BUTTON_MODE_RGB, 0x944E80 },
  852. { 0xFFC837, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FADE },
  853. { 0xFF28D7, IR_BUTTON_MODE_RGB, 0xFFFF00 },
  854. { 0xFFA857, IR_BUTTON_MODE_RGB, 0x0060A1 },
  855. { 0xFF6897, IR_BUTTON_MODE_RGB, 0xEF45AD },
  856. { 0xFFE817, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_SMOOTH }
  857. };
  858. #endif
  859. #endif // IR_SUPPORT
  860. //--------------------------------------------------------------------------------
  861. // Custom RF module
  862. // Check http://tinkerman.cat/adding-rf-to-a-non-rf-itead-sonoff/
  863. // Enable support by passing RF_SUPPORT=1 build flag
  864. // This module is not compatible with RFBRIDGE
  865. //--------------------------------------------------------------------------------
  866. #ifndef RF_SUPPORT
  867. #define RF_SUPPORT 0
  868. #endif
  869. #ifndef RF_PIN
  870. #define RF_PIN 14
  871. #endif
  872. #define RF_DEBOUNCE 500
  873. #define RF_LEARN_TIMEOUT 60000