outside (temperature, humidity relative/absolute)

This commit is contained in:
Patrick Haßel 2025-11-18 08:49:29 +01:00
parent a96cf9d62c
commit a3d2a92302
7 changed files with 129 additions and 11 deletions

View File

@ -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;
}
}

View File

@ -148,4 +148,44 @@
</div>
</div>
<div class="Section">
<div class="SectionHeading">
<div class="SectionHeadingText">
Außen
</div>
</div>
<div class="SectionBody">
<div class="Section2">
<div class="SectionHeading">
<div class="SectionHeadingText">
Temperatur
</div>
</div>
<div class="SectionBody">
<app-series-select [initial]="location.outsideTemperature" (onChange)="locationService.outsideTemperature(location, $event)" [filter]="filterTemperature"></app-series-select>
</div>
</div>
<div class="Section2">
<div class="SectionHeading">
<div class="SectionHeadingText">
Relative Luftfeuchte
</div>
</div>
<div class="SectionBody">
<app-series-select [initial]="location.outsideHumidityRelative" (onChange)="locationService.outsideHumidityRelative(location, $event)" [filter]="filterHumidityRelative"></app-series-select>
</div>
</div>
<div class="Section2">
<div class="SectionHeading">
<div class="SectionHeadingText">
Absolute Luftfeuchte
</div>
</div>
<div class="SectionBody">
<app-series-select [initial]="location.outsideHumidityAbsolute" (onChange)="locationService.outsideHumidityAbsolute(location, $event)" [filter]="filterHumidityAbsolute"></app-series-select>
</div>
</div>
</div>
</div>
}

View File

@ -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;

View File

@ -85,4 +85,16 @@ export class LocationService extends CrudService<Location> {
this.postSingle([location.id, 'powerProduce'], seriesId, next);
}
outsideTemperature(location: Location, seriesId: number | null, next?: Next<Location>) {
this.postSingle([location.id, 'outsideTemperature'], seriesId, next);
}
outsideHumidityRelative(location: Location, seriesId: number | null, next?: Next<Location>) {
this.postSingle([location.id, 'outsideHumidityRelative'], seriesId, next);
}
outsideHumidityAbsolute(location: Location, seriesId: number | null, next?: Next<Location>) {
this.postSingle([location.id, 'outsideHumidityAbsolute'], seriesId, next);
}
}

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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);
}
}