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.

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