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/windbarb",
|
||||
"moment-duration-format",
|
||||
"regression",
|
||||
"socket.io-client",
|
||||
"socket.io-parser"
|
||||
]
|
||||
|
||||
10
Display/package-lock.json
generated
10
Display/package-lock.json
generated
@@ -1810,11 +1810,6 @@
|
||||
"integrity": "sha1-vShOV8hPEyXacCur/IKlMoGQwMU=",
|
||||
"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": {
|
||||
"version": "3.0.17",
|
||||
"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": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz",
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
"@angular/router": "~10.0.1",
|
||||
"@aspnet/signalr": "^1.1.4",
|
||||
"@types/moment-duration-format": "^2.2.2",
|
||||
"@types/regression": "^2.0.0",
|
||||
"@types/suncalc": "^1.8.0",
|
||||
"angular-gridster2": "^10.0.1",
|
||||
"angular-highcharts": "^9.0.11",
|
||||
@@ -33,7 +32,6 @@
|
||||
"moment-duration-format": "^2.3.2",
|
||||
"ngx-moment": "^4.0.1",
|
||||
"ngx-socket-io": "^3.2.0",
|
||||
"regression": "^2.0.1",
|
||||
"rxjs": "~6.5.5",
|
||||
"suncalc": "^1.8.0",
|
||||
"tslib": "^2.0.0",
|
||||
|
||||
@@ -13,6 +13,22 @@
|
||||
{{ latestReading.PressureTemperature.toFixed(2) }}°F
|
||||
</td>
|
||||
</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>
|
||||
<td class="weather-current-header">
|
||||
Humidity
|
||||
@@ -21,6 +37,14 @@
|
||||
{{ latestReading.Humidity.toFixed(2) }}%
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="weather-current-header">
|
||||
Dew point
|
||||
</td>
|
||||
<td>
|
||||
{{ latestReading.DewPoint.toFixed(2) }}°F
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="weather-current-header">
|
||||
Pressure
|
||||
@@ -28,7 +52,7 @@
|
||||
<td>
|
||||
{{ (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>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { WeatherReading } from 'src/app/models/weather/weather-reading';
|
||||
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({
|
||||
selector: 'app-weather-current',
|
||||
@@ -13,57 +8,28 @@ import * as regression from 'regression';
|
||||
styleUrls: ['./weather-current.component.scss']
|
||||
})
|
||||
export class WeatherCurrentComponent implements OnInit {
|
||||
public pressureDifference: number = null;
|
||||
public latestReading: WeatherReading;
|
||||
|
||||
constructor(private weatherService: WeatherService) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.update();
|
||||
|
||||
setInterval(() => this.update(), 60000);
|
||||
|
||||
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 {
|
||||
if (!this.pressureDifference) {
|
||||
const pressureDifference = this.latestReading.PressureTrend;
|
||||
|
||||
if (!pressureDifference) {
|
||||
return '';
|
||||
} else if (Math.abs(this.pressureDifference) <= 1.0) {
|
||||
} else if (Math.abs(pressureDifference) <= 1.0) {
|
||||
return '';
|
||||
} else if (this.pressureDifference > 1.0 && this.pressureDifference <= 2.0) {
|
||||
} else if (pressureDifference > 1.0 && pressureDifference <= 2.0) {
|
||||
return 'up-low';
|
||||
} else if (this.pressureDifference > 2.0) {
|
||||
} else if (pressureDifference > 2.0) {
|
||||
return 'up-high';
|
||||
} else if (this.pressureDifference < -1.0 && this.pressureDifference >= -2.0) {
|
||||
} else if (pressureDifference < -1.0 && pressureDifference >= -2.0) {
|
||||
return 'down-low';
|
||||
} else if (this.pressureDifference < -2.0) {
|
||||
} else if (pressureDifference < -2.0) {
|
||||
return 'down-high';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,4 +16,8 @@ export class WeatherReading {
|
||||
Altitude: number;
|
||||
SatelliteCount: number;
|
||||
GpsTimestamp: Date;
|
||||
WindChill: number;
|
||||
HeatIndex: number;
|
||||
DewPoint: number;
|
||||
PressureTrend: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user