From a3d2a9230261f820cfa62b1e9f7d596c3f7dad39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Ha=C3=9Fel?= Date: Tue, 18 Nov 2025 08:49:29 +0100 Subject: [PATCH] outside (temperature, humidity relative/absolute) --- src/main/angular/src/app/location/Location.ts | 40 ++++++++++++++----- .../app/location/detail/location-detail.html | 40 +++++++++++++++++++ .../app/location/detail/location-detail.ts | 6 +++ .../src/app/location/location-service.ts | 12 ++++++ .../java/de/ph87/data/location/Location.java | 15 +++++++ .../data/location/LocationController.java | 15 +++++++ .../de/ph87/data/location/LocationDto.java | 12 ++++++ 7 files changed, 129 insertions(+), 11 deletions(-) diff --git a/src/main/angular/src/app/location/Location.ts b/src/main/angular/src/app/location/Location.ts index afbe3e9..da420b6 100644 --- a/src/main/angular/src/app/location/Location.ts +++ b/src/main/angular/src/app/location/Location.ts @@ -29,6 +29,9 @@ export class Location { private _powerPurchase: Series | null, private _powerDeliver: Series | null, private _powerProduce: Series | null, + private _outsideTemperature: Series | null, + private _outsideHumidityRelative: Series | null, + private _outsideHumidityAbsolute: Series | null, private _powerConsume: Value = Value.NULL, ) { this.updateConsume(); @@ -58,17 +61,6 @@ export class Location { } }; - private updateConsume() { - this._powerConsume = Value.ZERO.plus(this._powerPurchase?.value, true).plus(this._powerProduce?.value, true).minus(this._powerDeliver?.value, true); - this.powerSelf = Value.ZERO.plus(this.powerProduce?.value.minus(this.powerDeliver?.value, true), true); - this.powerPurchasePercentConsume = Value.ZERO.plus(this.powerPurchase?.value.percent(this.powerConsume, "%", 0), true); - this.powerProducePercentConsume = Value.ZERO.plus(this.powerProduce?.value.percent(this.powerConsume, "%", 0), true); - this.powerDeliveryPercentConsume = Value.ZERO.plus(this.powerDeliver?.value.percent(this.powerConsume, "%", 0), true); - this.powerDeliveryPercentProduce = Value.ZERO.plus(this.powerDeliver?.value.percent(this.powerProduce?.value, "%", 0), true); - this.powerSelfPercentConsume = Value.ZERO.plus(this.powerSelf.percent(this.powerConsume, "%", 0), true); - this.powerSelfPercentProduce = Value.ZERO.plus(this.powerSelf.percent(this.powerProduce?.value, "%", 0), true); - } - static fromJson(json: any): Location { return new Location( validateNumber(json.id), @@ -81,9 +73,23 @@ export class Location { or(json.powerPurchase, Series.fromJson, null), or(json.powerDeliver, Series.fromJson, null), or(json.powerProduce, Series.fromJson, null), + or(json.outsideTemperature, Series.fromJson, null), + or(json.outsideHumidityRelative, Series.fromJson, null), + or(json.outsideHumidityAbsolute, Series.fromJson, null), ); } + private updateConsume() { + this._powerConsume = Value.ZERO.plus(this._powerPurchase?.value, true).plus(this._powerProduce?.value, true).minus(this._powerDeliver?.value, true); + this.powerSelf = Value.ZERO.plus(this.powerProduce?.value.minus(this.powerDeliver?.value, true), true); + this.powerPurchasePercentConsume = Value.ZERO.plus(this.powerPurchase?.value.percent(this.powerConsume, "%", 0), true); + this.powerProducePercentConsume = Value.ZERO.plus(this.powerProduce?.value.percent(this.powerConsume, "%", 0), true); + this.powerDeliveryPercentConsume = Value.ZERO.plus(this.powerDeliver?.value.percent(this.powerConsume, "%", 0), true); + this.powerDeliveryPercentProduce = Value.ZERO.plus(this.powerDeliver?.value.percent(this.powerProduce?.value, "%", 0), true); + this.powerSelfPercentConsume = Value.ZERO.plus(this.powerSelf.percent(this.powerConsume, "%", 0), true); + this.powerSelfPercentProduce = Value.ZERO.plus(this.powerSelf.percent(this.powerProduce?.value, "%", 0), true); + } + get energyPurchase(): Series | null { return this._energyPurchase; } @@ -112,4 +118,16 @@ export class Location { return this._powerConsume; } + get outsideTemperature(): Series | null { + return this._outsideTemperature; + } + + get outsideHumidityRelative(): Series | null { + return this._outsideHumidityRelative; + } + + get outsideHumidityAbsolute(): Series | null { + return this._outsideHumidityAbsolute; + } + } diff --git a/src/main/angular/src/app/location/detail/location-detail.html b/src/main/angular/src/app/location/detail/location-detail.html index 3732e2d..22f9567 100644 --- a/src/main/angular/src/app/location/detail/location-detail.html +++ b/src/main/angular/src/app/location/detail/location-detail.html @@ -148,4 +148,44 @@ +
+
+
+ Außen +
+
+
+
+
+
+ Temperatur +
+
+
+ +
+
+
+
+
+ Relative Luftfeuchte +
+
+
+ +
+
+
+
+
+ Absolute Luftfeuchte +
+
+
+ +
+
+
+
+ } diff --git a/src/main/angular/src/app/location/detail/location-detail.ts b/src/main/angular/src/app/location/detail/location-detail.ts index 18c1dac..98c6ad6 100644 --- a/src/main/angular/src/app/location/detail/location-detail.ts +++ b/src/main/angular/src/app/location/detail/location-detail.ts @@ -33,6 +33,12 @@ export class LocationDetail implements OnInit, OnDestroy { protected readonly filterPower = (series: Series) => series.type === SeriesType.VARYING && series.unit === 'W'; + protected readonly filterTemperature = (series: Series) => series.type === SeriesType.VARYING && series.unit === '°C'; + + protected readonly filterHumidityRelative = (series: Series) => series.type === SeriesType.VARYING && series.unit === '%'; + + protected readonly filterHumidityAbsolute = (series: Series) => series.type === SeriesType.VARYING && series.unit === 'g/m³'; + protected readonly Interval = Interval; protected readonly Math = Math; diff --git a/src/main/angular/src/app/location/location-service.ts b/src/main/angular/src/app/location/location-service.ts index ce0944a..5786155 100644 --- a/src/main/angular/src/app/location/location-service.ts +++ b/src/main/angular/src/app/location/location-service.ts @@ -85,4 +85,16 @@ export class LocationService extends CrudService { this.postSingle([location.id, 'powerProduce'], seriesId, next); } + outsideTemperature(location: Location, seriesId: number | null, next?: Next) { + this.postSingle([location.id, 'outsideTemperature'], seriesId, next); + } + + outsideHumidityRelative(location: Location, seriesId: number | null, next?: Next) { + this.postSingle([location.id, 'outsideHumidityRelative'], seriesId, next); + } + + outsideHumidityAbsolute(location: Location, seriesId: number | null, next?: Next) { + this.postSingle([location.id, 'outsideHumidityAbsolute'], seriesId, next); + } + } diff --git a/src/main/java/de/ph87/data/location/Location.java b/src/main/java/de/ph87/data/location/Location.java index 515f903..62e9d99 100644 --- a/src/main/java/de/ph87/data/location/Location.java +++ b/src/main/java/de/ph87/data/location/Location.java @@ -71,4 +71,19 @@ public class Location { @ManyToOne private Series powerProduce; + @Setter + @Nullable + @ManyToOne + private Series outsideTemperature; + + @Setter + @Nullable + @ManyToOne + private Series outsideHumidityRelative; + + @Setter + @Nullable + @ManyToOne + private Series outsideHumidityAbsolute; + } diff --git a/src/main/java/de/ph87/data/location/LocationController.java b/src/main/java/de/ph87/data/location/LocationController.java index 91ea3e1..fb94c9d 100644 --- a/src/main/java/de/ph87/data/location/LocationController.java +++ b/src/main/java/de/ph87/data/location/LocationController.java @@ -87,4 +87,19 @@ public class LocationController { return locationService.setSeries(id, seriesId, Location::setPowerProduce); } + @PostMapping("{id}/outsideTemperature") + public LocationDto outsideTemperature(@PathVariable final long id, @RequestBody(required = false) @Nullable final Long seriesId) { + return locationService.setSeries(id, seriesId, Location::setOutsideTemperature); + } + + @PostMapping("{id}/outsideHumidityRelative") + public LocationDto outsideHumidityRelative(@PathVariable final long id, @RequestBody(required = false) @Nullable final Long seriesId) { + return locationService.setSeries(id, seriesId, Location::setOutsideHumidityRelative); + } + + @PostMapping("{id}/outsideHumidityAbsolute") + public LocationDto outsideHumidityAbsolute(@PathVariable final long id, @RequestBody(required = false) @Nullable final Long seriesId) { + return locationService.setSeries(id, seriesId, Location::setOutsideHumidityAbsolute); + } + } diff --git a/src/main/java/de/ph87/data/location/LocationDto.java b/src/main/java/de/ph87/data/location/LocationDto.java index 9d06cdc..14bfb3c 100644 --- a/src/main/java/de/ph87/data/location/LocationDto.java +++ b/src/main/java/de/ph87/data/location/LocationDto.java @@ -38,6 +38,15 @@ public class LocationDto { @Nullable public final SeriesDto powerProduce; + @Nullable + public final SeriesDto outsideTemperature; + + @Nullable + public final SeriesDto outsideHumidityRelative; + + @Nullable + public final SeriesDto outsideHumidityAbsolute; + public LocationDto(@NonNull final Location location) { this.id = location.getId(); this.version = location.getVersion(); @@ -50,6 +59,9 @@ public class LocationDto { this.powerPurchase = map(location.getPowerPurchase(), SeriesDto::new); this.powerDeliver = map(location.getPowerDeliver(), SeriesDto::new); this.powerProduce = map(location.getPowerProduce(), SeriesDto::new); + this.outsideTemperature = map(location.getOutsideTemperature(), SeriesDto::new); + this.outsideHumidityRelative = map(location.getOutsideHumidityRelative(), SeriesDto::new); + this.outsideHumidityAbsolute = map(location.getOutsideHumidityAbsolute(), SeriesDto::new); } }