Browse Source

add wind & rain sensors

master
Norwin Roosen 1 week ago
parent
commit
19dc2e83e1

+ 9
- 0
app/assets/scripts/actions/action-types.js View File

@@ -19,3 +19,12 @@ export const RECEIVE_SENSOR_DATA_PM10 = 'RECEIVE_SENSOR_DATA_PM10';
19 19
 
20 20
 export const REQUEST_SENSOR_DATA_PM25 = 'REQUEST_SENSOR_DATA_PM25';
21 21
 export const RECEIVE_SENSOR_DATA_PM25 = 'RECEIVE_SENSOR_DATA_PM25';
22
+
23
+export const REQUEST_SENSOR_DATA_WINDDIR = 'REQUEST_SENSOR_DATA_WINDDIR';
24
+export const RECEIVE_SENSOR_DATA_WINDDIR = 'RECEIVE_SENSOR_DATA_WINDDIR';
25
+
26
+export const REQUEST_SENSOR_DATA_WINDSPEED = 'REQUEST_SENSOR_DATA_WINDSPEED';
27
+export const RECEIVE_SENSOR_DATA_WINDSPEED = 'RECEIVE_SENSOR_DATA_WINDSPEED';
28
+
29
+export const REQUEST_SENSOR_DATA_RAIN = 'REQUEST_SENSOR_DATA_RAIN';
30
+export const RECEIVE_SENSOR_DATA_RAIN = 'RECEIVE_SENSOR_DATA_RAIN';

+ 3
- 0
app/assets/scripts/config/production.js View File

