Browse Source

add wind & rain sensors

master
Norwin 1 year ago
parent
commit
19dc2e83e1
4 changed files with 91 additions and 19 deletions
  1. +9
    -0
      app/assets/scripts/actions/action-types.js
  2. +3
    -0
      app/assets/scripts/config/production.js
  3. +6
    -0
      app/assets/scripts/reducers/reducer.js
  4. +73
    -19
      app/assets/scripts/views/home.js

+ 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';
export const REQUEST_SENSOR_DATA_PM25 = 'REQUEST_SENSOR_DATA_PM25';
export const RECEIVE_SENSOR_DATA_PM25 = 'RECEIVE_SENSOR_DATA_PM25';
export const REQUEST_SENSOR_DATA_WINDDIR = 'REQUEST_SENSOR_DATA_WINDDIR';
export const RECEIVE_SENSOR_DATA_WINDDIR = 'RECEIVE_SENSOR_DATA_WINDDIR';
export const REQUEST_SENSOR_DATA_WINDSPEED = 'REQUEST_SENSOR_DATA_WINDSPEED';
export const RECEIVE_SENSOR_DATA_WINDSPEED = 'RECEIVE_SENSOR_DATA_WINDSPEED';
export const REQUEST_SENSOR_DATA_RAIN = 'REQUEST_SENSOR_DATA_RAIN';
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 = {
title: 'Begga Weer',
senseBox: {
id: '5b26181b1fef04001b69093c',
'sensorId--rain': '5cd6818eff898b001a7366d8',
'sensorId--windSpeed': '5cd6818eff898b001a7366d7',
'sensorId--windDir': '5cd6818eff898b001a7366d6',
'sensorId--pm25': '5b26181b1fef04001b69093d',
'sensorId--pm10': '5b26181b1fef04001b69093e',
'sensorId--uv': '5b26181b1fef04001b69093f',

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

@ -31,6 +31,9 @@ const sensorHumidity = sensorReducerFactory('humidity');
const sensorTemperature = sensorReducerFactory('temperature');
const sensorPm10 = sensorReducerFactory('pm10');
const sensorPm25 = sensorReducerFactory('pm25');
const sensorWindDir = sensorReducerFactory('windDir');
const sensorWindSpeed = sensorReducerFactory('windSpeed');
const sensorRain = sensorReducerFactory('rain');
export default combineReducers({
routing: routeReducer,
@ -41,4 +44,7 @@ export default combineReducers({
sensorTemperature,
sensorPm10,
sensorPm25,
sensorWindDir,
sensorWindSpeed,
sensorRain,
});

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

@ -29,6 +29,9 @@ var Home = React.createClass({
sensorTemperature: sensorProps,
sensorPm10: sensorProps,
sensorPm25: sensorProps,
sensorWindDir: sensorProps,
sensorWindSpeed: sensorProps,
sensorRain: sensorProps,
},
// Having measurements every minute is too much. Group them.
@ -131,6 +134,9 @@ var Home = React.createClass({
this.props._requestSensorData('pressure', daysAgo3);
this.props._requestSensorData('pm10', daysAgo3);
this.props._requestSensorData('pm25', daysAgo3);
this.props._requestSensorData('windDir', daysAgo3);
this.props._requestSensorData('windSpeed', daysAgo3);
this.props._requestSensorData('rain', daysAgo3);
},
componentDidMount: function () {
@ -150,10 +156,13 @@ var Home = React.createClass({
let sensorTemperatureData = this.prepareData(this.props.sensorTemperature.data);
let sensorHumidityData = this.prepareData(this.props.sensorHumidity.data);
let sensorUvData = this.prepareData(this.props.sensorUv.data);
// let sensorLuminosityData = this.prepareData(this.props.sensorLuminosity.data);
// let sensorPressureData = this.prepareData(this.props.sensorPressure.data);
let sensorLuminosityData = this.prepareData(this.props.sensorLuminosity.data);
let sensorPressureData = this.prepareData(this.props.sensorPressure.data);
let sensorPm10Data = this.prepareData(this.props.sensorPm10.data);
let sensorPm25Data = this.prepareData(this.props.sensorPm25.data);
let sensorWindDirData = this.prepareData(this.props.sensorWindDir.data);
let sensorWindSpeedData = this.prepareData(this.props.sensorWindSpeed.data);
let sensorRainData = this.prepareData(this.props.sensorRain.data);
return (
<section className='page'>
@ -177,14 +186,28 @@ var Home = React.createClass({
lastReading={sensorTemperatureData.last}
avgs={sensorTemperatureData.avgs}
plotData={sensorTemperatureData.data}
axisLineMax={35}
axisLineMax={40}
axisLineVal={20}
axisLineMin={4}
axisLineMin={0}
unit=' ºC'
/>
<SensorWidget
className='card--hum'
fetching={this.props.sensorPressure.fetching}
fetched={this.props.sensorPressure.fetched}
title='Luftdruck'
lastReading={sensorPressureData.last}
avgs={sensorPressureData.avgs}
plotData={sensorPressureData.data}
axisLineMax={1020}
axisLineVal={1010}
axisLineMin={980}
unit=' hPa'
/>
<SensorWidget
className='card--press'
fetching={this.props.sensorHumidity.fetching}
fetched={this.props.sensorHumidity.fetched}
title='rel. Luftfeuchte'
@ -197,8 +220,50 @@ var Home = React.createClass({
unit=' %'
/>
<SensorWidget
className='card--press'
fetching={this.props.sensorRain.fetching}
fetched={this.props.sensorRain.fetched}
title='Niederschlag'
lastReading={sensorRainData.last}
avgs={sensorRainData.avgs}
plotData={sensorRainData.data}
axisLineMax={10}
axisLineVal={5}
axisLineMin={0}
unit=' L/m² / 5 Min'
/>
<SensorWidget
className='card--uv'
fetching={this.props.sensorWindDir.fetching}
fetched={this.props.sensorWindDir.fetched}
title='Windrichtung'
lastReading={sensorWindDirData.last}
avgs={sensorWindDirData.avgs}
plotData={sensorWindDirData.data}
axisLineMax={360}
axisLineVal={180}
axisLineMin={0}
unit=' °'
/>
<SensorWidget
className='card--uv'
fetching={this.props.sensorWindSpeed.fetching}
fetched={this.props.sensorWindSpeed.fetched}
title='Windgeschwindigkeit'
lastReading={sensorWindSpeedData.last}
avgs={sensorWindSpeedData.avgs}
plotData={sensorWindSpeedData.data}
axisLineMax={90}
axisLineVal={30}
axisLineMin={0}
unit=' km/h'
/>
<SensorWidget
className='card--lux'
fetching={this.props.sensorUv.fetching}
fetched={this.props.sensorUv.fetched}
title='Uv Licht'
@ -211,7 +276,7 @@ var Home = React.createClass({
unit=' μW/cm²'
/>
{/* <SensorWidget
<SensorWidget
className='card--lux'
fetching={this.props.sensorLuminosity.fetching}
fetched={this.props.sensorLuminosity.fetched}
@ -225,20 +290,6 @@ var Home = React.createClass({
unit=' lx'
/>
<SensorWidget
className='card--press'
fetching={this.props.sensorPressure.fetching}
fetched={this.props.sensorPressure.fetched}
title='Luftdruck'
lastReading={sensorPressureData.last}
avgs={sensorPressureData.avgs}
plotData={sensorPressureData.data}
axisLineMax={1020}
axisLineVal={1010}
axisLineMin={1000}
unit=' hPa'
/> */}
<SensorWidget
className='card--pm'
fetching={this.props.sensorPm10.fetching}
@ -287,6 +338,9 @@ function selector (state) {
sensorTemperature: state.sensorTemperature,
sensorPm10: state.sensorPm10,
sensorPm25: state.sensorPm25,
sensorWindDir: state.sensorWindDir,
sensorWindSpeed: state.sensorWindSpeed,
sensorRain: state.sensorRain,
};
}

Loading…
Cancel
Save