Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions src/items/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ const MetadataKey = Java.type('org.openhab.core.items.MetadataKey');
* @hideconstructor
*/
class ItemMetadata {
/**
* The metadata value.
* @type {string}
*/
value;
/**
* The metadata configuration.
* @type {object}
*/
configuration;

/**
* Create an ItemMetadata instance, wrapping native openHAB Item metadata.
* @param {*} rawMetadata {@link https://www.openhab.org/javadoc/latest/org/openhab/core/items/metadata org.openhab.core.items.Metadata}
Expand All @@ -38,26 +49,21 @@ class ItemMetadata {
* @type {*}
*/
this.rawMetadata = rawMetadata;
}

/**
* The Metadata value.
* @type {string}
*/
get value () {
return this.rawMetadata.getValue();
this.value = this.rawMetadata.getValue();
this.configuration = utils.javaMapToJsObj(this.rawMetadata.getConfiguration());
}

/**
* The metadata configuration.
* @type {object}
* The metadata key.
* @return {string}
*/
get configuration () {
return utils.javaMapToJsObj(this.rawMetadata.getConfiguration());
get key () {
return this.rawMetadata.getUID().toString();
}

toString () {
return this.rawMetadata.toString();
return `Metadata [key=${this.key}, value=${this.value}, configuration=${JSON.stringify(this.configuration)}]`;
}
}

Expand Down
52 changes: 40 additions & 12 deletions types/items/itemchannellink.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,57 @@ export type Item = {
readonly isInitialized: boolean;
readonly isUninitialized: boolean;
getMetadata(namespace?: string): {
value: string;
/**
* Class representing an openHAB Item -> channel link.
*
* @memberof items.itemChannelLink
* @hideconstructor
*/
configuration: any;
rawMetadata: any;
readonly value: string;
readonly configuration: any;
toString(): any;
readonly key: string;
toString(): string;
} | {
namespace: {
value: string;
/**
* Class representing an openHAB Item -> channel link.
*
* @memberof items.itemChannelLink
* @hideconstructor
*/
configuration: any;
rawMetadata: any;
readonly value: string;
readonly configuration: any;
toString(): any;
readonly key: string;
toString(): string;
};
};
replaceMetadata(namespace: string, value: string, configuration?: any): {
value: string;
/**
* Class representing an openHAB Item -> channel link.
*
* @memberof items.itemChannelLink
* @hideconstructor
*/
configuration: any;
rawMetadata: any;
readonly value: string;
readonly configuration: any;
toString(): any;
readonly key: string;
toString(): string;
};
removeMetadata(namespace?: string): {
value: string;
/**
* Class representing an openHAB Item -> channel link.
*
* @memberof items.itemChannelLink
* @hideconstructor
*/
configuration: any;
rawMetadata: any;
readonly value: string;
readonly configuration: any;
toString(): any;
readonly key: string;
toString(): string;
};
sendCommand(value: any, expire?: JSJoda.Duration, onExpire?: any): void;
sendCommandIfDifferent(value: any): boolean;
Expand Down
2 changes: 1 addition & 1 deletion types/items/itemchannellink.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions types/items/items.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ export type ItemConfig = {
autoupdate?: boolean;
};
export type ItemMetadata = {
value: string;
configuration: any;
rawMetadata: any;
readonly value: string;
readonly configuration: any;
toString(): any;
readonly key: string;
toString(): string;
};
export type ZonedDateTime = import('@js-joda/core').ZonedDateTime;
export type Instant = import('@js-joda/core').Instant;
Expand Down
2 changes: 1 addition & 1 deletion types/items/items.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 14 additions & 9 deletions types/items/metadata.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,26 @@ export class ItemMetadata {
*/
constructor(rawMetadata: any);
/**
* raw Java {@link https://www.openhab.org/javadoc/latest/org/openhab/core/items/metadata org.openhab.core.items.Metadata}
* @type {*}
*/
rawMetadata: any;
/**
* The Metadata value.
* The metadata value.
* @type {string}
*/
get value(): string;
value: string;
/**
* The metadata configuration.
* @type {object}
*/
get configuration(): any;
toString(): any;
configuration: object;
/**
* raw Java {@link https://www.openhab.org/javadoc/latest/org/openhab/core/items/metadata org.openhab.core.items.Metadata}
* @type {*}
*/
rawMetadata: any;
/**
* The metadata key.
* @return {string}
*/
get key(): string;
toString(): string;
}
export declare namespace itemChannelLink {
function get(): typeof import("./itemchannellink");
Expand Down
2 changes: 1 addition & 1 deletion types/items/metadata.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 16 additions & 12 deletions types/quantity.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,33 @@ export type Item = {
readonly isInitialized: boolean;
readonly isUninitialized: boolean;
getMetadata(namespace?: string): {
value: string;
configuration: any;
rawMetadata: any;
readonly value: string;
readonly configuration: any;
toString(): any;
readonly key: string;
toString(): string;
} | {
namespace: {
value: string;
configuration: any;
rawMetadata: any;
readonly value: string;
readonly configuration: any;
toString(): any;
readonly key: string;
toString(): string;
};
};
replaceMetadata(namespace: string, value: string, configuration?: any): {
value: string;
configuration: any;
rawMetadata: any;
readonly value: string;
readonly configuration: any;
toString(): any;
readonly key: string;
toString(): string;
};
removeMetadata(namespace?: string): {
value: string;
configuration: any;
rawMetadata: any;
readonly value: string;
readonly configuration: any;
toString(): any;
readonly key: string;
toString(): string;
};
sendCommand(value: any, expire?: JSJoda.Duration, onExpire?: any): void;
sendCommandIfDifferent(value: any): boolean;
Expand Down
2 changes: 1 addition & 1 deletion types/quantity.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 16 additions & 12 deletions types/rules/operation-builder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,34 @@ export type Item = {
readonly isInitialized: boolean;
readonly isUninitialized: boolean;
getMetadata(namespace?: string): {
value: string;
configuration: any;
rawMetadata: any;
readonly value: string;
readonly configuration: any;
toString(): any;
readonly key: string;
toString(): string;
} | {
namespace: {
value: string;
configuration: any;
rawMetadata: any;
readonly value: string;
readonly configuration: any;
toString(): any;
readonly key: string;
toString(): string;
};
};
/** @private */
replaceMetadata(namespace: string, value: string, configuration?: any): {
value: string;
configuration: any;
rawMetadata: any;
readonly value: string;
readonly configuration: any;
toString(): any;
readonly key: string;
toString(): string;
};
removeMetadata(namespace?: string): {
value: string;
configuration: any;
rawMetadata: any;
readonly value: string;
readonly configuration: any;
toString(): any;
readonly key: string;
toString(): string;
};
sendCommand(value: any, expire?: time.Duration, onExpire?: any): void;
sendCommandIfDifferent(value: any): boolean;
Expand Down
Loading