-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.h
More file actions
141 lines (119 loc) · 3.62 KB
/
Copy pathconfig.h
File metadata and controls
141 lines (119 loc) · 3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#ifndef CONFIG_H
#define CONFIG_H
/*
====================================================================================================
Define constants below or, preferably, in platformio.ini
====================================================================================================
*/
//#define WIFI_SSID "wifi_ssid" // Your WiFi ssid
//#define WIFI_PASS "wifi_password" // Your WiFi password
//#define WIFI_TIMEOUT 10 // Minutes to wait for a wifi connection before rebooting
//#define MQTT_SERVER "192.168.0.1" // Your mqtt server ip address
//#define MQTT_PORT 1883 // Your mqtt port
//#define MQTT_BASE_TOPIC "sonoff/basic" // Base mqtt topic
//#define MQTT_USER "sonoff" // mqtt username
//#define MQTT_PASS "password" // mqtt password
//#define MQTT_RETAIN true // Retain availability messages (recommended)
//#define MQTT_QOS 0 // QOS level for mqtt messages (0 or 1)
//#define NAME "Sonoff Button" // Home Assistant entity name
//#define DEFAULT_STATE 1 // Default/initial state of circuit (1 = on)
//#define TOGGLE_DURATION 10 // Seconds to toggle circuit
//#define DISABLE_LINK_LED // Uncomment to disable link status LED
//#define DEBUG // Uncomment to enable debug reporting
/*
====================================================================================================
END USER CONFIGURATION
====================================================================================================
*/
#include <Arduino.h>
/* ==== Wifi Config ==== */
#ifndef WIFI_SSID
#define WIFI_SSID "wifi_ssid"
#endif
#ifndef WIFI_PASS
#define WIFI_PASS "wifi_password"
#endif
#ifndef WIFI_TIMEOUT
#define WIFI_TIMEOUT 10
#endif
/* ==== MQTT config ==== */
#ifndef MQTT_SERVER
#define MQTT_SERVER "192.168.0.1"
#endif
#ifndef MQTT_PORT
#define MQTT_PORT 1883
#endif
#ifndef MQTT_BASE_TOPIC
#define MQTT_BASE_TOPIC "sonoff/basic"
#endif
#ifndef MQTT_USER
#define MQTT_USER "sonoff"
#endif
#ifndef MQTT_PASS
#define MQTT_PASS "password"
#endif
#ifndef MQTT_RETAIN
#define MQTT_RETAIN true
#endif
#ifndef MQTT_QOS
#define MQTT_QOS 0
#endif
// Home Assistant defaults
#ifndef MQTT_MSG_PRESS
#define MQTT_MSG_PRESS "PRESS"
#define MQTT_MSG_PRESS_DEFAULT
#endif
#ifndef MQTT_MSG_UP
#define MQTT_MSG_UP "online"
#define MQTT_MSG_UP_DEFAULT
#endif
#ifndef MQTT_MSG_DOWN
#define MQTT_MSG_DOWN "offline"
#define MQTT_MSG_DOWN_DEFAULT
#endif
// Not used by Home Assistant
#ifndef MQTT_MSG_RESTART
#define MQTT_MSG_RESTART "restart"
#endif
// Other MQTT constants
#define MQTT_CMD_SUF "/cmd"
#define MQTT_ATTR_SUF "/sys"
#define MQTT_AVTY_SUF "/up"
/* ==== Device config ==== */
#ifndef NAME
#define NAME "Sonoff Button"
#endif
#ifndef DEVICE_MODEL
#define DEVICE_MODEL "Sonoff Basic"
#endif
#ifndef DEVICE_NAME
#define DEVICE_NAME DEVICE_MODEL
#endif
#ifndef DEFAULT_STATE
#define DEFAULT_STATE 1
#endif
#ifndef TOGGLE_DURATION
#define TOGGLE_DURATION 10
#endif
/* ==== Hardware constants ==== */
#define LINK_LED 13
#define BUTTON 0
#define RELAY 12
/* ==== Other ==== */
#ifndef VERSION
#define VERSION "20220412000000"
#endif
#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)
#ifdef DEBUG
#define LOG_BEGIN(x) Serial.begin(x)
#define LOG(x) Serial.print(x)
#define LOG_LN(x) Serial.println(x)
#define LOG_F(x, ...) Serial.printf(x, __VA_ARGS__)
#else
#define LOG_BEGIN(x)
#define LOG(x)
#define LOG_LN(x)
#define LOG_F(x, ...)
#endif
#endif