Compare commits
3 Commits
73926b13e6
...
97d558e9c9
| Author | SHA1 | Date | |
|---|---|---|---|
| 97d558e9c9 | |||
| 27238d73d0 | |||
| b94f602b4b |
25
src/main/angular/src/app/api/Area/Area.ts
Normal file
25
src/main/angular/src/app/api/Area/Area.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import {validateString} from "../common/validators";
|
||||
|
||||
export class Area {
|
||||
|
||||
constructor(
|
||||
readonly uuid: string,
|
||||
readonly slug: string,
|
||||
readonly name: string,
|
||||
) {
|
||||
//
|
||||
}
|
||||
|
||||
static fromJson(json: any): Area {
|
||||
return new Area(
|
||||
validateString(json.uuid),
|
||||
validateString(json.slug),
|
||||
validateString(json.name),
|
||||
);
|
||||
}
|
||||
|
||||
static compareByName(a: Area, b: Area): number {
|
||||
return a.name.localeCompare(b.name);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,9 +1,11 @@
|
||||
import {Property} from "../Property/Property";
|
||||
import {orNull, validateString} from "../common/validators";
|
||||
import {Area} from '../Area/Area';
|
||||
|
||||
export class Device {
|
||||
|
||||
constructor(
|
||||
readonly area: Area,
|
||||
readonly uuid: string,
|
||||
readonly name: string,
|
||||
readonly slug: string,
|
||||
@ -15,6 +17,7 @@ export class Device {
|
||||
|
||||
static fromJson(json: any): Device {
|
||||
return new Device(
|
||||
Area.fromJson(json.area),
|
||||
validateString(json.uuid),
|
||||
validateString(json.name),
|
||||
validateString(json.slug),
|
||||
@ -23,12 +26,34 @@ export class Device {
|
||||
);
|
||||
}
|
||||
|
||||
get nameOrArea(): string {
|
||||
if (this.name === '') {
|
||||
return this.area.name;
|
||||
}
|
||||
return this.name;
|
||||
}
|
||||
|
||||
get nameWithArea(): string {
|
||||
if (this.name === '') {
|
||||
return this.area.name;
|
||||
}
|
||||
return this.area.name + ' ' + this.name;
|
||||
}
|
||||
|
||||
static trackBy(index: number, device: Device) {
|
||||
return device.uuid;
|
||||
}
|
||||
|
||||
static equals(a: Device, b: Device): boolean {
|
||||
return a.uuid !== b.uuid;
|
||||
return a.uuid === b.uuid;
|
||||
}
|
||||
|
||||
static compareByAreaThenName(a: Device, b: Device): number {
|
||||
const area = Area.compareByName(a.area, b.area);
|
||||
if (area !== 0) {
|
||||
return area;
|
||||
}
|
||||
return a.name.localeCompare(b.name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -29,5 +29,9 @@ export class Group {
|
||||
return group.address;
|
||||
}
|
||||
|
||||
static compareByName(a: Group, b: Group): number {
|
||||
return a.name.localeCompare(b.name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
import {Property} from "../Property/Property";
|
||||
import {orNull, validateString} from "../common/validators";
|
||||
|
||||
import {Area} from '../Area/Area';
|
||||
|
||||
export class Shutter {
|
||||
|
||||
constructor(
|
||||
readonly area: Area,
|
||||
readonly uuid: string,
|
||||
readonly name: string,
|
||||
readonly slug: string,
|
||||
@ -15,6 +18,7 @@ export class Shutter {
|
||||
|
||||
static fromJson(json: any): Shutter {
|
||||
return new Shutter(
|
||||
Area.fromJson(json.area),
|
||||
validateString(json.uuid),
|
||||
validateString(json.name),
|
||||
validateString(json.slug),
|
||||
@ -23,12 +27,34 @@ export class Shutter {
|
||||
);
|
||||
}
|
||||
|
||||
get nameOrArea(): string {
|
||||
if (this.name === '') {
|
||||
return this.area.name;
|
||||
}
|
||||
return this.name;
|
||||
}
|
||||
|
||||
get nameWithArea(): string {
|
||||
if (this.name === '') {
|
||||
return this.area.name;
|
||||
}
|
||||
return this.area.name + ' ' + this.name;
|
||||
}
|
||||
|
||||
static trackBy(index: number, shutter: Shutter) {
|
||||
return shutter.uuid;
|
||||
}
|
||||
|
||||
static equals(a: Shutter, b: Shutter): boolean {
|
||||
return a.uuid !== b.uuid;
|
||||
return a.uuid === b.uuid;
|
||||
}
|
||||
|
||||
static compareByAreaThenName(a: Shutter, b: Shutter): number {
|
||||
const area = Area.compareByName(a.area, b.area);
|
||||
if (area !== 0) {
|
||||
return area;
|
||||
}
|
||||
return a.name.localeCompare(b.name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,12 +2,12 @@ export class ShutterFilter {
|
||||
|
||||
search: string = "";
|
||||
|
||||
positionOpen: boolean | null = null;
|
||||
positionOpen: boolean = true;
|
||||
|
||||
positionBetween: boolean | null = null;
|
||||
positionBetween: boolean = true;
|
||||
|
||||
positionClosed: boolean | null = null;
|
||||
positionClosed: boolean = true;
|
||||
|
||||
stateNull: boolean | null = null;
|
||||
stateNull: boolean = true;
|
||||
|
||||
}
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
import {Property} from "../Property/Property";
|
||||
import {orNull, validateString} from "../common/validators";
|
||||
import {Area} from '../Area/Area';
|
||||
|
||||
export class Tunable {
|
||||
|
||||
constructor(
|
||||
readonly area: Area,
|
||||
readonly uuid: string,
|
||||
readonly name: string,
|
||||
readonly slug: string,
|
||||
@ -19,6 +21,7 @@ export class Tunable {
|
||||
|
||||
static fromJson(json: any): Tunable {
|
||||
return new Tunable(
|
||||
Area.fromJson(json.area),
|
||||
validateString(json.uuid),
|
||||
validateString(json.name),
|
||||
validateString(json.slug),
|
||||
@ -31,12 +34,34 @@ export class Tunable {
|
||||
);
|
||||
}
|
||||
|
||||
get nameOrArea(): string {
|
||||
if (this.name === '') {
|
||||
return this.area.name;
|
||||
}
|
||||
return this.name;
|
||||
}
|
||||
|
||||
get nameWithArea(): string {
|
||||
if (this.name === '') {
|
||||
return this.area.name;
|
||||
}
|
||||
return this.area.name + ' ' + this.name;
|
||||
}
|
||||
|
||||
static trackBy(index: number, tunable: Tunable) {
|
||||
return tunable.uuid;
|
||||
}
|
||||
|
||||
static equals(a: Tunable, b: Tunable): boolean {
|
||||
return a.uuid !== b.uuid;
|
||||
return a.uuid === b.uuid;
|
||||
}
|
||||
|
||||
static compareByAreaThenName(a: Tunable, b: Tunable): number {
|
||||
const area = Area.compareByName(a.area, b.area);
|
||||
if (area !== 0) {
|
||||
return area;
|
||||
}
|
||||
return a.name.localeCompare(b.name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -10,33 +10,37 @@ export class CrudLiveList<ENTITY> extends Subscription {
|
||||
filtered: ENTITY[] = [];
|
||||
|
||||
constructor(
|
||||
crudService: CrudService<ENTITY>,
|
||||
readonly crudService: CrudService<ENTITY>,
|
||||
readonly equals: (a: ENTITY, b: ENTITY) => boolean,
|
||||
readonly filter: (item: ENTITY) => boolean = _ => true,
|
||||
) {
|
||||
super(() => {
|
||||
this.subs.forEach(sub => sub.unsubscribe());
|
||||
});
|
||||
crudService.all(list => this.unfiltered = list);
|
||||
this.fetchAll();
|
||||
this.subs.push(crudService.api.connected(_ => this.fetchAll()));
|
||||
this.subs.push(crudService.subscribe(item => this.update(item)));
|
||||
}
|
||||
|
||||
private fetchAll() {
|
||||
this.crudService.all(list => {
|
||||
this.unfiltered = list;
|
||||
this.updateFiltered();
|
||||
});
|
||||
}
|
||||
|
||||
private update(item: ENTITY) {
|
||||
const index = this.unfiltered.findIndex(i => this.equals(i, item));
|
||||
if (index >= 0) {
|
||||
this.unfiltered.splice(index, 1, item);
|
||||
this.unfiltered[index] = item;
|
||||
} else {
|
||||
this.unfiltered.push(item);
|
||||
}
|
||||
this.updateFiltered();
|
||||
}
|
||||
|
||||
private updateFiltered() {
|
||||
this.filtered = this.unfiltered.filter(this.filter);
|
||||
}
|
||||
|
||||
get hasUnfiltered(): boolean {
|
||||
return this.unfiltered.length > 0;
|
||||
}
|
||||
|
||||
get hasFiltered(): boolean {
|
||||
return this.filtered.length > 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -29,7 +29,6 @@ export class ApiService {
|
||||
}
|
||||
|
||||
subscribe<T>(topic: any[], fromJson: FromJson<T>, next: Next<T>): Subscription {
|
||||
console.info("WEBSOCKET SUBSCRIBE", topic)
|
||||
return this.stompService
|
||||
.subscribe(topic.join("/"))
|
||||
.pipe(
|
||||
|
||||
@ -10,8 +10,6 @@ export function stompServiceFactory() {
|
||||
reconnect_delay: 2000,
|
||||
headers: {},
|
||||
});
|
||||
stomp.connected$.subscribe(_ => console.info("WEBSOCKET CONNECTED"));
|
||||
stomp.webSocketErrors$.subscribe(_ => console.info("WEBSOCKET DISCONNECTED"));
|
||||
stomp.activate();
|
||||
return stomp;
|
||||
}
|
||||
|
||||
@ -2,19 +2,19 @@
|
||||
|
||||
<div class="subheading">
|
||||
Eingeschaltete Geräte:
|
||||
{{ deviceList.filtered.length }}
|
||||
{{ deviceList.filtered.length }} / {{ deviceList.unfiltered.length }}
|
||||
</div>
|
||||
<app-device-list [list]="deviceList.filtered"></app-device-list>
|
||||
|
||||
<div class="subheading">
|
||||
Eingeschaltete Lichter:
|
||||
{{ tunableList.filtered.length }}
|
||||
{{ tunableList.filtered.length }} / {{ tunableList.unfiltered.length }}
|
||||
</div>
|
||||
<app-tunable-list [list]="tunableList.filtered"></app-tunable-list>
|
||||
|
||||
<div class="subheading">
|
||||
{{ shutterSubheading }} Rollläden:
|
||||
{{ shutterList.filtered.length }}
|
||||
{{ shutterList.filtered.length }} / {{ shutterList.unfiltered.length }}
|
||||
</div>
|
||||
<app-shutter-list [list]="shutterList.filtered"></app-shutter-list>
|
||||
|
||||
|
||||
@ -36,8 +36,8 @@ export class TunableListPageComponent implements OnInit, OnDestroy {
|
||||
|
||||
ngOnInit(): void {
|
||||
this.fetch();
|
||||
this.subs.push(this.tunableService.subscribe(tunable => this.updateTunable(tunable)));
|
||||
this.apiService.connected(() => this.fetch());
|
||||
this.subs.push(this.tunableService.subscribe(tunable => this.updateTunable(tunable)));
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
<div class="deviceList tileContainer">
|
||||
|
||||
<div class="tile" *ngFor="let device of list; trackBy: Device.trackBy">
|
||||
<div class="tile" *ngFor="let device of sorted(); trackBy: Device.trackBy">
|
||||
|
||||
<div class="device tileInner" [ngClass]="ngClass(device)">
|
||||
|
||||
<div class="name">
|
||||
{{ device.name }}
|
||||
{{ device.nameWithArea }}
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
|
||||
@ -49,4 +49,8 @@ export class DeviceListComponent implements OnInit, OnDestroy {
|
||||
};
|
||||
}
|
||||
|
||||
sorted(): Device[] {
|
||||
return this.list.sort(Device.compareByAreaThenName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<div class="groupList tileContainer">
|
||||
|
||||
<div class="tile" *ngFor="let group of groupList; trackBy: Group.trackBy">
|
||||
<div class="tile" *ngFor="let group of sorted(); trackBy: Group.trackBy">
|
||||
|
||||
<div class="group tileInner" [ngClass]="ngClass(group)">
|
||||
|
||||
|
||||
@ -42,4 +42,8 @@ export class KnxGroupListComponent implements OnInit, OnDestroy {
|
||||
this.subs.forEach(sub => sub.unsubscribe());
|
||||
}
|
||||
|
||||
sorted(): Group[] {
|
||||
return this.groupList.sort(Group.compareByName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
<div class="shutterList tileContainer">
|
||||
|
||||
<div class="tile" *ngFor="let shutter of list; trackBy: Shutter.trackBy">
|
||||
<div class="tile" *ngFor="let shutter of sorted(); trackBy: Shutter.trackBy">
|
||||
|
||||
<div class="shutter tileInner">
|
||||
|
||||
<div class="name">
|
||||
{{ shutter.name }}
|
||||
{{ shutter.nameWithArea }}
|
||||
</div>
|
||||
|
||||
<div class="icon">
|
||||
|
||||
@ -43,4 +43,8 @@ export class ShutterListComponent implements OnInit, OnDestroy {
|
||||
this.subs.forEach(sub => sub.unsubscribe());
|
||||
}
|
||||
|
||||
sorted(): Shutter[] {
|
||||
return this.list.sort(Shutter.compareByAreaThenName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
<div class="tunableList tileContainer">
|
||||
|
||||
<div *ngFor="let tunable of list; trackBy: Tunable.trackBy" class="tile">
|
||||
<div *ngFor="let tunable of sorted(); trackBy: Tunable.trackBy" class="tile">
|
||||
|
||||
<div [ngClass]="ngClass(tunable)" class="tunable tileInner">
|
||||
|
||||
<div class="name">
|
||||
{{ tunable.name }}
|
||||
{{ tunable.nameWithArea }}
|
||||
</div>
|
||||
|
||||
<div class="timestamp details">
|
||||
@ -13,10 +13,10 @@
|
||||
</div>
|
||||
|
||||
<div class="sliders">
|
||||
<div class="slider">
|
||||
<div class="slider" *ngIf="tunable.brightnessPropertyId !== ''">
|
||||
<input type="range" [ngModel]="tunable.brightnessProperty?.state?.value" (ngModelChange)="tunableService.setBrightness(tunable, $event)">
|
||||
</div>
|
||||
<div class="slider">
|
||||
<div class="slider" *ngIf="tunable.coldnessPropertyId !== ''">
|
||||
<input type="range" [ngModel]="tunable.coldnessProperty?.state?.value" (ngModelChange)="tunableService.setColdness(tunable, $event)">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import {Component, Input, OnDestroy, OnInit} from '@angular/core';
|
||||
import {NgClass, NgForOf} from '@angular/common';
|
||||
import {NgClass, NgForOf, NgIf} from '@angular/common';
|
||||
import {Tunable} from '../../api/Tunable/Tunable';
|
||||
import {TunableService} from '../../api/Tunable/tunable.service';
|
||||
import {RelativePipe} from '../../api/common/relative.pipe';
|
||||
@ -13,7 +13,8 @@ import {FormsModule} from '@angular/forms';
|
||||
NgForOf,
|
||||
NgClass,
|
||||
RelativePipe,
|
||||
FormsModule
|
||||
FormsModule,
|
||||
NgIf
|
||||
],
|
||||
templateUrl: './tunable-list.component.html',
|
||||
styleUrl: './tunable-list.component.less'
|
||||
@ -51,4 +52,8 @@ export class TunableListComponent implements OnInit, OnDestroy {
|
||||
};
|
||||
}
|
||||
|
||||
sorted(): Tunable[] {
|
||||
return this.list.sort(Tunable.compareByAreaThenName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
36
src/main/java/de/ph87/home/area/Area.java
Normal file
36
src/main/java/de/ph87/home/area/Area.java
Normal file
@ -0,0 +1,36 @@
|
||||
package de.ph87.home.area;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
public class Area {
|
||||
|
||||
@Id
|
||||
@NonNull
|
||||
private String uuid = UUID.randomUUID().toString();
|
||||
|
||||
@NonNull
|
||||
@Column(nullable = false)
|
||||
private String name;
|
||||
|
||||
@NonNull
|
||||
@Column(nullable = false, unique = true)
|
||||
private String slug;
|
||||
|
||||
public Area(@NonNull final String name, @NonNull final String slug) {
|
||||
this.name = name;
|
||||
this.slug = slug;
|
||||
}
|
||||
|
||||
}
|
||||
44
src/main/java/de/ph87/home/area/AreaController.java
Normal file
44
src/main/java/de/ph87/home/area/AreaController.java
Normal file
@ -0,0 +1,44 @@
|
||||
package de.ph87.home.area;
|
||||
|
||||
import de.ph87.home.property.PropertyTypeMismatch;
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import tuwien.auto.calimero.KNXFormatException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("Area")
|
||||
public class AreaController {
|
||||
|
||||
private final AreaService areaService;
|
||||
|
||||
@NonNull
|
||||
@GetMapping("getByUuid/{id}")
|
||||
@ExceptionHandler(KNXFormatException.class)
|
||||
private AreaDto getByUuid(@PathVariable final String id, @NonNull final HttpServletRequest request) {
|
||||
log.debug("getByUuid: path={}", request.getServletPath());
|
||||
return areaService.getByUuidDto(id);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@RequestMapping(value = "list", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
private List<AreaDto> list(@RequestBody(required = false) @Nullable final AreaFilter filter, @NonNull final HttpServletRequest request) throws PropertyTypeMismatch {
|
||||
log.debug("list: path={} filter={}", request.getServletPath(), filter);
|
||||
return areaService.list(filter);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@GetMapping("get/{uuidOrSlug}")
|
||||
private AreaDto get(@PathVariable @NonNull final String uuidOrSlug, @NonNull final HttpServletRequest request) {
|
||||
log.debug("get: path={}", request.getServletPath());
|
||||
return areaService.getByUuidOrSlugDto(uuidOrSlug);
|
||||
}
|
||||
|
||||
}
|
||||
32
src/main/java/de/ph87/home/area/AreaDto.java
Normal file
32
src/main/java/de/ph87/home/area/AreaDto.java
Normal file
@ -0,0 +1,32 @@
|
||||
package de.ph87.home.area;
|
||||
|
||||
import de.ph87.home.web.IWebSocketMessage;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@ToString
|
||||
public class AreaDto implements IWebSocketMessage {
|
||||
|
||||
@ToString.Exclude
|
||||
private final List<Object> websocketTopic = List.of("Area");
|
||||
|
||||
@NonNull
|
||||
private final String uuid;
|
||||
|
||||
@NonNull
|
||||
private final String name;
|
||||
|
||||
@NonNull
|
||||
private final String slug;
|
||||
|
||||
public AreaDto(@NonNull final Area area) {
|
||||
this.uuid = area.getUuid();
|
||||
this.name = area.getName();
|
||||
this.slug = area.getSlug();
|
||||
}
|
||||
|
||||
}
|
||||
17
src/main/java/de/ph87/home/area/AreaFilter.java
Normal file
17
src/main/java/de/ph87/home/area/AreaFilter.java
Normal file
@ -0,0 +1,17 @@
|
||||
package de.ph87.home.area;
|
||||
|
||||
import de.ph87.home.common.crud.AbstractSearchFilter;
|
||||
import de.ph87.home.property.PropertyTypeMismatch;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@ToString
|
||||
public class AreaFilter extends AbstractSearchFilter {
|
||||
|
||||
public boolean filter(@NonNull final AreaDto dto) throws PropertyTypeMismatch {
|
||||
return search(dto.getName());
|
||||
}
|
||||
|
||||
}
|
||||
12
src/main/java/de/ph87/home/area/AreaRepository.java
Normal file
12
src/main/java/de/ph87/home/area/AreaRepository.java
Normal file
@ -0,0 +1,12 @@
|
||||
package de.ph87.home.area;
|
||||
|
||||
import lombok.NonNull;
|
||||
import org.springframework.data.repository.ListCrudRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface AreaRepository extends ListCrudRepository<Area, String> {
|
||||
|
||||
Optional<Area> findByUuidOrSlug(@NonNull String uuid, @NonNull String slug);
|
||||
|
||||
}
|
||||
81
src/main/java/de/ph87/home/area/AreaService.java
Normal file
81
src/main/java/de/ph87/home/area/AreaService.java
Normal file
@ -0,0 +1,81 @@
|
||||
package de.ph87.home.area;
|
||||
|
||||
import de.ph87.home.common.crud.CrudAction;
|
||||
import de.ph87.home.common.crud.EntityNotFound;
|
||||
import de.ph87.home.property.PropertyTypeMismatch;
|
||||
import jakarta.annotation.Nullable;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional
|
||||
@RequiredArgsConstructor
|
||||
public class AreaService {
|
||||
|
||||
private final AreaRepository areaRepository;
|
||||
|
||||
private final ApplicationEventPublisher applicationEventPublisher;
|
||||
|
||||
@NonNull
|
||||
public AreaDto create(@NonNull final String name, @NonNull final String slug) {
|
||||
return publish(areaRepository.save(new Area(name, slug)), CrudAction.UPDATED);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public AreaDto getByUuidOrSlugDto(final @NonNull String uuidOrSlug) {
|
||||
return toDto(getByUuidOrSlug(uuidOrSlug));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private Area getByUuidOrSlug(@NonNull final String uuidOrSlug) {
|
||||
return areaRepository.findByUuidOrSlug(uuidOrSlug, uuidOrSlug).orElseThrow(() -> new EntityNotFound("uuidOrSlug", uuidOrSlug));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public AreaDto toDto(@NonNull final Area area) {
|
||||
return new AreaDto(area);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Area getByUuid(@NonNull final String uuid) {
|
||||
return areaRepository.findById(uuid).orElseThrow(() -> new EntityNotFound("uuid", uuid));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public List<AreaDto> list(@Nullable final AreaFilter filter) throws PropertyTypeMismatch {
|
||||
final List<AreaDto> all = areaRepository.findAll().stream().map(this::toDto).toList();
|
||||
if (filter == null) {
|
||||
return all;
|
||||
}
|
||||
final List<AreaDto> results = new ArrayList<>();
|
||||
for (final AreaDto dto : all) {
|
||||
if (filter.filter(dto)) {
|
||||
results.add(dto);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
private AreaDto publish(@NonNull final Area area, @NonNull final CrudAction action) {
|
||||
final AreaDto dto = toDto(area);
|
||||
log.info("Area {}: {}", action, dto);
|
||||
applicationEventPublisher.publishEvent(dto);
|
||||
return dto;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public AreaDto getByUuidDto(@NonNull final String uuid) {
|
||||
return toDto(getByUuid(uuid));
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
package de.ph87.home.demo;
|
||||
|
||||
import de.ph87.home.area.AreaDto;
|
||||
import de.ph87.home.area.AreaService;
|
||||
import de.ph87.home.device.DeviceService;
|
||||
import de.ph87.home.knx.property.KnxPropertyService;
|
||||
import de.ph87.home.knx.property.KnxPropertyType;
|
||||
@ -19,6 +21,7 @@ import tuwien.auto.calimero.GroupAddress;
|
||||
@Service
|
||||
@Transactional
|
||||
@RequiredArgsConstructor
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
public class DemoService {
|
||||
|
||||
private final KnxPropertyService knxPropertyService;
|
||||
@ -29,47 +32,68 @@ public class DemoService {
|
||||
|
||||
private final TunableService tunableService;
|
||||
|
||||
private final AreaService areaService;
|
||||
|
||||
@EventListener(ApplicationStartedEvent.class)
|
||||
public void startup() {
|
||||
device("eg_ambiente", "EG Ambiente", 849, 848);
|
||||
device("fernseher", "Wohnzimmer Fernseher", 20, 4);
|
||||
device("verstaerker", "Wohnzimmer Verstärker", 825, 824);
|
||||
device("fensterdeko", "Wohnzimmer Fenster", 1823, 1822);
|
||||
device("haengelampe", "Wohnzimmer Hängelampe", 1794, 1799);
|
||||
device("receiver", "Receiver", 2561, 2560);
|
||||
final AreaDto eg = area("eg", "EG");
|
||||
|
||||
tunable("wohnzimmer_spots", "Wohnzimmer", 28, 828, 2344, 2343, 1825, 1824);
|
||||
tunable("kueche_spots", "Küche", 2311, 2304, 2342, 2341, 2321, 2317);
|
||||
tunable("arbeitszimmer_spots", "Arbeitszimmer", 2058, 2057, 2067, 2069, 2049, 2054);
|
||||
final AreaDto wohnzimmer = area("wohnzimmer", "Wohnzimmer");
|
||||
device(wohnzimmer, "fernseher", "Fernseher", 20, 4);
|
||||
device(wohnzimmer, "verstaerker", "Verstärker", 825, 824);
|
||||
tunable(wohnzimmer, "haengelampe", "Hängelampe", 1794, 1799, null, null, null, null);
|
||||
tunable(wohnzimmer, "fensterdeko", "Fenster", 1823, 1822, null, null, null, null);
|
||||
tunable(wohnzimmer, "spots", "", 28, 828, 2344, 2343, 1825, 1824);
|
||||
shutter(wohnzimmer, "links", "Links", 1048);
|
||||
shutter(wohnzimmer, "rechts", "Rechts", 1811);
|
||||
|
||||
shutter("wohnzimmer_links", "Wohnzimmer Links", 1048);
|
||||
shutter("wohnzimmer_rechts", "Wohnzimmer Rechts", 1811);
|
||||
shutter("kueche_seite", "Küche Seite", 2316);
|
||||
shutter("kueche_theke", "Küche Theke", 2320);
|
||||
shutter("kueche_tuer", "Küche Tür", 2324);
|
||||
final AreaDto kueche = area("kueche", "Küche");
|
||||
tunable(kueche, "kueche_spots", "", 2311, 2304, 2342, 2341, 2321, 2317);
|
||||
shutter(kueche, "kueche_seite", "Seite", 2316);
|
||||
shutter(kueche, "kueche_theke", "Theke", 2320);
|
||||
shutter(kueche, "kueche_tuer", "Tür", 2324);
|
||||
|
||||
tunable(eg, "eg_ambiente", "Ambiente", 849, 848, null, null, null, null);
|
||||
|
||||
final AreaDto arbeitszimmer = area("arbeitszimmer", "Arbeitszimmer");
|
||||
tunable(arbeitszimmer, "spots", "", 2058, 2057, 2067, 2069, 2049, 2054);
|
||||
|
||||
final AreaDto keller = area("keller", "Keller");
|
||||
device(keller, "receiver", "Receiver", 2561, 2560);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private AreaDto area(@NonNull final String slug, @NonNull final String name) {
|
||||
return areaService.create(name, slug);
|
||||
}
|
||||
|
||||
private void device(
|
||||
@NonNull final String slug,
|
||||
@NonNull final AreaDto area,
|
||||
@NonNull final String subSlug,
|
||||
@NonNull final String name,
|
||||
@Nullable final Integer stateRead,
|
||||
@Nullable final Integer stateWrite
|
||||
) {
|
||||
knxPropertyService.create(slug, KnxPropertyType.BOOLEAN, adr(stateRead), adr(stateWrite));
|
||||
deviceService.create(name, slug, slug);
|
||||
@Nullable final Integer stateWrite) {
|
||||
final String slug = area.getSlug() + "_" + subSlug;
|
||||
final String statePropertyId = slug + "_state";
|
||||
knxPropertyService.create(statePropertyId, KnxPropertyType.BOOLEAN, adr(stateRead), adr(stateWrite));
|
||||
deviceService.create(area.getUuid(), name, slug, statePropertyId);
|
||||
}
|
||||
|
||||
private void shutter(
|
||||
@NonNull final String slug,
|
||||
@NonNull final AreaDto area,
|
||||
@NonNull final String subSlug,
|
||||
@NonNull final String name,
|
||||
@Nullable final Integer positionReadWrite
|
||||
) {
|
||||
knxPropertyService.create(slug, KnxPropertyType.DOUBLE, adr(positionReadWrite), adr(positionReadWrite));
|
||||
shutterService.create(name, slug, slug);
|
||||
final String slug = area.getSlug() + "_" + subSlug;
|
||||
final String statePropertyId = slug + "_state";
|
||||
knxPropertyService.create(statePropertyId, KnxPropertyType.DOUBLE, adr(positionReadWrite), adr(positionReadWrite));
|
||||
shutterService.create(area.getUuid(), name, slug, statePropertyId);
|
||||
}
|
||||
|
||||
private void tunable(
|
||||
@NonNull final String slug,
|
||||
@NonNull final AreaDto area,
|
||||
@NonNull final String subSlug,
|
||||
@NonNull final String name,
|
||||
@Nullable final Integer stateRead,
|
||||
@Nullable final Integer stateWrite,
|
||||
@ -78,16 +102,20 @@ public class DemoService {
|
||||
@Nullable final Integer coldnessRead,
|
||||
@Nullable final Integer coldnessWrite
|
||||
) {
|
||||
final String stateProperty = slug + "_state";
|
||||
knxPropertyService.create(stateProperty, KnxPropertyType.BOOLEAN, adr(stateRead), adr(stateWrite));
|
||||
final String slug = area.getSlug() + "_" + subSlug;
|
||||
final String stateProperty = knxProperty(slug + "_state", KnxPropertyType.BOOLEAN, stateRead, stateWrite);
|
||||
final String brightnessProperty = knxProperty(slug + "_brightness", KnxPropertyType.DOUBLE, brightnessRead, brightnessWrite);
|
||||
final String coldnessProperty = knxProperty(slug + "_coldness", KnxPropertyType.DOUBLE, coldnessRead, coldnessWrite);
|
||||
tunableService.create(area.getUuid(), name, slug, stateProperty, brightnessProperty, coldnessProperty);
|
||||
}
|
||||
|
||||
final String brightnessProperty = slug + "_brightness";
|
||||
knxPropertyService.create(brightnessProperty, KnxPropertyType.DOUBLE, adr(brightnessRead), adr(brightnessWrite));
|
||||
|
||||
final String coldnessProperty = slug + "_coldness";
|
||||
knxPropertyService.create(coldnessProperty, KnxPropertyType.DOUBLE, adr(coldnessRead), adr(coldnessWrite));
|
||||
|
||||
tunableService.create(name, slug, stateProperty, brightnessProperty, coldnessProperty);
|
||||
@NonNull
|
||||
private String knxProperty(@NonNull final String id, @NonNull final KnxPropertyType type, @Nullable final Integer stateRead, @Nullable final Integer stateWrite) {
|
||||
if (stateRead == null && stateWrite == null) {
|
||||
return "";
|
||||
}
|
||||
knxPropertyService.create(id, type, adr(stateRead), adr(stateWrite));
|
||||
return id;
|
||||
}
|
||||
|
||||
private static GroupAddress adr(final Integer rawGroupAddress) {
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package de.ph87.home.device;
|
||||
|
||||
import de.ph87.home.area.Area;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.UUID;
|
||||
@ -17,6 +19,10 @@ public class Device {
|
||||
@NonNull
|
||||
private String uuid = UUID.randomUUID().toString();
|
||||
|
||||
@NonNull
|
||||
@ManyToOne(optional = false)
|
||||
private Area area;
|
||||
|
||||
@NonNull
|
||||
@Column(nullable = false)
|
||||
private String name;
|
||||
@ -30,7 +36,8 @@ public class Device {
|
||||
@Column(nullable = false)
|
||||
private String statePropertyId;
|
||||
|
||||
public Device(@NonNull final String name, @NonNull final String slug, @NonNull final String statePropertyId) {
|
||||
public Device(final Area area, @NonNull final String name, @NonNull final String slug, @NonNull final String statePropertyId) {
|
||||
this.area = area;
|
||||
this.name = name;
|
||||
this.slug = slug;
|
||||
this.statePropertyId = statePropertyId;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package de.ph87.home.device;
|
||||
|
||||
import de.ph87.home.area.AreaDto;
|
||||
import de.ph87.home.property.PropertyDto;
|
||||
import de.ph87.home.property.PropertyTypeMismatch;
|
||||
import de.ph87.home.web.IWebSocketMessage;
|
||||
@ -17,6 +18,9 @@ public class DeviceDto implements IWebSocketMessage {
|
||||
@ToString.Exclude
|
||||
private final List<Object> websocketTopic = List.of("Device");
|
||||
|
||||
@NonNull
|
||||
private final AreaDto area;
|
||||
|
||||
@NonNull
|
||||
private final String uuid;
|
||||
|
||||
@ -34,6 +38,7 @@ public class DeviceDto implements IWebSocketMessage {
|
||||
private final PropertyDto<Boolean> stateProperty;
|
||||
|
||||
public DeviceDto(@NonNull final Device device, @Nullable final PropertyDto<Boolean> stateProperty) {
|
||||
this.area = new AreaDto(device.getArea());
|
||||
this.uuid = device.getUuid();
|
||||
this.name = device.getName();
|
||||
this.slug = device.getSlug();
|
||||
|
||||
@ -12,13 +12,13 @@ import lombok.ToString;
|
||||
public class DeviceFilter extends AbstractSearchFilter {
|
||||
|
||||
@JsonProperty
|
||||
private boolean stateNull;
|
||||
private boolean stateNull = true;
|
||||
|
||||
@JsonProperty
|
||||
private boolean stateTrue;
|
||||
private boolean stateTrue = true;
|
||||
|
||||
@JsonProperty
|
||||
private boolean stateFalse;
|
||||
private boolean stateFalse = true;
|
||||
|
||||
public boolean filter(@NonNull final DeviceDto dto) throws PropertyTypeMismatch {
|
||||
final Boolean value = dto.getStateValue();
|
||||
@ -28,7 +28,7 @@ public class DeviceFilter extends AbstractSearchFilter {
|
||||
if (!stateTrue && Boolean.TRUE.equals(value)) {
|
||||
return false;
|
||||
}
|
||||
if (!stateFalse == Boolean.FALSE.equals(value)) {
|
||||
if (!stateFalse && Boolean.FALSE.equals(value)) {
|
||||
return false;
|
||||
}
|
||||
return search(dto.getName());
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package de.ph87.home.device;
|
||||
|
||||
import de.ph87.home.area.Area;
|
||||
import de.ph87.home.area.AreaService;
|
||||
import de.ph87.home.common.crud.CrudAction;
|
||||
import de.ph87.home.common.crud.EntityNotFound;
|
||||
import de.ph87.home.property.*;
|
||||
@ -27,9 +29,12 @@ public class DeviceService {
|
||||
|
||||
private final ApplicationEventPublisher applicationEventPublisher;
|
||||
|
||||
private final AreaService areaService;
|
||||
|
||||
@NonNull
|
||||
public DeviceDto create(@NonNull final String name, @NonNull final String slug, @NonNull final String stateProperty) {
|
||||
return publish(deviceRepository.save(new Device(name, slug, stateProperty)), CrudAction.UPDATED);
|
||||
public DeviceDto create(@NonNull final String areaUuid, @NonNull final String name, @NonNull final String slug, @NonNull final String stateProperty) {
|
||||
final Area area = areaService.getByUuid(areaUuid);
|
||||
return publish(deviceRepository.save(new Device(area, name, slug, stateProperty)), CrudAction.UPDATED);
|
||||
}
|
||||
|
||||
public void setState(@NonNull final String uuidOrSlug, final boolean state) throws PropertyNotFound, PropertyNotWritable, PropertyTypeMismatch {
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package de.ph87.home.shutter;
|
||||
|
||||
import de.ph87.home.area.Area;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.UUID;
|
||||
@ -17,6 +19,10 @@ public class Shutter {
|
||||
@NonNull
|
||||
private String uuid = UUID.randomUUID().toString();
|
||||
|
||||
@NonNull
|
||||
@ManyToOne(optional = false)
|
||||
private Area area;
|
||||
|
||||
@NonNull
|
||||
@Column(nullable = false)
|
||||
private String name;
|
||||
@ -30,7 +36,8 @@ public class Shutter {
|
||||
@Column(nullable = false)
|
||||
private String positionPropertyId;
|
||||
|
||||
public Shutter(@NonNull final String name, @NonNull final String slug, @NonNull final String positionPropertyId) {
|
||||
public Shutter(@NonNull final Area area, @NonNull final String name, @NonNull final String slug, @NonNull final String positionPropertyId) {
|
||||
this.area = area;
|
||||
this.name = name;
|
||||
this.slug = slug;
|
||||
this.positionPropertyId = positionPropertyId;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package de.ph87.home.shutter;
|
||||
|
||||
import de.ph87.home.area.AreaDto;
|
||||
import de.ph87.home.property.PropertyDto;
|
||||
import de.ph87.home.property.PropertyTypeMismatch;
|
||||
import de.ph87.home.web.IWebSocketMessage;
|
||||
@ -17,6 +18,8 @@ public class ShutterDto implements IWebSocketMessage {
|
||||
@ToString.Exclude
|
||||
private final List<Object> websocketTopic = List.of("Shutter");
|
||||
|
||||
@NonNull
|
||||
private final AreaDto area;
|
||||
@NonNull
|
||||
private final String uuid;
|
||||
|
||||
@ -34,6 +37,7 @@ public class ShutterDto implements IWebSocketMessage {
|
||||
private final PropertyDto<Double> positionProperty;
|
||||
|
||||
public ShutterDto(@NonNull final Shutter shutter, @Nullable final PropertyDto<Double> positionProperty) {
|
||||
this.area = new AreaDto(shutter.getArea());
|
||||
this.uuid = shutter.getUuid();
|
||||
this.name = shutter.getName();
|
||||
this.slug = shutter.getSlug();
|
||||
|
||||
@ -3,36 +3,40 @@ package de.ph87.home.shutter;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import de.ph87.home.common.crud.AbstractSearchFilter;
|
||||
import de.ph87.home.property.PropertyTypeMismatch;
|
||||
import jakarta.annotation.Nullable;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Getter
|
||||
@ToString
|
||||
public class ShutterFilter extends AbstractSearchFilter {
|
||||
|
||||
@Nullable
|
||||
@JsonProperty
|
||||
private Boolean positionNull;
|
||||
private boolean positionNull = true;
|
||||
|
||||
@Nullable
|
||||
@JsonProperty
|
||||
private Double positionMin;
|
||||
private boolean positionOpen = true;
|
||||
|
||||
@Nullable
|
||||
@JsonProperty
|
||||
private Double positionMax;
|
||||
private boolean positionBetween = true;
|
||||
|
||||
@JsonProperty
|
||||
private boolean positionClosed = true;
|
||||
|
||||
public boolean filter(@NonNull final ShutterDto dto) throws PropertyTypeMismatch {
|
||||
if (positionNull != null && positionNull != (dto.getPositionProperty() == null)) {
|
||||
return false;
|
||||
}
|
||||
final Double value = dto.getPositionValue();
|
||||
if (positionMin != null && value != null && positionMin <= value) {
|
||||
if (!positionNull && value == null) {
|
||||
return false;
|
||||
}
|
||||
if (positionMax != null && value != null && positionMax >= value) {
|
||||
if (!positionOpen && Objects.equals(value, 0.0)) {
|
||||
return false;
|
||||
}
|
||||
if (!positionBetween && !Objects.equals(value, 0.0) && !Objects.equals(value, 100.0)) {
|
||||
return false;
|
||||
}
|
||||
if (!positionClosed && Objects.equals(value, 100.0)) {
|
||||
return false;
|
||||
}
|
||||
return search(dto.getName());
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package de.ph87.home.shutter;
|
||||
|
||||
import de.ph87.home.area.Area;
|
||||
import de.ph87.home.area.AreaService;
|
||||
import de.ph87.home.common.crud.CrudAction;
|
||||
import de.ph87.home.common.crud.EntityNotFound;
|
||||
import de.ph87.home.property.*;
|
||||
@ -21,6 +23,8 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
public class ShutterService {
|
||||
|
||||
private final AreaService areaService;
|
||||
|
||||
private final PropertyService propertyService;
|
||||
|
||||
private final ShutterRepository shutterRepository;
|
||||
@ -28,8 +32,9 @@ public class ShutterService {
|
||||
private final ApplicationEventPublisher applicationEventPublisher;
|
||||
|
||||
@NonNull
|
||||
public ShutterDto create(@NonNull final String name, @NonNull final String slug, @NonNull final String positionProperty) {
|
||||
return publish(shutterRepository.save(new Shutter(name, slug, positionProperty)), CrudAction.CREATED);
|
||||
public ShutterDto create(@NonNull final String areaUuid, @NonNull final String name, @NonNull final String slug, @NonNull final String positionProperty) {
|
||||
final Area area = areaService.getByUuid(areaUuid);
|
||||
return publish(shutterRepository.save(new Shutter(area, name, slug, positionProperty)), CrudAction.CREATED);
|
||||
}
|
||||
|
||||
public void setPosition(@NonNull final String uuidOrSlug, final double position) throws PropertyNotFound, PropertyNotWritable, PropertyTypeMismatch {
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package de.ph87.home.tunable;
|
||||
|
||||
import de.ph87.home.area.Area;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.UUID;
|
||||
@ -17,6 +19,10 @@ public class Tunable {
|
||||
@NonNull
|
||||
private String uuid = UUID.randomUUID().toString();
|
||||
|
||||
@NonNull
|
||||
@ManyToOne(optional = false)
|
||||
private Area area;
|
||||
|
||||
@NonNull
|
||||
@Column(nullable = false)
|
||||
private String name;
|
||||
@ -40,7 +46,8 @@ public class Tunable {
|
||||
@Column(nullable = false)
|
||||
private String coldnessPropertyId;
|
||||
|
||||
public Tunable(@NonNull final String name, @NonNull final String slug, @NonNull final String statePropertyId, @NonNull final String brightnessPropertyId, @NonNull final String coldnessPropertyId) {
|
||||
public Tunable(@NonNull final Area area, @NonNull final String name, @NonNull final String slug, @NonNull final String statePropertyId, @NonNull final String brightnessPropertyId, @NonNull final String coldnessPropertyId) {
|
||||
this.area = area;
|
||||
this.name = name;
|
||||
this.slug = slug;
|
||||
this.statePropertyId = statePropertyId;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package de.ph87.home.tunable;
|
||||
|
||||
import de.ph87.home.area.AreaDto;
|
||||
import de.ph87.home.property.PropertyDto;
|
||||
import de.ph87.home.property.PropertyTypeMismatch;
|
||||
import de.ph87.home.web.IWebSocketMessage;
|
||||
@ -17,6 +18,9 @@ public class TunableDto implements IWebSocketMessage {
|
||||
@ToString.Exclude
|
||||
private final List<Object> websocketTopic = List.of("Tunable");
|
||||
|
||||
@NonNull
|
||||
private final AreaDto area;
|
||||
|
||||
@NonNull
|
||||
private final String uuid;
|
||||
|
||||
@ -48,6 +52,7 @@ public class TunableDto implements IWebSocketMessage {
|
||||
private final PropertyDto<Double> coldnessProperty;
|
||||
|
||||
public TunableDto(@NonNull final Tunable tunable, @Nullable final PropertyDto<Boolean> stateProperty, @Nullable final PropertyDto<Double> brightnessProperty, @Nullable final PropertyDto<Double> coldnessProperty) {
|
||||
this.area = new AreaDto(tunable.getArea());
|
||||
this.uuid = tunable.getUuid();
|
||||
this.name = tunable.getName();
|
||||
this.slug = tunable.getSlug();
|
||||
|
||||
@ -12,13 +12,13 @@ import lombok.ToString;
|
||||
public class TunableFilter extends AbstractSearchFilter {
|
||||
|
||||
@JsonProperty
|
||||
private boolean stateNull;
|
||||
private boolean stateNull = true;
|
||||
|
||||
@JsonProperty
|
||||
private boolean stateTrue;
|
||||
private boolean stateTrue = true;
|
||||
|
||||
@JsonProperty
|
||||
private boolean stateFalse;
|
||||
private boolean stateFalse = true;
|
||||
|
||||
public boolean filter(@NonNull final TunableDto dto) throws PropertyTypeMismatch {
|
||||
final Boolean value = dto.getStateValue();
|
||||
@ -28,7 +28,7 @@ public class TunableFilter extends AbstractSearchFilter {
|
||||
if (!stateTrue && Boolean.TRUE.equals(value)) {
|
||||
return false;
|
||||
}
|
||||
if (!stateFalse == Boolean.FALSE.equals(value)) {
|
||||
if (!stateFalse && Boolean.FALSE.equals(value)) {
|
||||
return false;
|
||||
}
|
||||
return search(dto.getName());
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package de.ph87.home.tunable;
|
||||
|
||||
import de.ph87.home.area.Area;
|
||||
import de.ph87.home.area.AreaService;
|
||||
import de.ph87.home.common.crud.CrudAction;
|
||||
import de.ph87.home.common.crud.EntityNotFound;
|
||||
import de.ph87.home.property.*;
|
||||
@ -27,9 +29,12 @@ public class TunableService {
|
||||
|
||||
private final ApplicationEventPublisher applicationEventPublisher;
|
||||
|
||||
private final AreaService areaService;
|
||||
|
||||
@NonNull
|
||||
public TunableDto create(@NonNull final String name, @NonNull final String slug, @NonNull final String stateProperty, @NonNull final String brightnessProperty, @NonNull final String coldnessProperty) {
|
||||
return publish(tunableRepository.save(new Tunable(name, slug, stateProperty, brightnessProperty, coldnessProperty)), CrudAction.UPDATED);
|
||||
public TunableDto create(@NonNull final String areaUuid, @NonNull final String name, @NonNull final String slug, @NonNull final String stateProperty, @NonNull final String brightnessProperty, @NonNull final String coldnessProperty) {
|
||||
final Area area = areaService.getByUuid(areaUuid);
|
||||
return publish(tunableRepository.save(new Tunable(area, name, slug, stateProperty, brightnessProperty, coldnessProperty)), CrudAction.UPDATED);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
@ -13,7 +13,7 @@ import java.time.Duration;
|
||||
public class TvheadendConfig {
|
||||
|
||||
@NonNull
|
||||
private String receiver = "receiver";
|
||||
private String receiver = "keller_receiver";
|
||||
|
||||
@NonNull
|
||||
private Duration BEFORE_RECORDING = Duration.ofMinutes(10);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user