diff --git a/pom.xml b/pom.xml index 1cd3ec6..50c1f6c 100644 --- a/pom.xml +++ b/pom.xml @@ -48,9 +48,14 @@ org.projectlombok lombok - 1.18.20 + 1.18.22 + + org.jsoup + jsoup + 1.14.3 + com.github.calimero calimero-core diff --git a/src/main/angular/src/app/api/device/Device.ts b/src/main/angular/src/app/api/device/Device.ts index e2e20d8..0caac7e 100644 --- a/src/main/angular/src/app/api/device/Device.ts +++ b/src/main/angular/src/app/api/device/Device.ts @@ -1,4 +1,4 @@ -import {validateBooleanAllowNull, validateNumberAllowNull, validateNumberNotNull, validateStringNotEmptyNotNull, validateStringNullToEmpty} from "../validators"; +import {validateNumberNotNull, validateStringNotEmptyNotNull} from "../validators"; import {Property} from "../property/property.service"; export abstract class Device { @@ -19,18 +19,14 @@ export abstract class Device { validateNumberNotNull(json['id']), validateStringNotEmptyNotNull(json['title']), type, - validateStringNullToEmpty(json['getState']), - validateStringNullToEmpty(json['setState']), - validateBooleanAllowNull(json['state']), + Property.fromJsonAllowNull(json['stateProperty']), ); case "DeviceShutter": return new DeviceShutter( validateNumberNotNull(json['id']), validateStringNotEmptyNotNull(json['title']), type, - validateStringNullToEmpty(json['getPercent']), - validateStringNullToEmpty(json['setPercent']), - validateNumberAllowNull(json['percent']), + Property.fromJsonAllowNull(json['positionProperty']), ); } throw new Error("No such type: " + type); @@ -54,16 +50,14 @@ export class DeviceSwitch extends Device { id: number, title: string, type: string, - public getState: string, - public setState: string, - public state: boolean | null, + public stateProperty: Property | null, ) { super(id, title, type); } updateProperty(property: Property): void { - if (this.getState === property.name) { - this.state = property.booleanValue; + if (this.stateProperty?.name === property.name) { + this.stateProperty = property; } } @@ -75,16 +69,14 @@ export class DeviceShutter extends Device { id: number, title: string, type: string, - public getPercent: string, - public setPercent: string, - public percent: number | null, + public positionProperty: Property | null, ) { super(id, title, type); } updateProperty(property: Property): void { - if (this.getPercent === property.name) { - this.percent = property.numberValue; + if (this.positionProperty?.name === property.name) { + this.positionProperty = property; } } diff --git a/src/main/angular/src/app/api/property/property.service.ts b/src/main/angular/src/app/api/property/property.service.ts index 47b3cf9..3656e62 100644 --- a/src/main/angular/src/app/api/property/property.service.ts +++ b/src/main/angular/src/app/api/property/property.service.ts @@ -1,6 +1,6 @@ import {Injectable} from '@angular/core'; import {ApiService, NO_OP} from "../api.service"; -import {validateBooleanAllowNull, validateDateAllowNull, validateNumberAllowNull, validateStringNotEmptyNotNull} from "../validators"; +import {validateDateAllowNull, validateNumberAllowNull, validateStringNotEmptyNotNull} from "../validators"; import {ISearchService} from "../ISearchService"; import {KeyValuePair} from "../KeyValuePair"; import {Update} from "../Update"; @@ -10,10 +10,8 @@ export class Property { constructor( public name: string, public title: string, - public propertyType: string, - public booleanValue: boolean | null, - public numberValue: number | null, - public timestamp: Date | null, + public value: number | null, + public valueTimestamp: Date | null, ) { // nothing } @@ -29,10 +27,8 @@ export class Property { return new Property( validateStringNotEmptyNotNull(json['name']), validateStringNotEmptyNotNull(json['title']), - validateStringNotEmptyNotNull(json['propertyType']), - validateBooleanAllowNull(json['booleanValue']), - validateNumberAllowNull(json['numberValue']), - validateDateAllowNull(json['timestamp']), + validateNumberAllowNull(json['value']), + validateDateAllowNull(json['valueTimestamp']), ); } @@ -69,8 +65,8 @@ export class PropertyService implements ISearchService { this.api.postReturnList("property/searchLike", term, KeyValuePair.fromJson, next, error); } - set(name: string, value: number, next: () => void = NO_OP, error: (error: any) => void = NO_OP): void { - this.api.postReturnNone("property/set", {name: name, value: value}, next, error) + set(property: Property, value: number, next: () => void = NO_OP, error: (error: any) => void = NO_OP): void { + this.api.postReturnNone("property/set", {name: property.name, value: value}, next, error) } } diff --git a/src/main/angular/src/app/pages/device-list/device-list.component.html b/src/main/angular/src/app/pages/device-list/device-list.component.html index ee40bc3..2d89c96 100644 --- a/src/main/angular/src/app/pages/device-list/device-list.component.html +++ b/src/main/angular/src/app/pages/device-list/device-list.component.html @@ -20,19 +20,19 @@
-
+
Auf
-
+
50%
-
+
90%
-
+
Schlitze
-
+
Zu
diff --git a/src/main/angular/src/app/pages/device-list/device-list.component.ts b/src/main/angular/src/app/pages/device-list/device-list.component.ts index c605019..3c01a1b 100644 --- a/src/main/angular/src/app/pages/device-list/device-list.component.ts +++ b/src/main/angular/src/app/pages/device-list/device-list.component.ts @@ -41,18 +41,18 @@ export class DeviceListComponent implements OnInit { setSwitchState(d: Device, value: boolean): void { const device: DeviceSwitch = d as DeviceSwitch; - if (!device.setState) { + if (!device.stateProperty) { throw new Error("Property 'setState' not set for: " + device); } - this.propertyService.set(device.setState, value ? 1 : 0); + this.propertyService.set(device.stateProperty, value ? 1 : 0); } - setShutterPercent(d: Device, value: number): void { + setShutterPosition(d: Device, value: number): void { const device: DeviceShutter = d as DeviceShutter; - if (!device.setPercent) { - throw new Error("Property 'setPercent' not set for: " + device); + if (!device.positionProperty) { + throw new Error("Property 'setPosition' not set for: " + device); } - this.propertyService.set(device.setPercent, value); + this.propertyService.set(device.positionProperty, value); } create(): void { @@ -75,16 +75,16 @@ export class DeviceListComponent implements OnInit { } getSwitchClassList(device: Device): object { - const value: boolean | null | undefined = (device as DeviceSwitch).state; + const value: number | null | undefined = (device as DeviceSwitch).stateProperty?.value; return { - switchOn: value === true, - switchOff: value === false, + switchOn: value === 1, + switchOff: value === 0, switchUnknown: value === null || value === undefined, }; } getShutterClassList(device: Device): object { - const value: number | null | undefined = (device as DeviceShutter).percent; + const value: number | null | undefined = (device as DeviceShutter).positionProperty?.value; return { shutterOpen: value === 0, shutterBetween: value !== null && value !== undefined && value > 0 && value < 100, diff --git a/src/main/angular/src/app/pages/device/device.component.html b/src/main/angular/src/app/pages/device/device.component.html index 9c202c1..da3f1bf 100644 --- a/src/main/angular/src/app/pages/device/device.component.html +++ b/src/main/angular/src/app/pages/device/device.component.html @@ -11,15 +11,9 @@ - Zustand Lesen + Eigenschaft - - - - - Zustand Schreiben - - + @@ -34,15 +28,9 @@ - Position Lesen + Eigenschaft - - - - - Position Schreiben - - + diff --git a/src/main/angular/src/app/pages/schedule/schedule.component.html b/src/main/angular/src/app/pages/schedule/schedule.component.html index 90e7b4f..d3c65eb 100644 --- a/src/main/angular/src/app/pages/schedule/schedule.component.html +++ b/src/main/angular/src/app/pages/schedule/schedule.component.html @@ -18,7 +18,7 @@