diff --git a/Display/.vscode/settings.json b/Display/.vscode/settings.json
new file mode 100644
index 0000000..48c601a
--- /dev/null
+++ b/Display/.vscode/settings.json
@@ -0,0 +1,10 @@
+{
+ "cSpell.words": [
+ "aspnet",
+ "datetime",
+ "highcharts",
+ "signalr",
+ "suncalc",
+ "windbarb"
+ ]
+}
\ No newline at end of file
diff --git a/Display/src/app/components/power/charts/power-charts.component.ts b/Display/src/app/components/power/charts/power-charts.component.ts
index f4ce104..4377b87 100644
--- a/Display/src/app/components/power/charts/power-charts.component.ts
+++ b/Display/src/app/components/power/charts/power-charts.component.ts
@@ -106,7 +106,7 @@ export class PowerChartsComponent implements OnInit {
data[1].forEach(dataElement => {
const date = Date.parse(dataElement.bucket);
- seriesData[2].data.push([date, dataElement.averageValue * 100]);
+ seriesData[2].data.push([date, dataElement.averageValue]);
});
const title = this.selectedTimeSpan === TimeSpan.Last24Hours ? this.timeSpanItems[TimeSpan.Last24Hours] : this.getSelectedDateDisplayString();
diff --git a/Display/src/app/components/weather/almanac/almanac.component.ts b/Display/src/app/components/weather/almanac/almanac.component.ts
index 251028d..ced21ee 100644
--- a/Display/src/app/components/weather/almanac/almanac.component.ts
+++ b/Display/src/app/components/weather/almanac/almanac.component.ts
@@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
-import { WeatherReading } from 'src/app/models/weather/weather-reading';
+import { WeatherUpdate } from 'src/app/models/weather/weather-update';
import { WeatherService } from 'src/app/services/weather/weather.service';
import { first } from 'rxjs/operators';
@@ -14,7 +14,7 @@ import 'moment-duration-format';
})
export class AlmanacComponent implements OnInit {
public loaded = false;
- public latestReading: WeatherReading;
+ public latestReading: WeatherUpdate;
public sunTimes: SunCalc.GetTimesResult;
public moonTimes: SunCalc.GetMoonTimes;
public moon: SunCalc.GetMoonIlluminationResult;
diff --git a/Display/src/app/components/weather/charts/weather-charts.component.ts b/Display/src/app/components/weather/charts/weather-charts.component.ts
index e69ed11..75b0a17 100644
--- a/Display/src/app/components/weather/charts/weather-charts.component.ts
+++ b/Display/src/app/components/weather/charts/weather-charts.component.ts
@@ -118,10 +118,10 @@ export class WeatherChartsComponent implements OnInit {
data.forEach(dataElement => {
const date = Date.parse(dataElement.bucket);
- seriesData[0].data.push([date, dataElement.averagePressureTemperature]);
+ 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 * 100]);
+ seriesData[3].data.push([date, dataElement.averageLightLevel]);
seriesData[4].data.push([date, dataElement.rainTotal]);
});
diff --git a/Display/src/app/components/weather/current/weather-current.component.html b/Display/src/app/components/weather/current/weather-current.component.html
index f1210cf..d66b548 100644
--- a/Display/src/app/components/weather/current/weather-current.component.html
+++ b/Display/src/app/components/weather/current/weather-current.component.html
@@ -10,7 +10,7 @@
Temperature
- {{ latestReading.PressureTemperature.toFixed(2) }}°F
+ {{ latestReading.Temperature.toFixed(2) }}°F
|
diff --git a/Display/src/app/components/weather/current/weather-current.component.ts b/Display/src/app/components/weather/current/weather-current.component.ts
index c28998a..6384b7f 100644
--- a/Display/src/app/components/weather/current/weather-current.component.ts
+++ b/Display/src/app/components/weather/current/weather-current.component.ts
@@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
-import { WeatherReading } from 'src/app/models/weather/weather-reading';
+import { WeatherUpdate } from 'src/app/models/weather/weather-update';
import { WeatherService } from 'src/app/services/weather/weather.service';
@Component({
@@ -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: WeatherReading;
+ public latestReading: WeatherUpdate;
constructor(private weatherService: WeatherService) { }
diff --git a/Display/src/app/models/weather/weather-reading-grouped.ts b/Display/src/app/models/weather/weather-reading-grouped.ts
index 8afddbb..6d61fed 100644
--- a/Display/src/app/models/weather/weather-reading-grouped.ts
+++ b/Display/src/app/models/weather/weather-reading-grouped.ts
@@ -1,9 +1,8 @@
export class WeatherReadingGrouped {
bucket: string;
- averagePressureTemperature: number;
+ averageTemperature: number;
averagePressure: number;
averageLightLevel: number;
averageHumidity: number;
- averageHumidityTemperature: number;
rainTotal: number;
}
diff --git a/Display/src/app/models/weather/weather-reading.spec.ts b/Display/src/app/models/weather/weather-reading.spec.ts
index fe94efa..823b7cf 100644
--- a/Display/src/app/models/weather/weather-reading.spec.ts
+++ b/Display/src/app/models/weather/weather-reading.spec.ts
@@ -1,7 +1,7 @@
-import { WeatherReading } from './weather-reading';
+import { WeatherUpdate } from './weather-update';
-describe('WeatherReading', () => {
+describe('WeatherUpdate', () => {
it('should create an instance', () => {
- expect(new WeatherReading()).toBeTruthy();
+ expect(new WeatherUpdate()).toBeTruthy();
});
});
diff --git a/Display/src/app/models/weather/weather-reading.ts b/Display/src/app/models/weather/weather-update.ts
similarity index 84%
rename from Display/src/app/models/weather/weather-reading.ts
rename to Display/src/app/models/weather/weather-update.ts
index 1f13780..ccf4adc 100644
--- a/Display/src/app/models/weather/weather-reading.ts
+++ b/Display/src/app/models/weather/weather-update.ts
@@ -1,14 +1,13 @@
-export class WeatherReading {
+export class WeatherUpdate {
Type: string;
Message: null;
Timestamp: Date;
WindDirection: string;
WindSpeed: number;
Humidity: number;
- HumidityTemperature: number;
Rain: number;
Pressure: number;
- PressureTemperature: number;
+ Temperature: number;
BatteryLevel: number;
LightLevel: number;
Latitude: number;
diff --git a/Display/src/app/services/weather/weather.service.ts b/Display/src/app/services/weather/weather.service.ts
index c7229c9..f5e1fd6 100644
--- a/Display/src/app/services/weather/weather.service.ts
+++ b/Display/src/app/services/weather/weather.service.ts
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { Observable, BehaviorSubject } from 'rxjs';
import { HubConnectionBuilder, HubConnection } from '@aspnet/signalr';
-import { WeatherReading } from 'src/app/models/weather/weather-reading';
+import { WeatherUpdate } from 'src/app/models/weather/weather-update';
import { WeatherValue } from 'src/app/models/weather/weather-value';
import { HttpClient } from '@angular/common/http';
@@ -13,7 +13,7 @@ import { WeatherValueType } from 'src/app/models/weather/weather-value-type';
})
export class WeatherService {
private connection: HubConnection;
- private latestReading: BehaviorSubject = new BehaviorSubject(null);
+ private latestReading: BehaviorSubject = new BehaviorSubject(null);
constructor(private httpClient: HttpClient) {
this.connection = new HubConnectionBuilder()
@@ -27,7 +27,7 @@ export class WeatherService {
this.connection.start();
}
- getLatestReading(): Observable {
+ getLatestReading(): Observable {
return this.latestReading.asObservable();
}
diff --git a/Weather/Service/Data/Database.cs b/Weather/Service/Data/Database.cs
index 0479398..3b485ef 100644
--- a/Weather/Service/Data/Database.cs
+++ b/Weather/Service/Data/Database.cs
@@ -129,7 +129,7 @@ namespace ChrisKaczor.HomeMonitor.Weather.Service.Data
switch (weatherValueType)
{
case WeatherValueType.LightLevel:
- query = query.Replace("@Value", "LightLevel / 3.3");
+ query = query.Replace("@Value", "LightLevel / 3.3 * 100");
break;
default:
query = query.Replace("@Value", weatherValueType.ToString());
diff --git a/Weather/Service/Data/Resources/GetReadingHistory.sql b/Weather/Service/Data/Resources/GetReadingHistory.sql
index fd0abe4..03afa36 100644
--- a/Weather/Service/Data/Resources/GetReadingHistory.sql
+++ b/Weather/Service/Data/Resources/GetReadingHistory.sql
@@ -2,10 +2,9 @@ SELECT Timestamp,
WindDirection,
WindSpeed,
Humidity,
- HumidityTemperature,
Rain,
Pressure,
- PressureTemperature,
+ PressureTemperature AS Temperature,
BatteryLevel,
LightLevel,
Latitude,
diff --git a/Weather/Service/Data/Resources/GetReadingHistoryGrouped.sql b/Weather/Service/Data/Resources/GetReadingHistoryGrouped.sql
index 31be8a4..b7dfcea 100644
--- a/Weather/Service/Data/Resources/GetReadingHistoryGrouped.sql
+++ b/Weather/Service/Data/Resources/GetReadingHistoryGrouped.sql
@@ -1,7 +1,6 @@
SELECT Bucket,
- AVG(HumidityTemperature) AS AverageHumidityTemperature,
AVG(Humidity) AS AverageHumidity,
- AVG(PressureTemperature) AS AveragePressureTemperature,
+ AVG(Temperature) AS AverageTemperature,
AVG(Pressure) AS AveragePressure,
AVG(LightLevel) AS AverageLightLevel,
SUM(Rain) AS RainTotal
@@ -9,11 +8,10 @@ FROM (
SELECT CAST(FORMAT(Timestamp, 'yyyy-MM-ddTHH:') +
RIGHT('00' + CAST(DATEPART(MINUTE, Timestamp) / @BucketMinutes * @BucketMinutes AS VARCHAR), 2)
+ ':00+00:00' AS DATETIMEOFFSET) AS Bucket,
- HumidityTemperature,
Humidity,
- PressureTemperature,
+ PressureTemperature AS Temperature,
Pressure,
- LightLevel / 3.3 AS LightLevel,
+ LightLevel / 3.3 * 100 AS LightLevel,
Rain
FROM Reading
WHERE Timestamp BETWEEN @Start AND @End
diff --git a/Weather/Service/Data/Resources/GetRecentReading.sql b/Weather/Service/Data/Resources/GetRecentReading.sql
index cec182f..cb7b1c4 100644
--- a/Weather/Service/Data/Resources/GetRecentReading.sql
+++ b/Weather/Service/Data/Resources/GetRecentReading.sql
@@ -2,10 +2,9 @@ SELECT TOP 1 Timestamp,
WindDirection,
WindSpeed,
Humidity,
- HumidityTemperature,
Rain,
Pressure,
- PressureTemperature,
+ PressureTemperature AS Temperature,
BatteryLevel,
LightLevel,
Latitude,
diff --git a/Weather/Service/Models/WeatherReadingGrouped.cs b/Weather/Service/Models/WeatherReadingGrouped.cs
index d6daed4..8d20b97 100644
--- a/Weather/Service/Models/WeatherReadingGrouped.cs
+++ b/Weather/Service/Models/WeatherReadingGrouped.cs
@@ -8,11 +8,9 @@ namespace ChrisKaczor.HomeMonitor.Weather.Service.Models
{
public DateTimeOffset Bucket { get; set; }
- public decimal AverageHumidityTemperature { get; set; }
-
public decimal AverageHumidity { get; set; }
- public decimal AveragePressureTemperature { get; set; }
+ public decimal AverageTemperature { get; set; }
public decimal AveragePressure { get; set; }
diff --git a/Weather/Service/Models/WeatherUpdate.cs b/Weather/Service/Models/WeatherUpdate.cs
index 3471fad..e5f50cd 100644
--- a/Weather/Service/Models/WeatherUpdate.cs
+++ b/Weather/Service/Models/WeatherUpdate.cs
@@ -1,17 +1,52 @@
+using System;
using System.Linq;
using ChrisKaczor.HomeMonitor.Weather.Models;
using ChrisKaczor.HomeMonitor.Weather.Service.Data;
using DecimalMath;
using JetBrains.Annotations;
using MathNet.Numerics;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
namespace ChrisKaczor.HomeMonitor.Weather.Service.Models
{
[PublicAPI]
- public class WeatherUpdate : WeatherMessage
+ public class WeatherUpdate
{
private readonly Database _database;
+ [JsonConverter(typeof(StringEnumConverter))]
+ public MessageType Type { get; set; }
+
+ public string Message { get; set; }
+
+ public DateTimeOffset Timestamp { get; set; }
+
+ [JsonConverter(typeof(StringEnumConverter))]
+ public WindDirection WindDirection { get; set; }
+
+ public decimal WindSpeed { get; set; }
+
+ public decimal Humidity { get; set; }
+
+ public decimal Rain { get; set; }
+
+ public decimal Pressure { get; set; }
+
+ public decimal Temperature { get; set; }
+
+ public decimal LightLevel { get; set; }
+
+ public decimal Latitude { get; set; }
+
+ public decimal Longitude { get; set; }
+
+ public decimal Altitude { get; set; }
+
+ public int SatelliteCount { get; set; }
+
+ public DateTimeOffset GpsTimestamp { get; set; }
+
public decimal? WindChill { get; set; }
public decimal? HeatIndex { get; set; }
@@ -32,12 +67,10 @@ namespace ChrisKaczor.HomeMonitor.Weather.Service.Models
WindDirection = weatherMessage.WindDirection;
WindSpeed = weatherMessage.WindSpeed;
Humidity = weatherMessage.Humidity;
- HumidityTemperature = weatherMessage.HumidityTemperature;
Rain = weatherMessage.Rain;
Pressure = weatherMessage.Pressure;
- PressureTemperature = weatherMessage.PressureTemperature;
- BatteryLevel = weatherMessage.BatteryLevel;
- LightLevel = weatherMessage.LightLevel;
+ Temperature = weatherMessage.PressureTemperature;
+ LightLevel = weatherMessage.LightLevel / 3.3m * 100;
Latitude = weatherMessage.Latitude;
Longitude = weatherMessage.Longitude;
Altitude = weatherMessage.Altitude;
@@ -70,7 +103,7 @@ namespace ChrisKaczor.HomeMonitor.Weather.Service.Models
private void CalculateHeatIndex()
{
- var temperature = PressureTemperature;
+ var temperature = Temperature;
var humidity = Humidity;
if (temperature.IsBetween(80, 100) && humidity.IsBetween(40, 100))
@@ -83,7 +116,7 @@ namespace ChrisKaczor.HomeMonitor.Weather.Service.Models
private void CalculateWindChill()
{
- var temperatureInF = PressureTemperature;
+ var temperatureInF = Temperature;
var windSpeedInMph = WindSpeed;
if (temperatureInF.IsBetween(-45, 45) && windSpeedInMph.IsBetween(3, 60))
@@ -95,7 +128,7 @@ namespace ChrisKaczor.HomeMonitor.Weather.Service.Models
private void CalculateDewPoint()
{
var relativeHumidity = Humidity;
- var temperatureInF = PressureTemperature;
+ var temperatureInF = Temperature;
var temperatureInC = (temperatureInF - 32.0m) * 5.0m / 9.0m;