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.

857 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
6 years ago
6 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
  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_MODE_NORMAL 0
  220. #define WEB_MODE_PASSWORD 1
  221. #define WEB_USERNAME "admin" // HTTP username
  222. #define WEB_FORCE_PASS_CHANGE 1 // Force the user to change the password if default one
  223. #define WEB_PORT 80 // HTTP port
  224. // -----------------------------------------------------------------------------
  225. // WEBSOCKETS
  226. // -----------------------------------------------------------------------------
  227. // This will only be enabled if WEB_SUPPORT is 1 (this is the default value)
  228. #define WS_AUTHENTICATION 1 // WS authentication ON by default (see #507)
  229. #define WS_BUFFER_SIZE 5 // Max number of secured websocket connections
  230. #define WS_TIMEOUT 1800000 // Timeout for secured websocket
  231. #define WS_UPDATE_INTERVAL 30000 // Update clients every 30 seconds
  232. // -----------------------------------------------------------------------------
  233. // API
  234. // -----------------------------------------------------------------------------
  235. // This will only be enabled if WEB_SUPPORT is 1 (this is the default value)
  236. #define API_ENABLED 0 // Do not enable API by default
  237. #define API_BUFFER_SIZE 15 // Size of the buffer for HTTP GET API responses
  238. #define API_REAL_TIME_VALUES 0 // Show filtered/median values by default (0 => median, 1 => real time)
  239. // -----------------------------------------------------------------------------
  240. // MDNS / LLMNR / NETBIOS / SSDP
  241. // -----------------------------------------------------------------------------
  242. #ifndef MDNS_SERVER_SUPPORT
  243. #define MDNS_SERVER_SUPPORT 1 // Publish services using mDNS by default (1.48Kb)
  244. #endif
  245. #ifndef MDNS_CLIENT_SUPPORT
  246. #define MDNS_CLIENT_SUPPORT 0 // Resolve mDNS names (3.44Kb)
  247. #endif
  248. #ifndef LLMNR_SUPPORT
  249. #define LLMNR_SUPPORT 0 // Publish device using LLMNR protocol by default (1.95Kb) - requires 2.4.0
  250. #endif
  251. #ifndef NETBIOS_SUPPORT
  252. #define NETBIOS_SUPPORT 0 // Publish device using NetBIOS protocol by default (1.26Kb) - requires 2.4.0
  253. #endif
  254. #ifndef SSDP_SUPPORT
  255. #define SSDP_SUPPORT 0 // Publish device using SSDP protocol by default (4.59Kb)
  256. // Not compatible with ALEXA_SUPPORT at the moment
  257. #endif
  258. #ifndef SSDP_DEVICE_TYPE
  259. #define SSDP_DEVICE_TYPE "upnp:rootdevice"
  260. //#define SSDP_DEVICE_TYPE "urn:schemas-upnp-org:device:BinaryLight:1"
  261. #endif
  262. // -----------------------------------------------------------------------------
  263. // SPIFFS
  264. // -----------------------------------------------------------------------------
  265. #ifndef SPIFFS_SUPPORT
  266. #define SPIFFS_SUPPORT 0 // Do not add support for SPIFFS by default
  267. #endif
  268. // -----------------------------------------------------------------------------
  269. // OTA
  270. // -----------------------------------------------------------------------------
  271. #define OTA_PORT 8266 // OTA port
  272. #define OTA_GITHUB_FP "D7:9F:07:61:10:B3:92:93:E3:49:AC:89:84:5B:03:80:C1:9E:2F:8B"
  273. // -----------------------------------------------------------------------------
  274. // NOFUSS
  275. // -----------------------------------------------------------------------------
  276. #ifndef NOFUSS_SUPPORT
  277. #define NOFUSS_SUPPORT 0 // Do not enable support for NoFuss by default (12.65Kb)
  278. #endif
  279. #define NOFUSS_ENABLED 0 // Do not perform NoFUSS updates by default
  280. #define NOFUSS_SERVER "" // Default NoFuss Server
  281. #define NOFUSS_INTERVAL 3600000 // Check for updates every hour
  282. // -----------------------------------------------------------------------------
  283. // UART <-> MQTT
  284. // -----------------------------------------------------------------------------
  285. #ifndef UART_MQTT_SUPPORT
  286. #define UART_MQTT_SUPPORT 0 // No support by default
  287. #endif
  288. #define UART_MQTT_USE_SOFT 0 // Use SoftwareSerial
  289. #define UART_MQTT_HW_PORT Serial // Hardware serial port (if UART_MQTT_USE_SOFT == 0)
  290. #define UART_MQTT_RX_PIN 4 // RX PIN (if UART_MQTT_USE_SOFT == 1)
  291. #define UART_MQTT_TX_PIN 5 // TX PIN (if UART_MQTT_USE_SOFT == 1)
  292. #define UART_MQTT_BAUDRATE 115200 // Serial speed
  293. #define UART_MQTT_BUFFER_SIZE 100 // UART buffer size
  294. // -----------------------------------------------------------------------------
  295. // MQTT
  296. // -----------------------------------------------------------------------------
  297. #ifndef MQTT_SUPPORT
  298. #define MQTT_SUPPORT 1 // MQTT support (22.38Kb async, 12.48Kb sync)
  299. #endif
  300. #ifndef MQTT_USE_ASYNC
  301. #define MQTT_USE_ASYNC 1 // Use AysncMQTTClient (1) or PubSubClient (0)
  302. #endif
  303. // MQTT OVER SSL
  304. // Using MQTT over SSL works pretty well but generates problems with the web interface.
  305. // It could be a good idea to use it in conjuntion with WEB_SUPPORT=0.
  306. // Requires ASYNC_TCP_SSL_ENABLED to 1 and ESP8266 Arduino Core 2.4.0.
  307. //
  308. // You can use SSL with MQTT_USE_ASYNC=1 (AsyncMqttClient library)
  309. // but you might experience hiccups on the web interface, so my recommendation is:
  310. // WEB_SUPPORT=0
  311. //
  312. // If you use SSL with MQTT_USE_ASYNC=0 (PubSubClient library)
  313. // you will have to disable all the modules that use ESPAsyncTCP, that is:
  314. // ALEXA_SUPPORT=0, INFLUXDB_SUPPORT=0, TELNET_SUPPORT=0, THINGSPEAK_SUPPORT=0 and WEB_SUPPORT=0
  315. //
  316. // You will need the fingerprint for your MQTT server, example for CloudMQTT:
  317. // $ echo -n | openssl s_client -connect m11.cloudmqtt.com:24055 > cloudmqtt.pem
  318. // $ openssl x509 -noout -in cloudmqtt.pem -fingerprint -sha1
  319. #define MQTT_SSL_ENABLED 0 // By default MQTT over SSL will not be enabled
  320. #define MQTT_SSL_FINGERPRINT "" // SSL fingerprint of the server
  321. #define MQTT_ENABLED 0 // Do not enable MQTT connection by default
  322. #define MQTT_AUTOCONNECT 1 // If enabled and MDNS_SERVER_SUPPORT=1 will perform an autodiscover and
  323. // autoconnect to the first MQTT broker found if none defined
  324. #define MQTT_SERVER "" // Default MQTT broker address
  325. #define MQTT_USER "" // Default MQTT broker usename
  326. #define MQTT_PASS "" // Default MQTT broker password
  327. #define MQTT_PORT 1883 // MQTT broker port
  328. #define MQTT_TOPIC "{hostname}" // Default MQTT base topic
  329. #define MQTT_RETAIN true // MQTT retain flag
  330. #define MQTT_QOS 0 // MQTT QoS value for all messages
  331. #define MQTT_KEEPALIVE 30 // MQTT keepalive value
  332. #define MQTT_RECONNECT_DELAY_MIN 5000 // Try to reconnect in 5 seconds upon disconnection
  333. #define MQTT_RECONNECT_DELAY_STEP 5000 // Increase the reconnect delay in 5 seconds after each failed attempt
  334. #define MQTT_RECONNECT_DELAY_MAX 120000 // Set reconnect time to 2 minutes at most
  335. #define MQTT_SKIP_RETAINED 1 // Skip retained messages on connection
  336. #define MQTT_SKIP_TIME 1000 // Skip messages for 1 second anter connection
  337. #define MQTT_USE_JSON 0 // Group messages in a JSON body
  338. #define MQTT_USE_JSON_DELAY 100 // Wait this many ms before grouping messages
  339. #define MQTT_QUEUE_MAX_SIZE 20 // Size of the MQTT queue when MQTT_USE_JSON is enabled
  340. // These are the properties that will be sent when useJson is true
  341. #ifndef MQTT_ENQUEUE_IP
  342. #define MQTT_ENQUEUE_IP 1
  343. #endif
  344. #ifndef MQTT_ENQUEUE_MAC
  345. #define MQTT_ENQUEUE_MAC 1
  346. #endif
  347. #ifndef MQTT_ENQUEUE_HOSTNAME
  348. #define MQTT_ENQUEUE_HOSTNAME 1
  349. #endif
  350. #ifndef MQTT_ENQUEUE_DATETIME
  351. #define MQTT_ENQUEUE_DATETIME 1
  352. #endif
  353. #ifndef MQTT_ENQUEUE_MESSAGE_ID
  354. #define MQTT_ENQUEUE_MESSAGE_ID 1
  355. #endif
  356. // These particles will be concatenated to the MQTT_TOPIC base to form the actual topic
  357. #define MQTT_TOPIC_JSON "data"
  358. #define MQTT_TOPIC_ACTION "action"
  359. #define MQTT_TOPIC_RELAY "relay"
  360. #define MQTT_TOPIC_LED "led"
  361. #define MQTT_TOPIC_BUTTON "button"
  362. #define MQTT_TOPIC_IP "ip"
  363. #define MQTT_TOPIC_VERSION "version"
  364. #define MQTT_TOPIC_UPTIME "uptime"
  365. #define MQTT_TOPIC_DATETIME "datetime"
  366. #define MQTT_TOPIC_FREEHEAP "freeheap"
  367. #define MQTT_TOPIC_VCC "vcc"
  368. #define MQTT_TOPIC_STATUS "status"
  369. #define MQTT_TOPIC_MAC "mac"
  370. #define MQTT_TOPIC_RSSI "rssi"
  371. #define MQTT_TOPIC_MESSAGE_ID "id"
  372. #define MQTT_TOPIC_APP "app"
  373. #define MQTT_TOPIC_INTERVAL "interval"
  374. #define MQTT_TOPIC_HOSTNAME "host"
  375. #define MQTT_TOPIC_TIME "time"
  376. #define MQTT_TOPIC_RFOUT "rfout"
  377. #define MQTT_TOPIC_RFIN "rfin"
  378. #define MQTT_TOPIC_RFLEARN "rflearn"
  379. #define MQTT_TOPIC_RFRAW "rfraw"
  380. #define MQTT_TOPIC_UARTIN "uartin"
  381. #define MQTT_TOPIC_UARTOUT "uartout"
  382. #define MQTT_TOPIC_LOADAVG "loadavg"
  383. #define MQTT_TOPIC_BOARD "board"
  384. // Light module
  385. #define MQTT_TOPIC_CHANNEL "channel"
  386. #define MQTT_TOPIC_COLOR_RGB "rgb"
  387. #define MQTT_TOPIC_COLOR_HSV "hsv"
  388. #define MQTT_TOPIC_ANIM_MODE "anim_mode"
  389. #define MQTT_TOPIC_ANIM_SPEED "anim_speed"
  390. #define MQTT_TOPIC_BRIGHTNESS "brightness"
  391. #define MQTT_TOPIC_MIRED "mired"
  392. #define MQTT_TOPIC_KELVIN "kelvin"
  393. #define MQTT_STATUS_ONLINE "1" // Value for the device ON message
  394. #define MQTT_STATUS_OFFLINE "0" // Value for the device OFF message (will)
  395. #define MQTT_ACTION_RESET "reboot" // RESET MQTT topic particle
  396. // Internal MQTT events (do not change)
  397. #define MQTT_CONNECT_EVENT 0
  398. #define MQTT_DISCONNECT_EVENT 1
  399. #define MQTT_MESSAGE_EVENT 2
  400. #define MQTT_MESSAGE_ID_SHIFT 1000 // Store MQTT message id into EEPROM every these many
  401. // Custom get and set postfixes
  402. // Use something like "/status" or "/set", with leading slash
  403. // Since 1.9.0 the default value is "" for getter and "/set" for setter
  404. #ifndef MQTT_GETTER
  405. #define MQTT_GETTER ""
  406. #endif
  407. #ifndef MQTT_SETTER
  408. #define MQTT_SETTER "/set"
  409. #endif
  410. // -----------------------------------------------------------------------------
  411. // BROKER
  412. // -----------------------------------------------------------------------------
  413. #ifndef BROKER_SUPPORT
  414. #define BROKER_SUPPORT 1 // The broker is a poor-man's pubsub manager
  415. #endif
  416. // -----------------------------------------------------------------------------
  417. // SETTINGS
  418. // -----------------------------------------------------------------------------
  419. #ifndef SETTINGS_AUTOSAVE
  420. #define SETTINGS_AUTOSAVE 1 // Autosave settings o force manual commit
  421. #endif
  422. #define SETTINGS_MAX_LIST_COUNT 10 // Maximum index for settings lists
  423. // -----------------------------------------------------------------------------
  424. // LIGHT
  425. // -----------------------------------------------------------------------------
  426. // LIGHT_PROVIDER_DIMMER can have from 1 to 5 different channels.
  427. // They have to be defined for each device in the hardware.h file.
  428. // If 3 or more channels first 3 will be considered RGB.
  429. // Usual configurations are:
  430. // 1 channels => W
  431. // 2 channels => WW
  432. // 3 channels => RGB
  433. // 4 channels => RGBW
  434. // 5 channels => RGBWW
  435. #ifndef LIGHT_SAVE_ENABLED
  436. #define LIGHT_SAVE_ENABLED 1 // Light channel values saved by default after each change
  437. #endif
  438. #define LIGHT_SAVE_DELAY 5 // Persist color after 5 seconds to avoid wearing out
  439. #ifndef LIGHT_MAX_PWM
  440. #if LIGHT_PROVIDER == LIGHT_PROVIDER_MY92XX
  441. #define LIGHT_MAX_PWM 255
  442. #endif
  443. #if LIGHT_PROVIDER == LIGHT_PROVIDER_DIMMER
  444. #define LIGHT_MAX_PWM 10000 // 5000 * 200ns => 1 kHz
  445. #endif
  446. #endif // LIGHT_MAX_PWM
  447. #ifndef LIGHT_LIMIT_PWM
  448. #define LIGHT_LIMIT_PWM LIGHT_MAX_PWM // Limit PWM to this value (prevent 100% power)
  449. #endif
  450. #ifndef LIGHT_MAX_VALUE
  451. #define LIGHT_MAX_VALUE 255 // Maximum light value
  452. #endif
  453. #define LIGHT_MAX_BRIGHTNESS 255 // Maximun brightness value
  454. //#define LIGHT_MIN_MIREDS 153 // NOT USED (yet)! // Default to the Philips Hue value that HA has always assumed
  455. //#define LIGHT_MAX_MIREDS 500 // NOT USED (yet)! // https://developers.meethue.com/documentation/core-concepts
  456. #define LIGHT_DEFAULT_MIREDS 153 // Default value used by MQTT. This value is __NEVRER__ applied!
  457. #define LIGHT_STEP 32 // Step size
  458. #define LIGHT_USE_COLOR 1 // Use 3 first channels as RGB
  459. #define LIGHT_USE_WHITE 0 // Use white channel whenever RGB have the same value
  460. #define LIGHT_USE_GAMMA 0 // Use gamma correction for color channels
  461. #define LIGHT_USE_CSS 1 // Use CSS style to report colors (1=> "#FF0000", 0=> "255,0,0")
  462. #define LIGHT_USE_RGB 0 // Use RGB color selector (1=> RGB, 0=> HSV)
  463. #define LIGHT_USE_TRANSITIONS 1 // Transitions between colors
  464. #define LIGHT_TRANSITION_STEP 10 // Time in millis between each transtion step
  465. #define LIGHT_TRANSITION_TIME 500 // Time in millis from color to color
  466. // -----------------------------------------------------------------------------
  467. // DOMOTICZ
  468. // -----------------------------------------------------------------------------
  469. #ifndef DOMOTICZ_SUPPORT
  470. #define DOMOTICZ_SUPPORT MQTT_SUPPORT // Build with domoticz (if MQTT) support (1.72Kb)
  471. #endif
  472. #define DOMOTICZ_ENABLED 0 // Disable domoticz by default
  473. #define DOMOTICZ_IN_TOPIC "domoticz/in" // Default subscription topic
  474. #define DOMOTICZ_OUT_TOPIC "domoticz/out" // Default publication topic
  475. // -----------------------------------------------------------------------------
  476. // HOME ASSISTANT
  477. // -----------------------------------------------------------------------------
  478. #ifndef HOMEASSISTANT_SUPPORT
  479. #define HOMEASSISTANT_SUPPORT MQTT_SUPPORT // Build with home assistant support (if MQTT, 1.64Kb)
  480. #endif
  481. #define HOMEASSISTANT_ENABLED 0 // Integration not enabled by default
  482. #define HOMEASSISTANT_PREFIX "homeassistant" // Default MQTT prefix
  483. // -----------------------------------------------------------------------------
  484. // INFLUXDB
  485. // -----------------------------------------------------------------------------
  486. #ifndef INFLUXDB_SUPPORT
  487. #define INFLUXDB_SUPPORT 0 // Disable InfluxDB support by default (4.38Kb)
  488. #endif
  489. #define INFLUXDB_ENABLED 0 // InfluxDB disabled by default
  490. #define INFLUXDB_HOST "" // Default server
  491. #define INFLUXDB_PORT 8086 // Default InfluxDB port
  492. #define INFLUXDB_DATABASE "" // Default database
  493. #define INFLUXDB_USERNAME "" // Default username
  494. #define INFLUXDB_PASSWORD "" // Default password
  495. // -----------------------------------------------------------------------------
  496. // THINGSPEAK
  497. // -----------------------------------------------------------------------------
  498. #ifndef THINGSPEAK_SUPPORT
  499. #define THINGSPEAK_SUPPORT 1 // Enable Thingspeak support by default (2.56Kb)
  500. #endif
  501. #define THINGSPEAK_ENABLED 0 // Thingspeak disabled by default
  502. #define THINGSPEAK_APIKEY "" // Default API KEY
  503. #define THINGSPEAK_USE_ASYNC 1 // Use AsyncClient instead of WiFiClientSecure
  504. // THINGSPEAK OVER SSL
  505. // Using THINGSPEAK over SSL works well but generates problems with the web interface,
  506. // so you should compile it with WEB_SUPPORT to 0.
  507. // When THINGSPEAK_USE_ASYNC is 1, requires ASYNC_TCP_SSL_ENABLED to 1 and ESP8266 Arduino Core 2.4.0.
  508. #define THINGSPEAK_USE_SSL 0 // Use secure connection
  509. #define THINGSPEAK_FINGERPRINT "78 60 18 44 81 35 BF DF 77 84 D4 0A 22 0D 9B 4E 6C DC 57 2C"
  510. #define THINGSPEAK_HOST "api.thingspeak.com"
  511. #if THINGSPEAK_USE_SSL
  512. #define THINGSPEAK_PORT 443
  513. #else
  514. #define THINGSPEAK_PORT 80
  515. #endif
  516. #define THINGSPEAK_URL "/update"
  517. #define THINGSPEAK_MIN_INTERVAL 15000 // Minimum interval between POSTs (in millis)
  518. // -----------------------------------------------------------------------------
  519. // SCHEDULER
  520. // -----------------------------------------------------------------------------
  521. #ifndef SCHEDULER_SUPPORT
  522. #define SCHEDULER_SUPPORT 1 // Enable scheduler (1.77Kb)
  523. #endif
  524. #define SCHEDULER_MAX_SCHEDULES 10 // Max schedules alowed
  525. // -----------------------------------------------------------------------------
  526. // NTP
  527. // -----------------------------------------------------------------------------
  528. #ifndef NTP_SUPPORT
  529. #define NTP_SUPPORT 1 // Build with NTP support by default (6.78Kb)
  530. #endif
  531. #define NTP_SERVER "pool.ntp.org" // Default NTP server
  532. #define NTP_TIMEOUT 2000 // Set NTP request timeout to 2 seconds (issue #452)
  533. #define NTP_TIME_OFFSET 60 // Default timezone offset (GMT+1)
  534. #define NTP_DAY_LIGHT true // Enable daylight time saving by default
  535. #define NTP_SYNC_INTERVAL 60 // NTP initial check every minute
  536. #define NTP_UPDATE_INTERVAL 1800 // NTP check every 30 minutes
  537. #define NTP_START_DELAY 1000 // Delay NTP start 1 second
  538. #define NTP_DST_REGION 0 // 0 for Europe, 1 for USA (defined in NtpClientLib)
  539. // -----------------------------------------------------------------------------
  540. // ALEXA
  541. // -----------------------------------------------------------------------------
  542. // This setting defines whether Alexa support should be built into the firmware
  543. #ifndef ALEXA_SUPPORT
  544. #define ALEXA_SUPPORT 1 // Enable Alexa support by default (10.84Kb)
  545. #endif
  546. // This is default value for the alexaEnabled setting that defines whether
  547. // this device should be discoberable and respond to Alexa commands.
  548. // Both ALEXA_SUPPORT and alexaEnabled should be 1 for Alexa support to work.
  549. #define ALEXA_ENABLED 1
  550. // -----------------------------------------------------------------------------
  551. // RFBRIDGE
  552. // This module is not compatible with RF_SUPPORT=1
  553. // -----------------------------------------------------------------------------
  554. #define RF_SEND_TIMES 4 // How many times to send the message
  555. #define RF_SEND_DELAY 500 // Interval between sendings in ms
  556. #define RF_RECEIVE_DELAY 500 // Interval between recieving in ms (avoid debouncing)
  557. #define RF_RAW_SUPPORT 0 // RF raw codes require a specific firmware for the EFM8BB1
  558. // https://github.com/rhx/RF-Bridge-EFM8BB1
  559. // -----------------------------------------------------------------------------
  560. // IR
  561. // -----------------------------------------------------------------------------
  562. #ifndef IR_SUPPORT
  563. #define IR_SUPPORT 0 // Do not build with IR support by default (10.25Kb)
  564. #endif
  565. #ifndef IR_PIN
  566. #define IR_PIN 4 // IR LED
  567. #endif
  568. // 24 Buttons Set of the IR Remote
  569. #ifndef IR_BUTTON_SET
  570. #define IR_BUTTON_SET 1 // IR button set to use (see below)
  571. #endif
  572. //Remote Buttons SET 1 (for the original Remote shipped with the controller)
  573. #if IR_SUPPORT
  574. #if IR_BUTTON_SET == 1
  575. /*
  576. +------+------+------+------+
  577. | UP | Down | OFF | ON |
  578. +------+------+------+------+
  579. | R | G | B | W |
  580. +------+------+------+------+
  581. | 1 | 2 | 3 |FLASH |
  582. +------+------+------+------+
  583. | 4 | 5 | 6 |STROBE|
  584. +------+------+------+------+
  585. | 7 | 8 | 9 | FADE |
  586. +------+------+------+------+
  587. | 10 | 11 | 12 |SMOOTH|
  588. +------+------+------+------+
  589. */
  590. #define IR_BUTTON_COUNT 24
  591. const unsigned long IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {
  592. { 0xFF906F, IR_BUTTON_MODE_BRIGHTER, 1 },
  593. { 0xFFB847, IR_BUTTON_MODE_BRIGHTER, 0 },
  594. { 0xFFF807, IR_BUTTON_MODE_STATE, 0 },
  595. { 0xFFB04F, IR_BUTTON_MODE_STATE, 1 },
  596. { 0xFF9867, IR_BUTTON_MODE_RGB, 0xFF0000 },
  597. { 0xFFD827, IR_BUTTON_MODE_RGB, 0x00FF00 },
  598. { 0xFF8877, IR_BUTTON_MODE_RGB, 0x0000FF },
  599. { 0xFFA857, IR_BUTTON_MODE_RGB, 0xFFFFFF },
  600. { 0xFFE817, IR_BUTTON_MODE_RGB, 0xD13A01 },
  601. { 0xFF48B7, IR_BUTTON_MODE_RGB, 0x00E644 },
  602. { 0xFF6897, IR_BUTTON_MODE_RGB, 0x0040A7 },
  603. { 0xFFB24D, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FLASH },
  604. { 0xFF02FD, IR_BUTTON_MODE_RGB, 0xE96F2A },
  605. { 0xFF32CD, IR_BUTTON_MODE_RGB, 0x00BEBF },
  606. { 0xFF20DF, IR_BUTTON_MODE_RGB, 0x56406F },
  607. { 0xFF00FF, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_STROBE },
  608. { 0xFF50AF, IR_BUTTON_MODE_RGB, 0xEE9819 },
  609. { 0xFF7887, IR_BUTTON_MODE_RGB, 0x00799A },
  610. { 0xFF708F, IR_BUTTON_MODE_RGB, 0x944E80 },
  611. { 0xFF58A7, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FADE },
  612. { 0xFF38C7, IR_BUTTON_MODE_RGB, 0xFFFF00 },
  613. { 0xFF28D7, IR_BUTTON_MODE_RGB, 0x0060A1 },
  614. { 0xFFF00F, IR_BUTTON_MODE_RGB, 0xEF45AD },
  615. { 0xFF30CF, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_SMOOTH }
  616. };
  617. #endif
  618. //Remote Buttons SET 2 (another identical IR Remote shipped with another controller)
  619. #if IR_BUTTON_SET == 2
  620. /*
  621. +------+------+------+------+
  622. | UP | Down | OFF | ON |
  623. +------+------+------+------+
  624. | R | G | B | W |
  625. +------+------+------+------+
  626. | 1 | 2 | 3 |FLASH |
  627. +------+------+------+------+
  628. | 4 | 5 | 6 |STROBE|
  629. +------+------+------+------+
  630. | 7 | 8 | 9 | FADE |
  631. +------+------+------+------+
  632. | 10 | 11 | 12 |SMOOTH|
  633. +------+------+------+------+
  634. */
  635. #define IR_BUTTON_COUNT 24
  636. const unsigned long IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {
  637. { 0xFF00FF, IR_BUTTON_MODE_BRIGHTER, 1 },
  638. { 0xFF807F, IR_BUTTON_MODE_BRIGHTER, 0 },
  639. { 0xFF40BF, IR_BUTTON_MODE_STATE, 0 },
  640. { 0xFFC03F, IR_BUTTON_MODE_STATE, 1 },
  641. { 0xFF20DF, IR_BUTTON_MODE_RGB, 0xFF0000 },
  642. { 0xFFA05F, IR_BUTTON_MODE_RGB, 0x00FF00 },
  643. { 0xFF609F, IR_BUTTON_MODE_RGB, 0x0000FF },
  644. { 0xFFE01F, IR_BUTTON_MODE_RGB, 0xFFFFFF },
  645. { 0xFF10EF, IR_BUTTON_MODE_RGB, 0xD13A01 },
  646. { 0xFF906F, IR_BUTTON_MODE_RGB, 0x00E644 },
  647. { 0xFF50AF, IR_BUTTON_MODE_RGB, 0x0040A7 },
  648. { 0xFFD02F, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FLASH },
  649. { 0xFF30CF, IR_BUTTON_MODE_RGB, 0xE96F2A },
  650. { 0xFFB04F, IR_BUTTON_MODE_RGB, 0x00BEBF },
  651. { 0xFF708F, IR_BUTTON_MODE_RGB, 0x56406F },
  652. { 0xFFF00F, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_STROBE },
  653. { 0xFF08F7, IR_BUTTON_MODE_RGB, 0xEE9819 },
  654. { 0xFF8877, IR_BUTTON_MODE_RGB, 0x00799A },
  655. { 0xFF48B7, IR_BUTTON_MODE_RGB, 0x944E80 },
  656. { 0xFFC837, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FADE },
  657. { 0xFF28D7, IR_BUTTON_MODE_RGB, 0xFFFF00 },
  658. { 0xFFA857, IR_BUTTON_MODE_RGB, 0x0060A1 },
  659. { 0xFF6897, IR_BUTTON_MODE_RGB, 0xEF45AD },
  660. { 0xFFE817, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_SMOOTH }
  661. };
  662. #endif
  663. #endif // IR_SUPPORT
  664. //--------------------------------------------------------------------------------
  665. // Custom RF module
  666. // Check http://tinkerman.cat/adding-rf-to-a-non-rf-itead-sonoff/
  667. // Enable support by passing RF_SUPPORT=1 build flag
  668. // This module is not compatible with RFBRIDGE
  669. //--------------------------------------------------------------------------------
  670. #ifndef RF_SUPPORT
  671. #define RF_SUPPORT 0
  672. #endif
  673. #ifndef RF_PIN
  674. #define RF_PIN 14
  675. #endif
  676. #define RF_DEBOUNCE 500
  677. #define RF_LEARN_TIMEOUT 60000