mirror of
https://github.com/ckaczor/HomeMonitor.git
synced 2026-01-13 17:22:54 -05:00
Add new values to the UI
This commit is contained in:
@@ -40,7 +40,6 @@
|
|||||||
"highcharts/modules/exporting",
|
"highcharts/modules/exporting",
|
||||||
"highcharts/modules/windbarb",
|
"highcharts/modules/windbarb",
|
||||||
"moment-duration-format",
|
"moment-duration-format",
|
||||||
"regression",
|
|
||||||
"socket.io-client",
|
"socket.io-client",
|
||||||
"socket.io-parser"
|
"socket.io-parser"
|
||||||
]
|
]
|
||||||
|
|||||||
10
Display/package-lock.json
generated
10
Display/package-lock.json
generated
@@ -1810,11 +1810,6 @@
|
|||||||
"integrity": "sha1-vShOV8hPEyXacCur/IKlMoGQwMU=",
|
"integrity": "sha1-vShOV8hPEyXacCur/IKlMoGQwMU=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/regression": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/regression/-/regression-2.0.0.tgz",
|
|
||||||
"integrity": "sha512-Ch2FD53M1HpFLL6zSTc/sfuyqQcIPy+/PV3xFT6QYtk9EOiMI29XOYmLNxBb1Y0lfMOR/NNa86J1gRc/1jGLyw=="
|
|
||||||
},
|
|
||||||
"@types/selenium-webdriver": {
|
"@types/selenium-webdriver": {
|
||||||
"version": "3.0.17",
|
"version": "3.0.17",
|
||||||
"resolved": "https://registry.npmjs.org/@types/selenium-webdriver/-/selenium-webdriver-3.0.17.tgz",
|
"resolved": "https://registry.npmjs.org/@types/selenium-webdriver/-/selenium-webdriver-3.0.17.tgz",
|
||||||
@@ -10206,11 +10201,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"regression": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/regression/-/regression-2.0.1.tgz",
|
|
||||||
"integrity": "sha1-jSnD6CJKEIUMNeM36FqLL6w7DIc="
|
|
||||||
},
|
|
||||||
"remove-trailing-separator": {
|
"remove-trailing-separator": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz",
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
"@angular/router": "~10.0.1",
|
"@angular/router": "~10.0.1",
|
||||||
"@aspnet/signalr": "^1.1.4",
|
"@aspnet/signalr": "^1.1.4",
|
||||||
"@types/moment-duration-format": "^2.2.2",
|
"@types/moment-duration-format": "^2.2.2",
|
||||||
"@types/regression": "^2.0.0",
|
|
||||||
"@types/suncalc": "^1.8.0",
|
"@types/suncalc": "^1.8.0",
|
||||||
"angular-gridster2": "^10.0.1",
|
"angular-gridster2": "^10.0.1",
|
||||||
"angular-highcharts": "^9.0.11",
|
"angular-highcharts": "^9.0.11",
|
||||||
@@ -33,7 +32,6 @@
|
|||||||
"moment-duration-format": "^2.3.2",
|
"moment-duration-format": "^2.3.2",
|
||||||
"ngx-moment": "^4.0.1",
|
"ngx-moment": "^4.0.1",
|
||||||
"ngx-socket-io": "^3.2.0",
|
"ngx-socket-io": "^3.2.0",
|
||||||
"regression": "^2.0.1",
|
|
||||||
"rxjs": "~6.5.5",
|
"rxjs": "~6.5.5",
|
||||||
"suncalc": "^1.8.0",
|
"suncalc": "^1.8.0",
|
||||||
"tslib": "^2.0.0",
|
"tslib": "^2.0.0",
|
||||||
|
|||||||
@@ -13,6 +13,22 @@
|
|||||||
{{ latestReading.PressureTemperature.toFixed(2) }}°F
|
{{ latestReading.PressureTemperature.toFixed(2) }}°F
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr *ngIf="latestReading.HeatIndex">
|
||||||
|
<td class="weather-current-header">
|
||||||
|
Heat Index
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ latestReading.HeatIndex.toFixed(2) }}°F
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr *ngIf="latestReading.WindChill">
|
||||||
|
<td class="weather-current-header">
|
||||||
|
Wind Chill
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ latestReading.WindChill.toFixed(2) }}°F
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="weather-current-header">
|
<td class="weather-current-header">
|
||||||
Humidity
|
Humidity
|
||||||
@@ -21,6 +37,14 @@
|
|||||||
{{ latestReading.Humidity.toFixed(2) }}%
|
{{ latestReading.Humidity.toFixed(2) }}%
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="weather-current-header">
|
||||||
|
Dew point
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ latestReading.DewPoint.toFixed(2) }}°F
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="weather-current-header">
|
<td class="weather-current-header">
|
||||||
Pressure
|
Pressure
|
||||||
@@ -28,7 +52,7 @@
|
|||||||
<td>
|
<td>
|
||||||
{{ (latestReading.Pressure / 33.864 / 100).toFixed(2) }}"
|
{{ (latestReading.Pressure / 33.864 / 100).toFixed(2) }}"
|
||||||
|
|
||||||
<span *ngIf="pressureDifference !== null" class="pressure-trend-arrow" [ngClass]="rotationClass()" title="Trend: {{ pressureDifference.toFixed(1) }}">➜</span>
|
<span class="pressure-trend-arrow" [ngClass]="rotationClass()" title="Trend: {{ latestReading.PressureTrend.toFixed(1) }}">➜</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { WeatherReading } from 'src/app/models/weather/weather-reading';
|
import { WeatherReading } from 'src/app/models/weather/weather-reading';
|
||||||
import { WeatherService } from 'src/app/services/weather/weather.service';
|
import { WeatherService } from 'src/app/services/weather/weather.service';
|
||||||
import { WeatherValueType } from 'src/app/models/weather/weather-value-type';
|
|
||||||
import { WeatherValue } from 'src/app/models/weather/weather-value';
|
|
||||||
|
|
||||||
import * as moment from 'moment';
|
|
||||||
import * as regression from 'regression';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-weather-current',
|
selector: 'app-weather-current',
|
||||||
@@ -13,57 +8,28 @@ import * as regression from 'regression';
|
|||||||
styleUrls: ['./weather-current.component.scss']
|
styleUrls: ['./weather-current.component.scss']
|
||||||
})
|
})
|
||||||
export class WeatherCurrentComponent implements OnInit {
|
export class WeatherCurrentComponent implements OnInit {
|
||||||
public pressureDifference: number = null;
|
|
||||||
public latestReading: WeatherReading;
|
public latestReading: WeatherReading;
|
||||||
|
|
||||||
constructor(private weatherService: WeatherService) { }
|
constructor(private weatherService: WeatherService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.update();
|
|
||||||
|
|
||||||
setInterval(() => this.update(), 60000);
|
|
||||||
|
|
||||||
this.weatherService.getLatestReading().subscribe(r => this.latestReading = r);
|
this.weatherService.getLatestReading().subscribe(r => this.latestReading = r);
|
||||||
}
|
}
|
||||||
|
|
||||||
async update() {
|
|
||||||
this.pressureDifference = null;
|
|
||||||
|
|
||||||
const end: moment.Moment = moment();
|
|
||||||
const start: moment.Moment = moment(end).subtract(3, 'hours');
|
|
||||||
|
|
||||||
const weatherData = await this.weatherService.getReadingValueHistory(WeatherValueType.Pressure, start, end);
|
|
||||||
|
|
||||||
if (!weatherData) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const points: [number, number][] = [];
|
|
||||||
|
|
||||||
weatherData.forEach((weatherValue: WeatherValue) => {
|
|
||||||
const point: [number, number] = [moment(weatherValue.timestamp).unix(), weatherValue.value / 100];
|
|
||||||
points.push(point);
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = regression.linear(points, { precision: 10 });
|
|
||||||
|
|
||||||
const regressionPoints = result.points;
|
|
||||||
|
|
||||||
this.pressureDifference = regressionPoints[regressionPoints.length - 1][1] - regressionPoints[0][1];
|
|
||||||
}
|
|
||||||
|
|
||||||
rotationClass(): string {
|
rotationClass(): string {
|
||||||
if (!this.pressureDifference) {
|
const pressureDifference = this.latestReading.PressureTrend;
|
||||||
|
|
||||||
|
if (!pressureDifference) {
|
||||||
return '';
|
return '';
|
||||||
} else if (Math.abs(this.pressureDifference) <= 1.0) {
|
} else if (Math.abs(pressureDifference) <= 1.0) {
|
||||||
return '';
|
return '';
|
||||||
} else if (this.pressureDifference > 1.0 && this.pressureDifference <= 2.0) {
|
} else if (pressureDifference > 1.0 && pressureDifference <= 2.0) {
|
||||||
return 'up-low';
|
return 'up-low';
|
||||||
} else if (this.pressureDifference > 2.0) {
|
} else if (pressureDifference > 2.0) {
|
||||||
return 'up-high';
|
return 'up-high';
|
||||||
} else if (this.pressureDifference < -1.0 && this.pressureDifference >= -2.0) {
|
} else if (pressureDifference < -1.0 && pressureDifference >= -2.0) {
|
||||||
return 'down-low';
|
return 'down-low';
|
||||||
} else if (this.pressureDifference < -2.0) {
|
} else if (pressureDifference < -2.0) {
|
||||||
return 'down-high';
|
return 'down-high';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,4 +16,8 @@ export class WeatherReading {
|
|||||||
Altitude: number;
|
Altitude: number;
|
||||||
SatelliteCount: number;
|
SatelliteCount: number;
|
||||||
GpsTimestamp: Date;
|
GpsTimestamp: Date;
|
||||||
|
WindChill: number;
|
||||||
|
HeatIndex: number;
|
||||||
|
DewPoint: number;
|
||||||
|
PressureTrend: number;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user