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.

1432 lines
47 KiB

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