From 6f02350fc840db49ca08b6a5b6e4b454fb7d403a Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Tue, 22 Nov 2022 23:49:04 +0100 Subject: [PATCH 1/7] [MainUI] JS Scripting tern defs: Update `ItemHistory` Reference https://github.com/openhab/openhab-js/pull/158. Reference https://github.com/openhab/openhab-js/pull/175 (to be merged). Signed-off-by: Florian Hotze --- .../web/src/assets/openhab-js-tern-defs.json | 64 ++++++++++++++++--- 1 file changed, 54 insertions(+), 10 deletions(-) diff --git a/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json b/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json index 2be0a9217d..ee296d1585 100644 --- a/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json +++ b/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json @@ -92,37 +92,69 @@ } }, "ItemHistory": { + "averageBetween": { + "!doc": "Gets the average value of the state of a given Item between two certain points in time.", + "!type": "fn(begin: +Date|+ZonedDateTime, end: +Date|+ZonedDateTime, serviceId?: string) -> number|null" + }, "averageSince": { "!doc": "Gets the average value of the state of a given Item since a certain point in time.", - "!type": "fn(timestamp: +Date|+ZonedDateTime, serviceId?: string) -> number" + "!type": "fn(timestamp: +Date|+ZonedDateTime, serviceId?: string) -> number|null" + }, + "changedBetween": { + "!doc": "Checks if the state of a given Item has changed between two certain points in time.", + "!type": "fn(begin: +Date|+ZonedDateTime, end: +Date|+ZonedDateTime, serviceId?: string) -> boolean" }, "changedSince": { "!doc": "Checks if the state of a given Item has changed since a certain point in time.", "!type": "fn(timestamp: +Date|+ZonedDateTime, serviceId?: string) -> boolean" }, + "deltaBetween": { + "!doc": "Gets the difference value of the state of a given Item between two certain points in time.", + "!type": "fn(begin: +Date|+ZonedDateTime, end: +Date|+ZonedDateTime, serviceId?: string) -> number|null" + }, "deltaSince": { "!doc": "Gets the difference value of the state of a given Item since a certain point in time.", - "!type": "fn(timestamp: +Date|+ZonedDateTime, serviceId?: string) -> number" + "!type": "fn(timestamp: +Date|+ZonedDateTime, serviceId?: string) -> number|null" + }, + "deviationBetween": { + "!doc": "Gets the standard deviation of the state of the given Item between two certain points in time.", + "!type": "fn(begin: +Date|+ZonedDateTime, end: +Date|+ZonedDateTime, serviceId?: string) -> number|null" }, "deviationSince": { "!doc": "Gets the standard deviation of the state of the given Item since a certain point in time.", - "!type": "fn(timestamp: +Date|+ZonedDateTime, serviceId?: string) -> number" + "!type": "fn(timestamp: +Date|+ZonedDateTime, serviceId?: string) -> number|null" + }, + "evolutionRateBetween": { + "!doc": "Gets the evolution rate of the state of a given Item between two certain points in time.", + "!type": "fn(begin: +Date|+ZonedDateTime, end: +Date|+ZonedDateTime, serviceId?: string) -> number|null" }, - "evolutionRate": { + "evolutionRateSince": { "!doc": "Gets the evolution rate of the state of a given Item since a certain point in time.", - "!type": "fn(timestamp: +Date|+ZonedDateTime, serviceId?: string) -> number" + "!type": "fn(timestamp: +Date|+ZonedDateTime, serviceId?: string) -> number|null" }, "historicState": { "!doc": "Retrieves the historic Item state for a given Item at a certain point in time.", - "!type": "fn(timestamp: +Date|+ZonedDateTime, serviceId?: string) -> ?" + "!type": "fn(timestamp: +Date|+ZonedDateTime, serviceId?: string) -> string|null" }, "lastUpdate": { "!doc": "Query the last update time of a given item.", - "!type": "fn(serviceId?: string) -> Date?" + "!type": "fn(serviceId?: string) -> ZonedDateTime|null" + }, + "latestState": { + "!doc": "Retrieves the historic Item state for a given Item at the current point in time.", + "!type": "fn(serviceId?: string) -> string|null" + }, + "maximumBetween": { + "!doc": "Gets the maximum value of the historic state of a given Item between two certain points in time.", + "!type": "fn(begin: +Date|+ZonedDateTime, end: +Date|+ZonedDateTime, serviceId?: string) -> number|null" }, "maximumSince": { "!doc": "Gets the historic Item with the maximum value of the state of a given Item since a certain point in time.", - "!type": "fn(timestamp: +Date|+ZonedDateTime, serviceId?: string) -> number" + "!type": "fn(timestamp: +Date|+ZonedDateTime, serviceId?: string) -> number|null" + }, + "minimumBetween": { + "!doc": "Gets the minimum value of the historic state of a given Item between two certain points in time.", + "!type": "fn(begin: +Date|+ZonedDateTime, end: +Date|+ZonedDateTime, serviceId?: string) -> number|null" }, "minimumSince": { "!doc": "Gets the historic Item with the minimum value of the state of a given Item since a certain point in time.", @@ -134,16 +166,28 @@ }, "previousState": { "!doc": "Returns the previous state of a given item.", - "!type": "fn(skipEqual?: boolean, serviceId?: string) -> ?" + "!type": "fn(skipEqual?: boolean, serviceId?: string) -> string|null" + }, + "sumBetween": { + "!doc": "Gets the sum of the states of a given Item between two certain points in time.", + "!type": "fn(begin: +Date|+ZonedDateTime, end: +Date|+ZonedDateTime, serviceId?: string) -> number|null" }, "sumSince": { "!doc": "Gets the sum of the state of a given Item since a certain point in time.", - "!type": "fn(timestamp: +Date|+ZonedDateTime, serviceId?: string) -> number" + "!type": "fn(timestamp: +Date|+ZonedDateTime, serviceId?: string) -> number|null" + }, + "updatedBetween": { + "!doc": "Checks if the state of a given Item has been updated between two certain points in time.", + "!type": "fn(begin: +Date|+ZonedDateTime, end: +Date|+ZonedDateTime, serviceId?: string) -> boolean" }, "updatedSince": { "!doc": "Checks if the state of a given Item has been updated since a certain point in time.", "!type": "fn(timestamp: +Date|+ZonedDateTime, serviceId?: string) -> boolean" }, + "varianceBetween": { + "!doc": "Gets the variance of the state of the given Item between two certain points in time.", + "!type": "fn(begin: +Date|+ZonedDateTime, end: +Date|+ZonedDateTime, serviceId?: string) -> number|null" + }, "varianceSince": { "!doc": "Gets the variance of the state of the given Item since a certain point in time.", "!type": "fn(timestamp: +Date|+ZonedDateTime, serviceId?: string) -> number" From 070a226b96ca7d1b4e498d8079d662fc3397ec1a Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Thu, 24 Nov 2022 22:42:24 +0100 Subject: [PATCH 2/7] [MainUI] JS Scripting tern defs: Update `ScriptExecution` Reference https://github.com/openhab/openhab-js/pull/160. Reference https://github.com/openhab/openhab-js/pull/171. Reference https://github.com/openhab/openhab-js#createtimer. Signed-off-by: Florian Hotze --- .../web/src/assets/openhab-js-tern-defs.json | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json b/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json index ee296d1585..8406d80a50 100644 --- a/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json +++ b/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json @@ -337,6 +337,32 @@ "!type": "fn(key: string) -> ?" } }, + "Timer": { + "cancel": { + "!doc": "Cancels the timer.", + "!type": "fn() -> boolean" + }, + "getExecutionTime": { + "!doc": "The scheduled execution time or null if timer was cancelled.", + "!type": "fn() -> time.ZonedDateTime|null" + }, + "isActive": { + "!doc": "Whether the scheduled execution is yet to happen.", + "!type": "fn() -> boolean" + }, + "isCancelled": { + "!doc": "Whether the timer has been cancelled.", + "!type": "fn() -> boolean" + }, + "hasTerminated": { + "!doc": "Whether the scheduled execution has already terminated.", + "!type": "fn() -> boolean" + }, + "reschedule": { + "!doc": "Reschedules a timer to a new starting time. This can also be called after a timer has terminated, which will result in another execution of the same code.", + "!type": "fn(time.ZonedDateTime) -> boolean" + } + }, "TimeNamespace": { "toZDT": { "!doc": "Converts nearly any representation of a time to a time.ZonedDateTime (see JS Scripting Docs/Standard Library/Time)", @@ -510,8 +536,10 @@ }, "ScriptExecutionActions": { "callScript": { "!type": "fn(scriptName: string)" }, - "createTimer": { "!type": "fn(instant, function: fn()) -> ?" }, - "createTimerWithArgument": { "!type": "fn(instant, arg, function: fn()) -> ?" } + "createTimer": { + "!doc": "Schedules a function for later execution.", + "!type": "fn(identifier?: string, zonedDateTime: time.ZonedDateTime, function: fn()) -> Timer" + } }, "SemanticsActions": { "getEquipment": { "!type": "fn(rawItem: ?) -> ?" }, From 6e5aabc469dc5d2545a5286656f702d63ffb850d Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Thu, 24 Nov 2022 22:47:44 +0100 Subject: [PATCH 3/7] [MainUI] JS Scripting tern defs: Add `thingActions` Reference https://github.com/openhab/openhab-js/pull/165. Signed-off-by: Florian Hotze --- .../org.openhab.ui/web/src/assets/openhab-js-tern-defs.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json b/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json index 8406d80a50..af0e46336d 100644 --- a/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json +++ b/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json @@ -609,6 +609,10 @@ "Voice": { "!doc": "Voice Actions. The static methods of this class are made available as functions in the scripts. This allows a script to use voice features.", "!type": "VoiceActions" + }, + "thingActions": { + "!doc": "Get the ThingActions of a given Thing.", + "!type": "fn(bindingId: string, thingUid: string) -> ?" } } }, From 26df513c36fbf16c57de954bd8c806efa11f9f12 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Thu, 24 Nov 2022 22:55:28 +0100 Subject: [PATCH 4/7] [MainUI] JS Scripting tern defs: Add Item sementics Reference https://github.com/openhab/openhab-js/pull/167. Signed-off-by: Florian Hotze --- .../web/src/assets/openhab-js-tern-defs.json | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json b/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json index af0e46336d..ab83c4421c 100644 --- a/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json +++ b/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json @@ -22,6 +22,10 @@ "!doc": "Access historical states for this item", "!type": "ItemHistory" }, + "semantics": { + "!doc:": "Access the sementic features for this Item", + "!type": "ItemSemantics" + }, "rawState": { "!doc": "The raw state of the item, as a java object.", "!type": "?" @@ -197,6 +201,28 @@ "!type": "fn(serviceId?: string) -> ?" } }, + "ItemSemantics": { + "equipmentType": { + "!doc": "The type of the semantic equipment.", + "!type": "string|null" + }, + "locationType": { + "!doc": "The type of the semantic location.", + "!type": "string|null" + }, + "pointType": { + "!doc": "The type of the semantic point.", + "!type": "string|null" + }, + "propertyType": { + "!doc": "The type of the semantic property.", + "!type": "string|null" + }, + "semanticType": { + "!doc": "Determines the semantic type (i.e. a sub-type of Location, Equipment or Point).", + "!type": "string|null" + } + }, "ItemConfig": { "type": { "!doc": "Type of the Item.", From 33166176168b0fcaaafa297046f1346db99f6ca4 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Sat, 3 Dec 2022 21:36:37 +0100 Subject: [PATCH 5/7] [MainUI] JS Scripting tern defs: Remove `BusEvent` & `State` ... as they are not used/referenced from the rest of the tern defs and not used in JS Scripting as well. Signed-off-by: Florian Hotze --- .../web/src/assets/openhab-js-tern-defs.json | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json b/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json index ab83c4421c..7832879605 100644 --- a/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json +++ b/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json @@ -450,34 +450,6 @@ "!type": "fn(message: string, args?: ?)" } }, - "BusEvent": { - "getSource": { - "!doc": "The source of the event", - "!type": "fn() -> string" - }, - "getType": { - "!doc": "The type of the event", - "!type": "fn() -> string" - }, - "getTopic": { - "!doc": "The topic of the event", - "!type": "fn() -> string" - }, - "getPayload": { - "!doc": "The payload of the event", - "!type": "fn() -> string" - }, - "toString": { - "!doc": "Returns a string representation of the event", - "!type": "fn() -> string" - } - }, - "State": { - "toString": { - "!doc": "Returns a string representation of the state", - "!type": "fn() -> string" - } - }, "EventData": { "itemName": { "!doc": "The name of the Item that triggered the event (core.ItemStateUpdateTrigger, core.ItemStateChangeTrigger, core.ItemCommandTrigger). Attention: Java type!", From 89af0dfbc3160837cd7a4a5521a130cbb05a922d Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Sat, 3 Dec 2022 23:23:28 +0100 Subject: [PATCH 6/7] [MainUI] JS Scripting tern defs: Fixes Signed-off-by: Florian Hotze --- .../org.openhab.ui/web/src/assets/openhab-js-tern-defs.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json b/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json index 7832879605..d683f32743 100644 --- a/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json +++ b/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json @@ -23,7 +23,7 @@ "!type": "ItemHistory" }, "semantics": { - "!doc:": "Access the sementic features for this Item", + "!doc": "Access the semantic features for this Item", "!type": "ItemSemantics" }, "rawState": { @@ -386,7 +386,7 @@ }, "reschedule": { "!doc": "Reschedules a timer to a new starting time. This can also be called after a timer has terminated, which will result in another execution of the same code.", - "!type": "fn(time.ZonedDateTime) -> boolean" + "!type": "fn(zonedDateTime: time.ZonedDateTime) -> boolean" } }, "TimeNamespace": { From f7d23d7c25168d0f9ba32ba42b742f2cea690dde Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Sat, 3 Dec 2022 23:31:13 +0100 Subject: [PATCH 7/7] [MainUI] JS Scripting tern defs: Add Transformation actions Signed-off-by: Florian Hotze --- .../web/src/assets/openhab-js-tern-defs.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json b/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json index d683f32743..4df6f2b9aa 100644 --- a/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json +++ b/bundles/org.openhab.ui/web/src/assets/openhab-js-tern-defs.json @@ -554,6 +554,16 @@ "getActions": { "!type": "fn(scope: string, thingUid: string) -> ?" }, "getThingStatusInfo": { "!type": "fn(thingUid: string) -> ?" } }, + "TransformationActions": { + "transform": { + "!doc": "Applies a transformation of a given type with some function to a value. Returns the original value if the transformation fails.", + "!type": "fn(type: string, fn: string, value: string) -> string" + }, + "transformRaw": { + "!doc": "Applies a transformation of a given type with some function to a value. Throws an error if the transformation fails.", + "!type": "fn(type: string, fn: string, value: string) -> string" + } + }, "VoiceActions": { "interpret": { "!type": "fn(text: string, interpreter?: string, sink?: string) -> ?" }, "say": { "!type": "fn(text: string, interpreter?: string, sink?: string, volume?: ?)" } @@ -604,6 +614,10 @@ "!doc": "Things Actions. This class provides static methods that can be used in automation rules for getting thing's status info.", "!type": "ThingsActions" }, + "Transformation": { + "!doc": "Transformation Actions. The static methods of this class allow rules to execute transformations using one of the various data transformation services.", + "!type": "TransformationActions" + }, "Voice": { "!doc": "Voice Actions. The static methods of this class are made available as functions in the scripts. This allows a script to use voice features.", "!type": "VoiceActions"