-
Notifications
You must be signed in to change notification settings - Fork 0
/
sensor.cpp.diff
307 lines (278 loc) · 6.3 KB
/
sensor.cpp.diff
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
--- ./deconz-rest-plugin/sensor.cpp 2017-03-04 23:50:14.983712234 +0100
+++ ./sensor.cpp 2017-02-27 01:18:12.372487346 +0100
@@ -137,6 +137,8 @@
sensorTypes.append("ZHASwitch");
sensorTypes.append("ZHALight");
sensorTypes.append("ZHAPresence");
+
+ pushCode ( m_pushType = PUSH_TYPE_SWITCH; m_pushDType = 's' );
}
/*! Returns the sensor deleted state.
@@ -167,6 +169,8 @@
void Sensor::setName(const QString &name)
{
m_name = name;
+
+ pushSetNodeInfo ( name );
}
/*! Returns the sensor mode (Lighting Switch).
@@ -187,6 +191,8 @@
*/
void Sensor::setMode(SensorMode mode)
{
+ pushSetNodeInfoMemComp ( mode );
+
m_mode = mode;
}
@@ -202,6 +208,8 @@
*/
void Sensor::setType(const QString &type)
{
+ pushSetNodeInfoMemComp ( type );
+
m_type = type;
}
@@ -217,6 +225,8 @@
*/
void Sensor::setModelId(const QString &mid)
{
+ pushSetNodeInfoCompName ( m_modelid, mid.trimmed (), "modelid" );
+
m_modelid = mid.trimmed();
}
@@ -232,6 +242,8 @@
*/
void Sensor::setResetRetryCount(uint8_t resetRetryCount)
{
+ pushSetNodeInfoMemComp ( resetRetryCount );
+
m_resetRetryCount = resetRetryCount;
}
@@ -247,6 +259,8 @@
*/
void Sensor::setZdpResetSeq(uint8_t zdpResetSeq)
{
+ pushSetNodeInfoMemComp ( zdpResetSeq );
+
m_zdpResetSeq = zdpResetSeq;
}
@@ -263,6 +277,8 @@
*/
void Sensor::setManufacturer(const QString &manufacturer)
{
+ pushSetNodeInfoMemComp ( manufacturer );
+
m_manufacturer = manufacturer;
}
@@ -279,6 +295,8 @@
*/
void Sensor::setSwVersion(const QString &swversion)
{
+ pushSetNodeInfoMemComp ( swversion );
+
m_swversion = swversion;
}
@@ -302,6 +320,15 @@
void Sensor::setState(const SensorState &state)
{
m_state = state;
+
+#ifdef ENABLE_PUSH
+ if ( id ().length () > 0 ) {
+ int val = id ().toInt ();
+
+ m_state.m_pushId = val;
+ m_config.m_pushId = val;
+ }
+#endif
}
/*! Returns the sensor config.
@@ -317,6 +344,15 @@
void Sensor::setConfig(const SensorConfig &config)
{
m_config = config;
+
+#ifdef ENABLE_PUSH
+ if ( id ().length () > 0 ) {
+ int val = id ().toInt ();
+
+ m_state.m_pushId = val;
+ m_config.m_pushId = val;
+ }
+#endif
}
/*! Transfers state into JSONString.
@@ -423,6 +459,7 @@
/*! Constructor. */
SensorState::SensorState() :
// m_lastupdated(""),
+ pushSensorVarsInit ()
m_flag(""),
m_status(""),
m_presence(""),
@@ -451,6 +488,8 @@
void SensorState::setLastupdated(const QString &lastupdated)
{
m_lastupdated = lastupdated;
+
+ pushSetSensorStateInfo ( lastupdated );
}
/*! Returns the sensor state flag attribute.
@@ -468,6 +507,8 @@
void SensorState::setFlag(const QString &flag)
{
m_flag = flag;
+
+ pushSetSensorStateInfo ( flag );
}
/*! Returns the sensor state status attribute.
@@ -485,6 +526,8 @@
void SensorState::setStatus(const QString &status)
{
m_status = status;
+
+ pushSetSensorStateInfo ( status );
}
/*! Returns the sensor state presence attribute.
@@ -501,6 +544,8 @@
void SensorState::setPresence(const QString &presence)
{
m_presence = presence;
+
+ pushSetSensorStateInfo ( presence );
}
/*! Returns the sensor state open attribute.
@@ -518,6 +563,8 @@
void SensorState::setOpen(const QString &open)
{
m_open = open;
+
+ pushSetSensorStateInfo ( open );
}
/*! Returns the sensor state buttonevent attribute.
@@ -535,6 +582,8 @@
void SensorState::setButtonevent(int buttonevent)
{
m_buttonevent = buttonevent;
+
+ pushSetSensorStateInfo ( buttonevent );
}
/*! Returns the sensor state temperature attribute.
@@ -552,6 +601,8 @@
void SensorState::setTemperature(const QString &temperature)
{
m_temperature = temperature;
+
+ pushSetSensorStateInfo ( temperature );
}
/*! Returns the sensor state humidity attribute.
@@ -570,6 +621,8 @@
void SensorState::setHumidity(const QString &humidity)
{
m_humidity = humidity;
+
+ pushSetSensorStateInfo ( humidity );
}
/*! Returns the sensor state daylight attribute.
@@ -587,6 +640,8 @@
void SensorState::setDaylight(const QString &daylight)
{
m_daylight = daylight;
+
+ pushSetSensorStateInfo ( daylight );
}
/*! Returns the sensor state lux attribute.
@@ -603,6 +658,8 @@
*/
void SensorState::setLux(quint32 lux)
{
+ pushSetSensorStateInfoMemComp ( lux );
+
m_lux = lux;
}
@@ -612,11 +669,14 @@
{
QDateTime datetime = QDateTime::currentDateTimeUtc();
m_lastupdated = datetime.toString("yyyy-MM-ddTHH:mm:ss"); // ISO 8601
+
+ pushSetSensorStateInfoMem ( lastupdated );
}
// Sensor Config
/*! Constructor. */
SensorConfig::SensorConfig() :
+ pushSensorVarsInit ()
m_on(true),
m_reachable(false),
m_duration(-1),
@@ -644,6 +704,8 @@
void SensorConfig::setOn(bool on)
{
m_on = on;
+
+ pushSetSensorConfigState ( on, -1 );
}
/*! Returns the sensor config reachable attribute.
@@ -661,6 +723,8 @@
void SensorConfig::setReachable(bool reachable)
{
m_reachable = reachable;
+
+ pushSetSensorConfigInfo ( reachable );
}
/*! Returns the sensor config duration attribute.
@@ -680,6 +744,8 @@
DBG_Assert(duration >= 0 && duration < 65535);
if (duration >= 0 && duration <= 65535)
{
+ pushSetSensorConfigInfoMemCompDouble ( duration );
+
m_duration = duration;
}
}
@@ -698,6 +764,8 @@
*/
void SensorConfig::setBattery(quint8 battery)
{
+ pushSetSensorConfigInfoMemComp ( battery );
+
m_battery = battery;
}
@@ -716,6 +784,8 @@
void SensorConfig::setUrl(const QString &url)
{
m_url = url;
+
+ pushSetSensorConfigInfo ( url );
}
/*! Returns the sensor config longitude attribute.
@@ -733,6 +803,8 @@
void SensorConfig::setLongitude(const QString &longitude)
{
m_long = longitude;
+
+ pushSetSensorConfigInfo ( longitude );
}
/*! Returns the sensor config lat attribute.
@@ -750,6 +822,8 @@
void SensorConfig::setLat(const QString &lat)
{
m_lat = lat;
+
+ pushSetSensorConfigInfoName ( lat, "latitude" );
}
/*! Returns the sensor config sunriseoffset attribute.
@@ -767,6 +841,8 @@
void SensorConfig::setSunriseoffset(const QString &sunriseoffset)
{
m_sunriseoffset = sunriseoffset;
+
+ pushSetSensorConfigInfo ( sunriseoffset );
}
/*! Returns the sensor config sunsetoffset attribute.
@@ -784,4 +860,6 @@
void SensorConfig::setSunsetoffset(const QString &sunsetoffset)
{
m_sunsetoffset = sunsetoffset;
+
+ pushSetSensorConfigInfo ( sunsetoffset );
}