@@ -8,6 +8,9 @@ module.exports = {
8 8
   title: 'Begga Weer',
9 9
   senseBox: {
10 10
     id: '5b26181b1fef04001b69093c',
11
+    'sensorId--rain': '5cd6818eff898b001a7366d8',
12
+    'sensorId--windSpeed': '5cd6818eff898b001a7366d7',
13
+    'sensorId--windDir': '5cd6818eff898b001a7366d6',
11 14
     'sensorId--pm25': '5b26181b1fef04001b69093d',
12 15
     'sensorId--pm10': '5b26181b1fef04001b69093e',
13 16
     'sensorId--uv': '5b26181b1fef04001b69093f',

+ 6
- 0
app/assets/scripts/reducers/reducer.js View File

@@ -31,6 +31,9 @@ const sensorHumidity = sensorReducerFactory('humidity');
31 31
 const sensorTemperature = sensorReducerFactory('temperature');
32 32
 const sensorPm10 = sensorReducerFactory('pm10');
33 33
 const sensorPm25 = sensorReducerFactory('pm25');
34
+const sensorWindDir = sensorReducerFactory('windDir');
35
+const sensorWindSpeed = sensorReducerFactory('windSpeed');
36
+const sensorRain = sensorReducerFactory('rain');
34 37
 
35 38
 export default combineReducers({
36 39
   routing: routeReducer,
@@ -41,4 +44,7 @@ export default combineReducers({
41 44
   sensorTemperature,
42 45
   sensorPm10,
43 46
   sensorPm25,
47
+  sensorWindDir,
48
+  sensorWindSpeed,
49
+  sensorRain,
44 50
 });

+ 73
- 19
app/assets/scripts/views/home.js View File

@@ -29,6 +29,9 @@ var Home = React.createClass({
29 29
     sensorTemperature: sensorProps,
30 30
     sensorPm10: sensorProps,
31 31
     sensorPm25: sensorProps,
32
+    sensorWindDir: sensorProps,
33
+    sensorWindSpeed: sensorProps,
34
+    sensorRain: sensorProps,
32 35
   },
33 36
 
34 37
   // Having measurements every minute is too much. Group them.
@@ -131,6 +134,9 @@ var Home = React.createClass({
131 134
     this.props._requestSensorData('pressure', daysAgo3);
132 135
     this.props._requestSensorData('pm10', daysAgo3);
133 136
     this.props._requestSensorData('pm25', daysAgo3);
137
+    this.props._requestSensorData('windDir', daysAgo3);
138
+    this.props._requestSensorData('windSpeed', daysAgo3);
139
+    this.props._requestSensorData('rain', daysAgo3);
134 140
   },
135 141
 
136 142
   componentDidMount: function () {
@@ -150,10 +156,13 @@ var Home = React.createClass({
150 156
     let sensorTemperatureData = this.prepareData(this.props.sensorTemperature.data);
151 157
     let sensorHumidityData = this.prepareData(this.props.sensorHumidity.data);
152 158
     let sensorUvData = this.prepareData(this.props.sensorUv.data);
153
-    // let sensorLuminosityData = this.prepareData(this.props.sensorLuminosity.data);
154
-    // let sensorPressureData = this.prepareData(this.props.sensorPressure.data);
159
+    let sensorLuminosityData = this.prepareData(this.props.sensorLuminosity.data);
160
+    let sensorPressureData = this.prepareData(this.props.sensorPressure.data);
155 161
     let sensorPm10Data = this.prepareData(this.props.sensorPm10.data);
156 162
     let sensorPm25Data = this.prepareData(this.props.sensorPm25.data);
163
+    let sensorWindDirData = this.prepareData(this.props.sensorWindDir.data);
164
+    let sensorWindSpeedData = this.prepareData(this.props.sensorWindSpeed.data);
165
+    let sensorRainData = this.prepareData(this.props.sensorRain.data);
157 166
 
158 167
     return (
159 168
       <section className='page'>
@@ -177,14 +186,28 @@ var Home = React.createClass({
177 186
                 lastReading={sensorTemperatureData.last}
178 187
                 avgs={sensorTemperatureData.avgs}
179 188
                 plotData={sensorTemperatureData.data}
180
-                axisLineMax={35}
189
+                axisLineMax={40}
181 190
                 axisLineVal={20}
182
-                axisLineMin={4}
191
+                axisLineMin={0}
183 192
                 unit=' ºC'
184 193
               />
185 194
 
186 195
               <SensorWidget
187 196
                 className='card--hum'
197
+                fetching={this.props.sensorPressure.fetching}
198
+                fetched={this.props.sensorPressure.fetched}
199
+                title='Luftdruck'
200
+                lastReading={sensorPressureData.last}
201
+                avgs={sensorPressureData.avgs}
202
+                plotData={sensorPressureData.data}
203
+                axisLineMax={1020}
204
+                axisLineVal={1010}
205
+                axisLineMin={980}
206
+                unit=' hPa'
207
+              />
208
+
209
+              <SensorWidget
210
+                className='card--press'
188 211
                 fetching={this.props.sensorHumidity.fetching}
189 212
                 fetched={this.props.sensorHumidity.fetched}
190 213
                 title='rel. Luftfeuchte'
@@ -197,8 +220,50 @@ var Home = React.createClass({
197 220
                 unit=' %'
198 221
               />
199 222
 
223
+              <SensorWidget
224
+                className='card--press'
225
+                fetching={this.props.sensorRain.fetching}
226
+                fetched={this.props.sensorRain.fetched}
227
+                title='Niederschlag'
228
+                lastReading={sensorRainData.last}
229
+                avgs={sensorRainData.avgs}
230
+                plotData={sensorRainData.data}
231
+                axisLineMax={10}
232
+                axisLineVal={5}
233
+                axisLineMin={0}
234
+                unit=' L/m² / 5 Min'
235
+              />
236
+
237
+              <SensorWidget
238
+                className='card--uv'
239
+                fetching={this.props.sensorWindDir.fetching}
240
+                fetched={this.props.sensorWindDir.fetched}
241
+                title='Windrichtung'
242
+                lastReading={sensorWindDirData.last}
243
+                avgs={sensorWindDirData.avgs}
244
+                plotData={sensorWindDirData.data}
245
+                axisLineMax={360}
246
+                axisLineVal={180}
247
+                axisLineMin={0}
248
+                unit=' °'
249
+              />
250
+
200 251
               <SensorWidget
201 252
                 className='card--uv'
253
+                fetching={this.props.sensorWindSpeed.fetching}
254
+                fetched={this.props.sensorWindSpeed.fetched}
255
+                title='Windgeschwindigkeit'
256
+                lastReading={sensorWindSpeedData.last}
257
+                avgs={sensorWindSpeedData.avgs}
258
+                plotData={sensorWindSpeedData.data}
259
+                axisLineMax={90}
260
+                axisLineVal={30}
261
+                axisLineMin={0}
262
+                unit=' km/h'
263
+              />
264
+
265
+              <SensorWidget
266
+                className='card--lux'
202 267
                 fetching={this.props.sensorUv.fetching}
203 268
                 fetched={this.props.sensorUv.fetched}
204 269
                 title='Uv Licht'
@@ -211,7 +276,7 @@ var Home = React.createClass({
211 276
                 unit=' μW/cm²'
212 277
               />
213 278
 
214
-              {/* <SensorWidget
279
+              <SensorWidget
215 280
                 className='card--lux'
216 281
                 fetching={this.props.sensorLuminosity.fetching}
217 282
                 fetched={this.props.sensorLuminosity.fetched}
@@ -225,20 +290,6 @@ var Home = React.createClass({
225 290
                 unit=' lx'
226 291
               />
227 292
 
228
-              <SensorWidget
229
-                className='card--press'
230
-                fetching={this.props.sensorPressure.fetching}
231
-                fetched={this.props.sensorPressure.fetched}
232
-                title='Luftdruck'
233
-                lastReading={sensorPressureData.last}
234
-                avgs={sensorPressureData.avgs}
235
-                plotData={sensorPressureData.data}
236
-                axisLineMax={1020}
237
-                axisLineVal={1010}
238
-                axisLineMin={1000}
239
-                unit=' hPa'
240
-              /> */}
241
-
242 293
               <SensorWidget
243 294
                 className='card--pm'
244 295
                 fetching={this.props.sensorPm10.fetching}
@@ -287,6 +338,9 @@ function selector (state) {
287 338
     sensorTemperature: state.sensorTemperature,
288 339
     sensorPm10: state.sensorPm10,
289 340
     sensorPm25: state.sensorPm25,
341
+    sensorWindDir: state.sensorWindDir,
342
+    sensorWindSpeed: state.sensorWindSpeed,
343
+    sensorRain: state.sensorRain,
290 344
   };
291 345
 }
292 346
 

Loading…
Cancel
Save