From fed2d7a71a8cb59a24abd67204f9b25e7c1d13bb Mon Sep 17 00:00:00 2001 From: felixerdy Date: Tue, 10 Dec 2019 15:22:52 +0100 Subject: [PATCH] feat(registration): Add BME680 and soil moisture sensor with port selection --- .../controllers/account.box.edit.script.js | 7 ++ app/scripts/controllers/register.js | 70 +++++++++++- app/views/account.box.edit.script.html | 14 +++ app/views/account.box.register.html | 107 ++++++++++++++++++ 4 files changed, 196 insertions(+), 2 deletions(-) diff --git a/app/scripts/controllers/account.box.edit.script.js b/app/scripts/controllers/account.box.edit.script.js index c62a98b0..a4f99d20 100644 --- a/app/scripts/controllers/account.box.edit.script.js +++ b/app/scripts/controllers/account.box.edit.script.js @@ -15,6 +15,8 @@ vm.boxScript = ''; vm.showConfiguration = false; vm.showSerialPort = false; + vm.soilDigitalPort = 'A'; + vm.showSoilDigitalPort = false; vm.compiling = false; vm.wifi = { ssid: '', @@ -37,6 +39,10 @@ vm.showSerialPort = true; } + if (boxData.sensorsArray.filter(s => s.sensorType === 'SMT50').length > 0) { + vm.showSoilDigitalPort = true; + } + return getScript(); } @@ -49,6 +55,7 @@ function getScript () { return AccountService.getScript(boxData._id, { serialPort: vm.serialPort, + soilDigitalPort: vm.soilDigitalPort, ssid: vm.wifi.ssid, password: vm.wifi.password }) diff --git a/app/scripts/controllers/register.js b/app/scripts/controllers/register.js index be0e11dc..d9baaaf8 100644 --- a/app/scripts/controllers/register.js +++ b/app/scripts/controllers/register.js @@ -33,9 +33,12 @@ temp: false, pressure: false, light: false, - pollution: false + pollution: false, + bme680: false, }, - serialPort: 'Serial1' + serialPort: 'Serial1', + soilDigitalPort: 'A', + bmePhenomenon: 'tempHumiPress' }; vm.wifi = { @@ -69,6 +72,14 @@ vm.extensions = { feinstaub: { id: '' + }, + soilMoisture: { + id: '', + port: 'A' + }, + soundLevelMeter: { + id: '', + port: 'B' } }; @@ -166,6 +177,7 @@ function getScript () { return AccountService.getScript(vm.newSenseBox.id, { serialPort: vm.newSenseBox.serialPort, + soilDigitalPort: vm.newSenseBox.soilDigitalPort, ssid: vm.wifi.ssid, password: vm.wifi.password }) @@ -310,6 +322,7 @@ var data = {}; if (model.startsWith('homeV2')) { data.serialPort = vm.newModel.serialPort; + data.soilDigitalPort = vm.newSenseBox.soilDigitalPort; } AccountService.getScript(boxId, data) .then(function (data) { @@ -365,6 +378,9 @@ vm.newSenseBox.sensorTemplates.push('veml6070'); vm.newSenseBox.sensorTemplates.push('tsl45315'); break; + case 'bme680': + vm.newSenseBox.sensorTemplates.push('bme680'); + break; } } } @@ -373,6 +389,14 @@ vm.newSenseBox.sensorTemplates.push('sds 011'); vm.newSenseBox.serialPort = vm.newModel.serialPort; } + if (vm.extensions.soilMoisture.id !== '') { + vm.newSenseBox.sensorTemplates.push('smt50'); + vm.newSenseBox.soilDigitalPort = vm.extensions.soilMoisture.port; + } + if (vm.extensions.soundLevelMeter.id !== '') { + vm.newSenseBox.sensorTemplates.push('soundlevelmeter'); + vm.newSenseBox.soundLevelMeterPort = vm.extensions.soundLevelMeter.port; + } } if (vm.newModel.connection) { @@ -476,6 +500,30 @@ unit = 'μW/cm²'; sensorType = 'VEML6070'; break; + case 'BME680_TEMPERATURE': + icon = 'osem-thermometer'; + title = 'Temperatur'; + unit = '°C'; + sensorType = 'BME680'; + break; + case 'BME680_HUMIDITY': + icon = 'osem-humidity'; + title = 'rel. Luftfeuchte'; + unit = '%'; + sensorType = 'BME680'; + break; + case 'BME680_PRESSURE': + icon = 'osem-barometer'; + title = 'Luftdruck'; + unit = 'hPa'; + sensorType = 'BME680'; + break; + case 'BME680_VOC': + icon = 'osem-barometer'; + title = 'VOC'; + unit = 'kΩ'; + sensorType = 'BME680'; + break; case 'PM25': icon = 'osem-cloud'; title = 'PM2.5'; @@ -488,6 +536,24 @@ unit = 'µg/m³'; sensorType = 'SDS 011'; break; + case 'smt50_soilmoisture': + icon = 'osem-humidity'; + title = 'Bodenfeuchte'; + unit = '%'; + sensorType = 'SMT50'; + break; + case 'smt50_soiltemperature': + icon = 'osem-thermometer'; + title = 'Bodentemperatur'; + unit = '°C'; + sensorType = 'SMT50'; + break; + case 'soundlevelmeter': + icon = 'osem-microphone'; + title = 'Lautstärke'; + unit = 'dB'; + sensorType = 'soundlevelmeter'; + break; } add(icon, title, unit, sensorType); } diff --git a/app/views/account.box.edit.script.html b/app/views/account.box.edit.script.html index 1d3f3b67..8f302ecf 100644 --- a/app/views/account.box.edit.script.html +++ b/app/views/account.box.edit.script.html @@ -21,6 +21,20 @@

{{'CONFIGURATION'|translate}}

+
+ +
+ +
+ +
+
+
{{'SENSORS' | translate}}
+
+
+
+
+ + +
+ + BME680 +
+
+ +
@@ -357,6 +387,69 @@

{{'SENSORS' | translate}}

+
+
+
+
+ + +
+ + {{'SOIL_MOISTURE' | translate}} +
+
+
+
+ +
+ +
+
+
+
+ @@ -1151,6 +1244,20 @@
+
+ +
+ +
+ +
+
+