mirror of
https://github.com/ckaczor/HomeMonitor.git
synced 2026-01-14 01:25:38 -05:00
Quick and dirty strict checks
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
</button>
|
||||
</header>
|
||||
<gridster class="content" [options]="options">
|
||||
<gridster-item [item]="dashboardLayout.layout[0]">
|
||||
<gridster-item [item]="dashboardLayout!.layout![0]">
|
||||
<div class="dashboard-item">
|
||||
<div class="dashboard-item-header">
|
||||
Weather
|
||||
@@ -20,7 +20,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</gridster-item>
|
||||
<gridster-item [item]="dashboardLayout.layout[1]">
|
||||
<gridster-item [item]="dashboardLayout!.layout![1]">
|
||||
<div class="dashboard-item">
|
||||
<div class="dashboard-item-header">
|
||||
Laundry
|
||||
@@ -30,7 +30,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</gridster-item>
|
||||
<gridster-item [item]="dashboardLayout.layout[2]">
|
||||
<gridster-item [item]="dashboardLayout!.layout![2]">
|
||||
<div class="dashboard-item">
|
||||
<div class="dashboard-item-header">
|
||||
Almanac
|
||||
@@ -40,7 +40,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</gridster-item>
|
||||
<gridster-item [item]="dashboardLayout.layout[3]">
|
||||
<gridster-item [item]="dashboardLayout!.layout![3]">
|
||||
<div class="dashboard-item">
|
||||
<div class="dashboard-item-header">
|
||||
Power
|
||||
|
||||
@@ -8,8 +8,8 @@ import { DashboardLayout } from 'src/app/models/dashboard/dashboard-layout';
|
||||
styleUrls: ['./dashboard.component.scss']
|
||||
})
|
||||
export class DashboardComponent implements OnInit {
|
||||
public options: GridsterConfig;
|
||||
public dashboardLayout: DashboardLayout;
|
||||
public options: GridsterConfig | undefined;
|
||||
public dashboardLayout: DashboardLayout | undefined;
|
||||
public locked = true;
|
||||
|
||||
private defaultLayout: DashboardLayout = {
|
||||
@@ -46,14 +46,14 @@ export class DashboardComponent implements OnInit {
|
||||
}
|
||||
|
||||
changedOptions() {
|
||||
this.options.api.optionsChanged();
|
||||
this.options!.api!.optionsChanged!();
|
||||
}
|
||||
|
||||
toggleLocked() {
|
||||
this.locked = !this.locked;
|
||||
|
||||
this.options.resizable.enabled = !this.locked;
|
||||
this.options.draggable.enabled = !this.locked;
|
||||
this.options!.resizable!.enabled = !this.locked;
|
||||
this.options!.draggable!.enabled = !this.locked;
|
||||
|
||||
this.changedOptions();
|
||||
}
|
||||
|
||||
@@ -8,16 +8,16 @@
|
||||
<td class="laundry-current-header">
|
||||
Washer
|
||||
</td>
|
||||
<td [ngClass]="latestStatus.washer.toString()">
|
||||
{{ latestStatus.washer ? 'On' : 'Off' }}
|
||||
<td [ngClass]="latestStatus!.washer!.toString()">
|
||||
{{ latestStatus!.washer ? 'On' : 'Off' }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="laundry-current-header">
|
||||
Dryer
|
||||
</td>
|
||||
<td [ngClass]="latestStatus.dryer.toString()">
|
||||
{{ latestStatus.dryer ? 'On' : 'Off' }}
|
||||
<td [ngClass]="latestStatus!.dryer!.toString()">
|
||||
{{ latestStatus!.dryer ? 'On' : 'Off' }}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -8,7 +8,7 @@ import { LaundryStatus } from '../../models/laundry/laundry-status';
|
||||
styleUrls: ['./laundry.component.scss']
|
||||
})
|
||||
export class LaundryComponent implements OnInit {
|
||||
public latestStatus: LaundryStatus;
|
||||
public latestStatus: LaundryStatus | undefined;
|
||||
constructor(private laundryService: LaundryService) { }
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
@@ -10,7 +10,7 @@ import { MatSidenav } from '@angular/material/sidenav';
|
||||
styleUrls: ['./nav.component.scss']
|
||||
})
|
||||
export class NavComponent {
|
||||
@ViewChild('sidenav', {}) sidenav: MatSidenav;
|
||||
@ViewChild('sidenav', {}) sidenav: MatSidenav | undefined;
|
||||
|
||||
isHandset$: Observable<boolean> = this.breakpointObserver.observe([
|
||||
Breakpoints.HandsetLandscape,
|
||||
@@ -30,7 +30,7 @@ export class NavComponent {
|
||||
public toggleSidenav() {
|
||||
this.isHandset$.subscribe(isHandset => {
|
||||
if (isHandset) {
|
||||
this.sidenav.toggle();
|
||||
this.sidenav!.toggle();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ HC_exporting(Highcharts);
|
||||
})
|
||||
export class PowerChartsComponent implements OnInit {
|
||||
|
||||
public chart: Chart;
|
||||
public chart: Chart | undefined;
|
||||
public loading = true;
|
||||
|
||||
private timeSpanValue: TimeSpan = TimeSpan.Last24Hours;
|
||||
@@ -71,19 +71,19 @@ export class PowerChartsComponent implements OnInit {
|
||||
]).subscribe(data => {
|
||||
const seriesData: Array<SeriesLineOptions> = [];
|
||||
|
||||
seriesData.push({ name: 'Generation', data: [], yAxis: 0, marker: { enabled: false }, tooltip: { valueSuffix: ' W' } } as SeriesLineOptions);
|
||||
seriesData.push({ name: 'Consumption', data: [], yAxis: 0, marker: { enabled: false }, tooltip: { valueSuffix: ' W' } } as SeriesLineOptions);
|
||||
seriesData.push({ name: 'Light', data: [], yAxis: 1, marker: { enabled: false }, tooltip: { valueSuffix: ' lx' } } as SeriesLineOptions);
|
||||
seriesData.push({ type: 'line', name: 'Generation', data: [], yAxis: 0, marker: { enabled: false }, tooltip: { valueSuffix: ' W' } } as SeriesLineOptions);
|
||||
seriesData.push({ type: 'line', name: 'Consumption', data: [], yAxis: 0, marker: { enabled: false }, tooltip: { valueSuffix: ' W' } } as SeriesLineOptions);
|
||||
seriesData.push({ type: 'line', name: 'Light', data: [], yAxis: 1, marker: { enabled: false }, tooltip: { valueSuffix: ' lx' } } as SeriesLineOptions);
|
||||
|
||||
data[0].forEach(dataElement => {
|
||||
const date = Date.parse(dataElement.bucket);
|
||||
seriesData[0].data.push([date, dataElement.averageGeneration < 0 ? 0 : dataElement.averageGeneration]);
|
||||
seriesData[1].data.push([date, dataElement.averageConsumption < 0 ? 0 : dataElement.averageConsumption]);
|
||||
const date = Date.parse(dataElement.bucket!);
|
||||
seriesData[0].data!.push([date, dataElement.averageGeneration! < 0 ? 0 : dataElement.averageGeneration]);
|
||||
seriesData[1].data!.push([date, dataElement.averageConsumption! < 0 ? 0 : dataElement.averageConsumption]);
|
||||
});
|
||||
|
||||
data[1].forEach(dataElement => {
|
||||
const date = Date.parse(dataElement.bucket);
|
||||
seriesData[2].data.push([date, dataElement.averageValue]);
|
||||
const date = Date.parse(dataElement.bucket!);
|
||||
seriesData[2].data!.push([date, dataElement.averageValue]);
|
||||
});
|
||||
|
||||
this.chart = new Chart({
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
Generation
|
||||
</td>
|
||||
<td>
|
||||
{{ latestStatus.Generation < 0 ? 0 : latestStatus.Generation }} W
|
||||
{{ latestStatus!.Generation < 0 ? 0 : latestStatus!.Generation }} W
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -17,7 +17,7 @@
|
||||
Consumption
|
||||
</td>
|
||||
<td>
|
||||
{{ latestStatus.Consumption < 0 ? 0 : latestStatus.Consumption }} W
|
||||
{{ latestStatus!.Consumption < 0 ? 0 : latestStatus!.Consumption }} W
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -8,7 +8,7 @@ import { PowerStatus } from 'src/app/models/power/power-status';
|
||||
styleUrls: ['./power.component.scss']
|
||||
})
|
||||
export class PowerComponent implements OnInit {
|
||||
public latestStatus: PowerStatus;
|
||||
public latestStatus: PowerStatus | undefined | null;
|
||||
constructor(private powerService: PowerService) { }
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { TimeSpan } from 'src/app/models/time-span';
|
||||
|
||||
import * as moment from 'moment';
|
||||
import moment from 'moment';
|
||||
|
||||
@Component({
|
||||
selector: 'app-time-range',
|
||||
@@ -11,12 +11,12 @@ import * as moment from 'moment';
|
||||
export class TimeRangeComponent implements OnInit {
|
||||
|
||||
@Input()
|
||||
public loading: boolean;
|
||||
public loading: boolean | undefined;
|
||||
|
||||
private timeSpanValue: TimeSpan;
|
||||
private timeSpanValue: TimeSpan | undefined;
|
||||
|
||||
@Input()
|
||||
public set timeSpan(val: TimeSpan) {
|
||||
public set timeSpan(val: TimeSpan | undefined) {
|
||||
this.timeSpanChange.emit(val);
|
||||
this.timeSpanValue = val;
|
||||
}
|
||||
@@ -28,10 +28,10 @@ export class TimeRangeComponent implements OnInit {
|
||||
@Output()
|
||||
public timeSpanChange: EventEmitter<TimeSpan> = new EventEmitter<TimeSpan>();
|
||||
|
||||
private dateValue: moment.Moment;
|
||||
private dateValue: moment.Moment | undefined;
|
||||
|
||||
@Input()
|
||||
public set date(val: moment.Moment) {
|
||||
public set date(val: moment.Moment | undefined) {
|
||||
this.dateChange.emit(val);
|
||||
this.dateValue = val;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
Sunrise
|
||||
</td>
|
||||
<td colspan="2">
|
||||
{{ sunTimes.sunrise | amLocal | amDateFormat: 'hh:mm:ss A' }}
|
||||
{{ sunTimes!.sunrise | amLocal | amDateFormat: 'hh:mm:ss A' }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -17,7 +17,7 @@
|
||||
Sunset
|
||||
</td>
|
||||
<td colspan="2">
|
||||
{{ sunTimes.sunset | amLocal | amDateFormat: 'hh:mm:ss A' }}
|
||||
{{ sunTimes!.sunset | amLocal | amDateFormat: 'hh:mm:ss A' }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -33,7 +33,7 @@
|
||||
Moonrise
|
||||
</td>
|
||||
<td colspan="2">
|
||||
{{ moonTimes.rise | amLocal | amDateFormat: 'hh:mm:ss A' }}
|
||||
{{ moonTimes!.rise | amLocal | amDateFormat: 'hh:mm:ss A' }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -41,7 +41,7 @@
|
||||
Moonset
|
||||
</td>
|
||||
<td colspan="2">
|
||||
{{ moonTimes.set | amLocal | amDateFormat: 'hh:mm:ss A' }}
|
||||
{{ moonTimes!.set | amLocal | amDateFormat: 'hh:mm:ss A' }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -49,13 +49,13 @@
|
||||
Moon
|
||||
</td>
|
||||
<td>
|
||||
{{ moonPhaseName(moon.phase) }}
|
||||
{{ moonPhaseName(moon!.phase) }}
|
||||
<br>
|
||||
{{ (moon.fraction * 100).toFixed(1) }}% illuminated
|
||||
{{ (moon!.fraction * 100).toFixed(1) }}% illuminated
|
||||
</td>
|
||||
<td>
|
||||
<div class="moon-phase">
|
||||
{{ moonPhaseLetter(moon.phase) }}
|
||||
{{ moonPhaseLetter(moon!.phase) }}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -14,10 +14,10 @@ import 'moment-duration-format';
|
||||
})
|
||||
export class AlmanacComponent implements OnInit {
|
||||
public loaded = false;
|
||||
public latestReading: WeatherUpdate;
|
||||
public sunTimes: SunCalc.GetTimesResult;
|
||||
public moonTimes: SunCalc.GetMoonTimes;
|
||||
public moon: SunCalc.GetMoonIlluminationResult;
|
||||
public latestReading: WeatherUpdate | undefined | null;
|
||||
public sunTimes: SunCalc.GetTimesResult | undefined | null;
|
||||
public moonTimes: SunCalc.GetMoonTimes | undefined | null;
|
||||
public moon: SunCalc.GetMoonIlluminationResult | undefined | null;
|
||||
|
||||
constructor(private weatherService: WeatherService) { }
|
||||
|
||||
@@ -33,8 +33,8 @@ export class AlmanacComponent implements OnInit {
|
||||
|
||||
const date = new Date();
|
||||
|
||||
this.sunTimes = SunCalc.getTimes(date, this.latestReading.Latitude, this.latestReading.Longitude);
|
||||
this.moonTimes = SunCalc.getMoonTimes(date, this.latestReading.Latitude, this.latestReading.Longitude);
|
||||
this.sunTimes = SunCalc.getTimes(date, this.latestReading?.Latitude!, this.latestReading?.Longitude!);
|
||||
this.moonTimes = SunCalc.getMoonTimes(date, this.latestReading?.Latitude!, this.latestReading?.Longitude!);
|
||||
this.moon = SunCalc.getMoonIllumination(date);
|
||||
|
||||
this.loaded = true;
|
||||
@@ -59,6 +59,8 @@ export class AlmanacComponent implements OnInit {
|
||||
} else if (phase < 1.0) {
|
||||
return 'Waning Crescent';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
moonPhaseLetter(phase: number): string {
|
||||
@@ -79,10 +81,12 @@ export class AlmanacComponent implements OnInit {
|
||||
} else if (phase < 1.0) {
|
||||
return 'W';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
dayLength(): string {
|
||||
const duration = moment.duration((this.sunTimes.sunset.valueOf() - this.sunTimes.sunrise.valueOf()));
|
||||
const duration = moment.duration((this.sunTimes!.sunset.valueOf() - this.sunTimes!.sunrise.valueOf()));
|
||||
return duration.format('hh [hours] mm [minutes]');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ enum ChartType {
|
||||
})
|
||||
export class WeatherChartsComponent implements OnInit {
|
||||
|
||||
public chart: Chart;
|
||||
public chart: Chart | undefined;
|
||||
public loading = true;
|
||||
|
||||
public selectedChartType: ChartType = ChartType.Weather;
|
||||
@@ -91,12 +91,12 @@ export class WeatherChartsComponent implements OnInit {
|
||||
seriesData.push({ type: 'column', name: 'Rain', data: [], yAxis: 3, marker: { enabled: false }, tooltip: { valueSuffix: '"' } } as SeriesColumnOptions);
|
||||
|
||||
data.forEach(dataElement => {
|
||||
const date = Date.parse(dataElement.bucket);
|
||||
seriesData[0].data.push([date, dataElement.averageTemperature]);
|
||||
seriesData[1].data.push([date, dataElement.averagePressure / 33.864 / 100]);
|
||||
seriesData[2].data.push([date, dataElement.averageHumidity]);
|
||||
seriesData[3].data.push([date, dataElement.averageLightLevel]);
|
||||
seriesData[4].data.push([date, dataElement.rainTotal]);
|
||||
const date = Date.parse(dataElement.bucket!);
|
||||
seriesData[0].data!.push([date, dataElement.averageTemperature]);
|
||||
seriesData[1].data!.push([date, dataElement.averagePressure! / 33.864 / 100]);
|
||||
seriesData[2].data!.push([date, dataElement.averageHumidity]);
|
||||
seriesData[3].data!.push([date, dataElement.averageLightLevel]);
|
||||
seriesData[4].data!.push([date, dataElement.rainTotal]);
|
||||
});
|
||||
|
||||
this.chart = new Chart({
|
||||
@@ -219,11 +219,11 @@ export class WeatherChartsComponent implements OnInit {
|
||||
seriesData.push({ type: 'windbarb', name: 'Direction', data: [], marker: { enabled: false }, tooltip: { valueSuffix: ' MPH' } } as SeriesWindbarbOptions);
|
||||
|
||||
data.forEach(dataElement => {
|
||||
const date = Date.parse(dataElement.bucket);
|
||||
seriesData[0].data.push([date, dataElement.minimumSpeed]);
|
||||
seriesData[1].data.push([date, dataElement.averageSpeed]);
|
||||
seriesData[2].data.push([date, dataElement.maximumSpeed]);
|
||||
seriesData[3].data.push([date, dataElement.averageSpeed, dataElement.averageDirection]);
|
||||
const date = Date.parse(dataElement.bucket!);
|
||||
seriesData[0].data!.push([date, dataElement.minimumSpeed]);
|
||||
seriesData[1].data!.push([date, dataElement.averageSpeed]);
|
||||
seriesData[2].data!.push([date, dataElement.maximumSpeed]);
|
||||
seriesData[3].data!.push([date, dataElement.averageSpeed, dataElement.averageDirection]);
|
||||
});
|
||||
|
||||
this.chart = new Chart({
|
||||
|
||||
@@ -10,23 +10,23 @@
|
||||
Temperature
|
||||
</td>
|
||||
<td>
|
||||
{{ latestReading.Temperature.toFixed(2) }}°F
|
||||
{{ latestReading!.Temperature?.toFixed(2) }}°F
|
||||
</td>
|
||||
</tr>
|
||||
<tr *ngIf="latestReading.HeatIndex">
|
||||
<tr *ngIf="latestReading!.HeatIndex">
|
||||
<td class="weather-current-header">
|
||||
Heat index
|
||||
</td>
|
||||
<td>
|
||||
{{ latestReading.HeatIndex.toFixed(2) }}°F
|
||||
{{ latestReading!.HeatIndex?.toFixed(2) }}°F
|
||||
</td>
|
||||
</tr>
|
||||
<tr *ngIf="latestReading.WindChill">
|
||||
<tr *ngIf="latestReading!.WindChill">
|
||||
<td class="weather-current-header">
|
||||
Wind chill
|
||||
</td>
|
||||
<td>
|
||||
{{ latestReading.WindChill.toFixed(2) }}°F
|
||||
{{ latestReading!.WindChill?.toFixed(2) }}°F
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -34,7 +34,7 @@
|
||||
Humidity
|
||||
</td>
|
||||
<td>
|
||||
{{ latestReading.Humidity.toFixed(2) }}%
|
||||
{{ latestReading!.Humidity?.toFixed(2) }}%
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -42,7 +42,7 @@
|
||||
Dew point
|
||||
</td>
|
||||
<td>
|
||||
{{ latestReading.DewPoint.toFixed(2) }}°F
|
||||
{{ latestReading!.DewPoint?.toFixed(2) }}°F
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -50,9 +50,9 @@
|
||||
Pressure
|
||||
</td>
|
||||
<td>
|
||||
{{ (latestReading.Pressure / 33.864 / 100).toFixed(2) }}"
|
||||
{{ latestReading!.Pressure && (latestReading!.Pressure / 33.864 / 100)?.toFixed(2) }}"
|
||||
|
||||
<span class="pressure-trend-arrow" [ngClass]="rotationClass()" title="3 Hour Change: {{ latestReading.PressureDifferenceThreeHour.toFixed(1) }}">➜</span>
|
||||
<span class="pressure-trend-arrow" [ngClass]="rotationClass()" title="3 Hour Change: {{ latestReading!.PressureDifferenceThreeHour?.toFixed(1) }}">➜</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -60,7 +60,7 @@
|
||||
Wind
|
||||
</td>
|
||||
<td>
|
||||
{{ latestReading.WindSpeed.toFixed(2) }} mph {{ latestReading.WindDirection }}
|
||||
{{ latestReading!.WindSpeed?.toFixed(2) }} mph {{ latestReading!.WindDirection }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -68,7 +68,7 @@
|
||||
Rain
|
||||
</td>
|
||||
<td>
|
||||
{{ latestReading.RainLastHour.toFixed(2) }}" (last hour)
|
||||
{{ latestReading!.RainLastHour?.toFixed(2) }}" (last hour)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -76,7 +76,7 @@
|
||||
Light
|
||||
</td>
|
||||
<td>
|
||||
{{ latestReading.LightLevel.toFixed(2) }} lx
|
||||
{{ latestReading!.LightLevel?.toFixed(2) }} lx
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -8,7 +8,7 @@ import { WeatherService } from 'src/app/services/weather/weather.service';
|
||||
styleUrls: ['./weather-current.component.scss']
|
||||
})
|
||||
export class WeatherCurrentComponent implements OnInit {
|
||||
public latestReading: WeatherUpdate;
|
||||
public latestReading: WeatherUpdate | null | undefined;
|
||||
|
||||
constructor(private weatherService: WeatherService) { }
|
||||
|
||||
@@ -17,7 +17,7 @@ export class WeatherCurrentComponent implements OnInit {
|
||||
}
|
||||
|
||||
rotationClass(): string {
|
||||
const pressureDifference = this.latestReading.PressureDifferenceThreeHour;
|
||||
const pressureDifference = this.latestReading?.PressureDifferenceThreeHour;
|
||||
|
||||
if (!pressureDifference) {
|
||||
return '';
|
||||
@@ -32,5 +32,7 @@ export class WeatherCurrentComponent implements OnInit {
|
||||
} else if (pressureDifference < -2.0) {
|
||||
return 'down-high';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,13 +39,13 @@
|
||||
Temperature
|
||||
</td>
|
||||
<td>
|
||||
{{ weatherAggregates.temperature.min.toFixed(2) }}°F
|
||||
{{ weatherAggregates!.temperature.min.toFixed(2) }}°F
|
||||
</td>
|
||||
<td>
|
||||
{{ weatherAggregates.temperature.average.toFixed(2) }}°F
|
||||
{{ weatherAggregates!.temperature.average.toFixed(2) }}°F
|
||||
</td>
|
||||
<td>
|
||||
{{ weatherAggregates.temperature.max.toFixed(2) }}°F
|
||||
{{ weatherAggregates!.temperature.max.toFixed(2) }}°F
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -53,13 +53,13 @@
|
||||
Humidity
|
||||
</td>
|
||||
<td>
|
||||
{{ weatherAggregates.humidity.min.toFixed(2) }}%
|
||||
{{ weatherAggregates!.humidity.min.toFixed(2) }}%
|
||||
</td>
|
||||
<td>
|
||||
{{ weatherAggregates.humidity.average.toFixed(2) }}%
|
||||
{{ weatherAggregates!.humidity.average.toFixed(2) }}%
|
||||
</td>
|
||||
<td>
|
||||
{{ weatherAggregates.humidity.max.toFixed(2) }}%
|
||||
{{ weatherAggregates!.humidity.max.toFixed(2) }}%
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -67,13 +67,13 @@
|
||||
Pressure
|
||||
</td>
|
||||
<td>
|
||||
{{ (weatherAggregates.pressure.min / 33.864 / 100).toFixed(2) }}"
|
||||
{{ (weatherAggregates!.pressure.min / 33.864 / 100).toFixed(2) }}"
|
||||
</td>
|
||||
<td>
|
||||
{{ (weatherAggregates.pressure.average / 33.864 / 100).toFixed(2) }}"
|
||||
{{ (weatherAggregates!.pressure.average / 33.864 / 100).toFixed(2) }}"
|
||||
</td>
|
||||
<td>
|
||||
{{ (weatherAggregates.pressure.max / 33.864 / 100).toFixed(2) }}"
|
||||
{{ (weatherAggregates!.pressure.max / 33.864 / 100).toFixed(2) }}"
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -81,13 +81,13 @@
|
||||
Light
|
||||
</td>
|
||||
<td>
|
||||
{{ weatherAggregates.light.min.toFixed(2) }} lx
|
||||
{{ weatherAggregates!.light.min.toFixed(2) }} lx
|
||||
</td>
|
||||
<td>
|
||||
{{ weatherAggregates.light.average.toFixed(2) }} lx
|
||||
{{ weatherAggregates!.light.average.toFixed(2) }} lx
|
||||
</td>
|
||||
<td>
|
||||
{{ weatherAggregates.light.max.toFixed(2) }} lx
|
||||
{{ weatherAggregates!.light.max.toFixed(2) }} lx
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -95,13 +95,13 @@
|
||||
Wind Speed
|
||||
</td>
|
||||
<td>
|
||||
{{ weatherAggregates.windSpeed.min.toFixed(2) }} mph
|
||||
{{ weatherAggregates!.windSpeed.min.toFixed(2) }} mph
|
||||
</td>
|
||||
<td>
|
||||
{{ weatherAggregates.windSpeed.average.toFixed(2) }} mph
|
||||
{{ weatherAggregates!.windSpeed.average.toFixed(2) }} mph
|
||||
</td>
|
||||
<td>
|
||||
{{ weatherAggregates.windSpeed.max.toFixed(2) }} mph
|
||||
{{ weatherAggregates!.windSpeed.max.toFixed(2) }} mph
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -111,7 +111,7 @@
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
{{ weatherAggregates.windDirectionAverage }}
|
||||
{{ weatherAggregates!.windDirectionAverage }}
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
@@ -125,7 +125,7 @@
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
{{ weatherAggregates.rainTotal.toFixed(2) }}"
|
||||
{{ weatherAggregates!.rainTotal.toFixed(2) }}"
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { TimeSpan } from 'src/app/models/time-span';
|
||||
import { WeatherService } from 'src/app/services/weather/weather.service';
|
||||
import { WeatherAggregates } from 'src/app/models/weather/weather-aggregates';
|
||||
|
||||
import * as moment from 'moment';
|
||||
import moment from 'moment';
|
||||
|
||||
@Component({
|
||||
selector: 'app-weather-summary',
|
||||
@@ -13,7 +13,7 @@ import * as moment from 'moment';
|
||||
export class WeatherSummaryComponent implements OnInit {
|
||||
|
||||
public loading = true;
|
||||
public weatherAggregates: WeatherAggregates = null;
|
||||
public weatherAggregates: WeatherAggregates | undefined | null = null;
|
||||
|
||||
private timeSpanValue: TimeSpan = TimeSpan.Last24Hours;
|
||||
private dateValue: moment.Moment = moment().startOf('day');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { GridsterItem } from 'angular-gridster2';
|
||||
|
||||
export class DashboardLayout {
|
||||
version: number;
|
||||
layout: Array<GridsterItem>;
|
||||
version: number | undefined;
|
||||
layout: Array<GridsterItem> | undefined;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export class LaundryStatus {
|
||||
washer = false;
|
||||
dryer = false;
|
||||
washer: boolean | undefined = false;
|
||||
dryer: boolean | undefined = false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export class PowerStatusGrouped {
|
||||
bucket: string;
|
||||
averageGeneration: number;
|
||||
averageConsumption: number;
|
||||
bucket: string | undefined;
|
||||
averageGeneration: number | undefined;
|
||||
averageConsumption: number | undefined;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
export class WeatherReadingGrouped {
|
||||
bucket: string;
|
||||
averageTemperature: number;
|
||||
averagePressure: number;
|
||||
averageLightLevel: number;
|
||||
averageHumidity: number;
|
||||
rainTotal: number;
|
||||
bucket: string | undefined;
|
||||
averageTemperature: number | undefined;
|
||||
averagePressure: number | undefined;
|
||||
averageLightLevel: number | undefined;
|
||||
averageHumidity: number | undefined;
|
||||
rainTotal: number | undefined;
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
export class WeatherUpdate {
|
||||
Type: string;
|
||||
Message: null;
|
||||
Timestamp: Date;
|
||||
WindDirection: string;
|
||||
WindSpeed: number;
|
||||
Humidity: number;
|
||||
Rain: number;
|
||||
Pressure: number;
|
||||
Temperature: number;
|
||||
BatteryLevel: number;
|
||||
LightLevel: number;
|
||||
Latitude: number;
|
||||
Longitude: number;
|
||||
Altitude: number;
|
||||
SatelliteCount: number;
|
||||
GpsTimestamp: Date;
|
||||
WindChill: number;
|
||||
HeatIndex: number;
|
||||
DewPoint: number;
|
||||
PressureDifferenceThreeHour: number;
|
||||
PressureSlope: number;
|
||||
PressureAngle: number;
|
||||
RainLastHour: number;
|
||||
Type: string | undefined;
|
||||
Message: null | undefined;
|
||||
Timestamp: Date | undefined;
|
||||
WindDirection: string | undefined;
|
||||
WindSpeed: number | undefined;
|
||||
Humidity: number | undefined;
|
||||
Rain: number | undefined;
|
||||
Pressure: number | undefined;
|
||||
Temperature: number | undefined;
|
||||
BatteryLevel: number | undefined;
|
||||
LightLevel: number | undefined;
|
||||
Latitude: number | undefined;
|
||||
Longitude: number | undefined;
|
||||
Altitude: number | undefined;
|
||||
SatelliteCount: number | undefined;
|
||||
GpsTimestamp: Date | undefined;
|
||||
WindChill: number | undefined;
|
||||
HeatIndex: number | undefined;
|
||||
DewPoint: number | undefined;
|
||||
PressureDifferenceThreeHour: number | undefined;
|
||||
PressureSlope: number | undefined;
|
||||
PressureAngle: number | undefined;
|
||||
RainLastHour: number | undefined;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export class WeatherValueGrouped {
|
||||
bucket: string;
|
||||
averageValue: number;
|
||||
bucket: string | undefined;
|
||||
averageValue: number | undefined;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export class WeatherValue {
|
||||
timestamp: string;
|
||||
value: number;
|
||||
timestamp: string | undefined;
|
||||
value: number | undefined;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
export class WindHistoryGrouped {
|
||||
bucket: string;
|
||||
minimumSpeed: number;
|
||||
averageSpeed: number;
|
||||
maximumSpeed: number;
|
||||
averageDirection: number;
|
||||
bucket: string | undefined;
|
||||
minimumSpeed: number | undefined;
|
||||
averageSpeed: number | undefined;
|
||||
maximumSpeed: number | undefined;
|
||||
averageDirection: number | undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, BehaviorSubject } from 'rxjs';
|
||||
import { Observable, BehaviorSubject, firstValueFrom } from 'rxjs';
|
||||
import { HubConnectionBuilder, HubConnection } from '@aspnet/signalr';
|
||||
import { LaundryStatus } from '../../models/laundry/laundry-status';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
|
||||
class DeviceMessage {
|
||||
name: string;
|
||||
status: boolean;
|
||||
name: string | undefined;
|
||||
status: boolean | undefined;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
@@ -48,7 +48,7 @@ export class LaundryService {
|
||||
}
|
||||
|
||||
private async loadLatestStatus() {
|
||||
const data = await this.httpClient.get<DeviceMessage[]>(`/api/device-status/status/recent`).toPromise();
|
||||
const data = await firstValueFrom(this.httpClient.get<DeviceMessage[]>(`/api/device-status/status/recent`));
|
||||
|
||||
const newStatus = new LaundryStatus();
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { PowerStatus } from 'src/app/models/power/power-status';
|
||||
})
|
||||
export class PowerService {
|
||||
private connection: HubConnection;
|
||||
private latestStatus: BehaviorSubject<PowerStatus> = new BehaviorSubject<PowerStatus>(null);
|
||||
private latestStatus: BehaviorSubject<PowerStatus | null> = new BehaviorSubject<PowerStatus | null>(null);
|
||||
|
||||
constructor() {
|
||||
this.connection = new HubConnectionBuilder()
|
||||
@@ -22,7 +22,7 @@ export class PowerService {
|
||||
this.connection.start();
|
||||
}
|
||||
|
||||
getLatestStatus(): Observable<PowerStatus> {
|
||||
getLatestStatus(): Observable<PowerStatus | null> {
|
||||
return this.latestStatus.asObservable();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, BehaviorSubject } from 'rxjs';
|
||||
import { Observable, BehaviorSubject, firstValueFrom } from 'rxjs';
|
||||
import { HubConnectionBuilder, HubConnection } from '@aspnet/signalr';
|
||||
import { WeatherUpdate } from 'src/app/models/weather/weather-update';
|
||||
import { WeatherValue } from 'src/app/models/weather/weather-value';
|
||||
@@ -7,14 +7,14 @@ import { HttpClient } from '@angular/common/http';
|
||||
import { WeatherValueType } from 'src/app/models/weather/weather-value-type';
|
||||
import { WeatherAggregates } from 'src/app/models/weather/weather-aggregates';
|
||||
|
||||
import * as moment from 'moment';
|
||||
import moment from 'moment';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class WeatherService {
|
||||
private connection: HubConnection;
|
||||
private latestReading: BehaviorSubject<WeatherUpdate> = new BehaviorSubject<WeatherUpdate>(null);
|
||||
private latestReading: BehaviorSubject<WeatherUpdate | null> = new BehaviorSubject<WeatherUpdate | null>(null);
|
||||
|
||||
constructor(private httpClient: HttpClient) {
|
||||
this.connection = new HubConnectionBuilder()
|
||||
@@ -28,24 +28,24 @@ export class WeatherService {
|
||||
this.connection.start();
|
||||
}
|
||||
|
||||
getLatestReading(): Observable<WeatherUpdate> {
|
||||
getLatestReading(): Observable<WeatherUpdate | null> {
|
||||
return this.latestReading.asObservable();
|
||||
}
|
||||
|
||||
async getReadingValueHistory(valueType: WeatherValueType, start: moment.Moment, end: moment.Moment): Promise<WeatherValue[]> {
|
||||
async getReadingValueHistory(valueType: WeatherValueType, start: moment.Moment, end: moment.Moment): Promise<WeatherValue[] | undefined> {
|
||||
const startString = start.toISOString();
|
||||
const endString = end.toISOString();
|
||||
|
||||
const data = await this.httpClient.get<WeatherValue[]>(`/api/weather/readings/value-history?weatherValueType=${valueType}&start=${startString}&end=${endString}`).toPromise();
|
||||
const data = await firstValueFrom(this.httpClient.get<WeatherValue[]>(`/api/weather/readings/value-history?weatherValueType=${valueType}&start=${startString}&end=${endString}`));
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
async getReadingAggregate(start: moment.Moment, end: moment.Moment): Promise<WeatherAggregates> {
|
||||
async getReadingAggregate(start: moment.Moment, end: moment.Moment): Promise<WeatherAggregates | undefined> {
|
||||
const startString = start.toISOString();
|
||||
const endString = end.toISOString();
|
||||
|
||||
const data = await this.httpClient.get<WeatherAggregates>(`/api/weather/readings/aggregate?start=${startString}&end=${endString}`).toPromise();
|
||||
const data = await firstValueFrom(this.httpClient.get<WeatherAggregates>(`/api/weather/readings/aggregate?start=${startString}&end=${endString}`));
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user