# \#javascript

**URL:** https://community.openhab.org/tag/javascript/540.md

[Latest](https://community.openhab.org/latest.md) · [Categories](https://community.openhab.org/categories.md) · [Tags](https://community.openhab.org/tags.md)

---

## [Transformation Problem JS, Inline Transformation, division by 10](https://community.openhab.org/t/transformation-problem-js-inline-transformation-division-by-10/156801)

<div class="topic-metadata">

**Author:** [@heimchemiker](https://community.openhab.org/u/heimchemiker)\
**Replies:** 11\
**Last updated:** [November 9, 2026, 10:27pm UTC](https://community.openhab.org/t/transformation-problem-js-inline-transformation-division-by-10/156801 "2026-11-09T22:27:40Z")

</div>

Hi everyone, I have a problem with the transformation of an item. I am getting weather data from the (quite) undocumented DWD Weather API that spits out JSON formatted Data. I am trying to extract the predicted minimum …

---

## [Problem with JavaScript rule with SystemStartLevel not loading](https://community.openhab.org/t/problem-with-javascript-rule-with-systemstartlevel-not-loading/169571)

<div class="topic-metadata">

**Author:** [@nelson.aponte](https://community.openhab.org/u/nelson.aponte)\
**Replies:** 14\
**Last updated:** [August 24, 2026, 8:12am UTC](https://community.openhab.org/t/problem-with-javascript-rule-with-systemstartlevel-not-loading/169571 "2026-08-24T08:12:05Z")

</div>

Platform information: Hardware: Raspberry Pi 4 OS: CENTOS 9 Java Runtime Environment: OpenJDK version “21.0.10” 2026-01-20 LTS openHAB version: 5.1.3 Issue of the topic: A text-based rule with the SystemStartlevelTri…

---

## [How is javascript calculating persistence.averageSince](https://community.openhab.org/t/how-is-javascript-calculating-persistence-averagesince/169595)

<div class="topic-metadata">

**Author:** [@mtrax](https://community.openhab.org/u/mtrax)\
**Replies:** 4\
**Last updated:** [June 21, 2026, 2:59am UTC](https://community.openhab.org/t/how-is-javascript-calculating-persistence-averagesince/169595 "2026-06-21T02:59:31Z")

</div>

I running this JavaScript to get the average energy for the last 2 days and I seem to get a different result when I query the persistent table for the same item. how is javascript getting these averages? eg Energy\_Mai…

---

## [Text-based JavaScript rule with item change from any state (optional) to a specific state](https://community.openhab.org/t/text-based-javascript-rule-with-item-change-from-any-state-optional-to-a-specific-state/169569)

<div class="topic-metadata">

**Author:** [@nelson.aponte](https://community.openhab.org/u/nelson.aponte)\
**Replies:** 2\
**Last updated:** [June 16, 2026, 9:20am UTC](https://community.openhab.org/t/text-based-javascript-rule-with-item-change-from-any-state-optional-to-a-specific-state/169569 "2026-06-16T09:20:58Z")

</div>

Platform information: Hardware: Raspberry Pi 4 OS: CENTOS 9 Java Runtime Environment: OpenJDK version “21.0.10” 2026-01-20 LTS openHAB version: 5.1.3 Issue of the topic: I want to create a text-based rule that gets t…

---

## [Javascript in OH5.1.3](https://community.openhab.org/t/javascript-in-oh5-1-3/168644)

<div class="topic-metadata">

**Author:** [@MartOs](https://community.openhab.org/u/MartOs)\
**Replies:** 4\
**Last updated:** [February 26, 2026, 9:25pm UTC](https://community.openhab.org/t/javascript-in-oh5-1-3/168644 "2026-02-26T21:25:39Z")

</div>

Hi, I’m trying to upgrade from 5.0.3 to 5.1.3, but the changes to javascript have broken some of my rules and I don’t understand enough to figure it out. I have been using things like items.metadata.itemchannellink.re…

---

## [Cache.private.get defaultSupplier is always called](https://community.openhab.org/t/cache-private-get-defaultsupplier-is-always-called/168578)

<div class="topic-metadata">

**Author:** [@DavidR](https://community.openhab.org/u/DavidR)\
**Replies:** 7\
**Last updated:** [February 23, 2026, 5:52pm UTC](https://community.openhab.org/t/cache-private-get-defaultsupplier-is-always-called/168578 "2026-02-23T17:52:12Z")

</div>

Using JavaScript scripting. When the call to cache.private.get is given a defaultSupplier, I expected that defaultSupplier would only be called if there was no entry in the cache, but it looks like it is called every ti…

---

## [Issues with DateTimeType Cast](https://community.openhab.org/t/issues-with-datetimetype-cast/162281)

<div class="topic-metadata">

**Author:** [@MatziBrow](https://community.openhab.org/u/MatziBrow)\
**Replies:** 5\
**Last updated:** [February 7, 2026, 3:46pm UTC](https://community.openhab.org/t/issues-with-datetimetype-cast/162281 "2026-02-07T15:46:33Z")

</div>

Platform & System Information: Ubuntu 18.04.6 LTS (GNU/Linux 4.15.0-213-generic x86\_64) Openhab Version: 4.1.1 (Build) OpenJDK Runtime Environment (build 17.0.7+7-Ubuntu-0ubuntu118.04) I have some javascript inte…

---

## [Rule always fires despite Condition Script in Place](https://community.openhab.org/t/rule-always-fires-despite-condition-script-in-place/167990)

<div class="topic-metadata">

**Author:** [@Ltty](https://community.openhab.org/u/Ltty)\
**Replies:** 4\
**Last updated:** [January 13, 2026, 7:22pm UTC](https://community.openhab.org/t/rule-always-fires-despite-condition-script-in-place/167990 "2026-01-13T19:22:52Z")

</div>

Hey all, I am on OpenHab 5.1.1 and have a JavaScript Condition Script for one of my rules in place to ensure that the rule is only triggered between dusk and dawn. I’m using ECMA 262 Edition 11. var dusk = items.getIte…

---

## [MQTT Binding - JS transformation only executed randomly when in wrong format?](https://community.openhab.org/t/mqtt-binding-js-transformation-only-executed-randomly-when-in-wrong-format/167788)

<div class="topic-metadata">

**Author:** [@darkspirit510](https://community.openhab.org/u/darkspirit510)\
**Replies:** 2\
**Last updated:** [January 4, 2026, 7:42pm UTC](https://community.openhab.org/t/mqtt-binding-js-transformation-only-executed-randomly-when-in-wrong-format/167788 "2026-01-04T19:42:47Z")

</div>

Hi all, I have a small issue with MQTT binding and incoming data transformation using JavaScript. Somewhere in the forum (can’t find the post anymore), I read that there are two valid formats for JavaScript. But for som…

---

## [Condition return editor parsing error - return outside of function](https://community.openhab.org/t/condition-return-editor-parsing-error-return-outside-of-function/167710)

<div class="topic-metadata">

**Author:** [@jswim788](https://community.openhab.org/u/jswim788)\
**Replies:** 1\
**Last updated:** [December 29, 2025, 5:24pm UTC](https://community.openhab.org/t/condition-return-editor-parsing-error-return-outside-of-function/167710 "2025-12-29T17:24:31Z")

</div>

OH 5.1 Is it expected that the editor for a JS condition script will complain about a parsing error with a ‘return’ outside of a function? As far as I can tell the syntax for the condition is okay. Is there any issue …

---

## [Need MQTT trigger event help](https://community.openhab.org/t/need-mqtt-trigger-event-help/166815)

<div class="topic-metadata">

**Author:** [@bpmartin20](https://community.openhab.org/u/bpmartin20)\
**Replies:** 11\
**Last updated:** [October 17, 2025, 3:33pm UTC](https://community.openhab.org/t/need-mqtt-trigger-event-help/166815 "2025-10-17T15:33:27Z")

</div>

Platform information: Hardware: Raspberry Pi 4/8G/diskless(NFS root) OS: ubuntu 24.04.3 LTS Java Runtime Environment: openjdk-21-jre-headless openHAB version: 5.0.1 Issue of the topic: Core question: Under OH5, …

---

## [Show JS property "lastStateUpdateTimestamp" in custom Widgets](https://community.openhab.org/t/show-js-property-laststateupdatetimestamp-in-custom-widgets/166777)

<div class="topic-metadata">

**Author:** [@uk59821](https://community.openhab.org/u/uk59821)\
**Replies:** 2\
**Last updated:** [October 12, 2025, 2:23pm UTC](https://community.openhab.org/t/show-js-property-laststateupdatetimestamp-in-custom-widgets/166777 "2025-10-12T14:23:58Z")

</div>

I’m using OH Version: 5.0.1 Since an update to JS scripting (v5.11.1), there are additional item properties such as lastStateUpdateTimestamp or lastStateChangeTimestamp. Until now, I had created several items for this,…

---

## [persistence.getAllStatesBetween() wrong for mapdb](https://community.openhab.org/t/persistence-getallstatesbetween-wrong-for-mapdb/166407)

<div class="topic-metadata">

**Author:** [@DavidR](https://community.openhab.org/u/DavidR)\
**Replies:** 9\
**Last updated:** [September 23, 2025, 1:37pm UTC](https://community.openhab.org/t/persistence-getallstatesbetween-wrong-for-mapdb/166407 "2025-09-23T13:37:02Z")

</div>

From the docs: .getAllStatesBetween(begin, end, serviceId) ⇒ Array\[PersistedItem\] With a serviceId of ‘mapdb’ and a begin time after the last entry, the method should return an empty array, but instead it returns an ar…

---

## [Filter on category in js script](https://community.openhab.org/t/filter-on-category-in-js-script/166006)

<div class="topic-metadata">

**Author:** [@jswim788](https://community.openhab.org/u/jswim788)\
**Replies:** 1\
**Last updated:** [August 30, 2025, 4:38pm UTC](https://community.openhab.org/t/filter-on-category-in-js-script/166006 "2025-08-30T16:38:05Z")

</div>

OH 5.0.1 How do I filter on a specific icon category in a js script similar to filtering on tags? For example, see the filter below to get the lights via the location. Now I would like to find the door sensor in the s…

---

## [Simplfy automation to sync photos](https://community.openhab.org/t/simplfy-automation-to-sync-photos/165401)

<div class="topic-metadata">

**Author:** [@mtrax](https://community.openhab.org/u/mtrax)\
**Replies:** 5\
**Last updated:** [August 12, 2025, 8:56pm UTC](https://community.openhab.org/t/simplfy-automation-to-sync-photos/165401 "2025-08-12T20:56:54Z")

</div>

I have some automation to sync photos from my smart phone to my “Gallery” on my server ( same host as Openhab) Basically it goes like this.. Foldersync ( on Android phone) copies files to folder on Linux server Folder…

---

## [Javascript persistance totals off](https://community.openhab.org/t/javascript-persistance-totals-off/165099)

<div class="topic-metadata">

**Author:** [@mtrax](https://community.openhab.org/u/mtrax)\
**Replies:** 18\
**Last updated:** [August 12, 2025, 2:07pm UTC](https://community.openhab.org/t/javascript-persistance-totals-off/165099 "2025-08-12T14:07:04Z")

</div>

I’ve just upgraded to openHAB version: v5.0 and just getting some odd values when I get the persistence totals. I’m getting some inconsistent output when I query history for this value vs SQL/db look up. ie using JS p…

---

## [Parsing online weather info from VisualCrossing.com](https://community.openhab.org/t/parsing-online-weather-info-from-visualcrossing-com/165215)

<div class="topic-metadata">

**Author:** [@kchest](https://community.openhab.org/u/kchest)\
**Replies:** 10\
**Last updated:** [August 2, 2025, 10:09pm UTC](https://community.openhab.org/t/parsing-online-weather-info-from-visualcrossing-com/165215 "2025-08-02T22:09:59Z")

</div>

My z-wave rain gauge needed new batteries last week. Upon replacing them I noticed that the electronics and battery connections were starting to rust. Although it is working fine with the new batteries, this motivivated …

---

## [JS Failed to execute commandLine](https://community.openhab.org/t/js-failed-to-execute-commandline/164107)

<div class="topic-metadata">

**Author:** [@mtrax](https://community.openhab.org/u/mtrax)\
**Replies:** 7\
**Last updated:** [May 19, 2025, 1:58pm UTC](https://community.openhab.org/t/js-failed-to-execute-commandline/164107 "2025-05-19T13:58:14Z")

</div>

I’m sure this was working but I’m seeing this fail now, has something changed? var calcMbs=125000; console.log("speedtest: start"); var results = actions.Exec.executeCommandLine(time.Duration.ofSeconds(30), "/usr/bin/sp…

---

## [Global function with state and timers](https://community.openhab.org/t/global-function-with-state-and-timers/163330)

<div class="topic-metadata">

**Author:** [@johnuopini](https://community.openhab.org/u/johnuopini)\
**Replies:** 2\
**Last updated:** [April 1, 2025, 7:43am UTC](https://community.openhab.org/t/global-function-with-state-and-timers/163330 "2025-04-01T07:43:17Z")

</div>

Hello! I’m trying to understand how i could snooze phone notifications, specifically for scenarios like “washing machine cycle completed”, something similar to what you find in alarm or calendar apps. What I’d like to…

---

## [Using of Conditions in JavaScript/ECMAScript 262 Edition 11](https://community.openhab.org/t/using-of-conditions-in-javascript-ecmascript-262-edition-11/163272)

<div class="topic-metadata">

**Author:** [@Gaure](https://community.openhab.org/u/Gaure)\
**Replies:** 5\
**Last updated:** [March 25, 2025, 5:22pm UTC](https://community.openhab.org/t/using-of-conditions-in-javascript-ecmascript-262-edition-11/163272 "2025-03-25T17:22:39Z")

</div>

Hi, im searching the documentation and the community for a hint how to specify a condition like a trigger in JavaScript/ECMAScript 262 Edition 11. How would be the syntax to use the numericState of the Item (victron\_ou…

---

## [JavaScript-Error after Update from 4.2.1 to 4.3.3 (call warnings.json from DWD)](https://community.openhab.org/t/javascript-error-after-update-from-4-2-1-to-4-3-3-call-warnings-json-from-dwd/163120)

<div class="topic-metadata">

**Author:** [@eidelsburger](https://community.openhab.org/u/eidelsburger)\
**Replies:** 1\
**Last updated:** [March 17, 2025, 5:48am UTC](https://community.openhab.org/t/javascript-error-after-update-from-4-2-1-to-4-3-3-call-warnings-json-from-dwd/163120 "2025-03-17T05:48:35Z")

</div>

Hi Forum, I have a problem with a Javascript after updating from 4.2.1 to 4.3.3. “JavaScript Scripting (Nashorn)” as Automation is installed. I use this function in a rule to read wanrings.json (not a valid JSON-Result…

---

## [JavaScript - Transformation Services missing in openhab 4](https://community.openhab.org/t/javascript-transformation-services-missing-in-openhab-4/146213)

<div class="topic-metadata">

**Author:** [@helipus](https://community.openhab.org/u/helipus)\
**Replies:** 18\
**Last updated:** [March 12, 2025, 11:16pm UTC](https://community.openhab.org/t/javascript-transformation-services-missing-in-openhab-4/146213 "2025-03-12T23:16:16Z")

</div>

Hi there, I’m missing the JavaScript - Transformation Services in openhab 4. https://www.openhab.org/addons/transformations/javascript/ How can I now make sure that my items which are linked to a float channel only ho…

---

## [How do i compare the item state in javascript?](https://community.openhab.org/t/how-do-i-compare-the-item-state-in-javascript/162704)

<div class="topic-metadata">

**Author:** [@dniklas1](https://community.openhab.org/u/dniklas1)\
**Replies:** 3\
**Last updated:** [February 26, 2025, 2:58pm UTC](https://community.openhab.org/t/how-do-i-compare-the-item-state-in-javascript/162704 "2025-02-26T14:58:41Z")

</div>

Hi, i’m at a loss, it should bei simple… How do i compare the item state in javascript? My code: var itemState = triggeringItem.state; console.info("Fenster-Status = " + itemState); console.info(itemState == "CLOSED…

---

## [JS: Formatting weekday with @js-joda/locale\_de-de](https://community.openhab.org/t/js-formatting-weekday-with-js-joda-locale-de-de/161937)

<div class="topic-metadata">

**Author:** [@sihui](https://community.openhab.org/u/sihui)\
**Replies:** 2\
**Last updated:** [January 24, 2025, 9:00am UTC](https://community.openhab.org/t/js-formatting-weekday-with-js-joda-locale-de-de/161937 "2025-01-24T09:00:03Z")

</div>

According to the docs it should be possible to format a ZonedDateTime with a weekday in several languages: I try to show the weekday, for example Montag, Dienstag, … rules.JSRule({ name: "JS test rule", descripti…

---

## [Persisting Norwegian electricity price](https://community.openhab.org/t/persisting-norwegian-electricity-price/161925)

<div class="topic-metadata">

**Author:** [@himkok](https://community.openhab.org/u/himkok)\
**Replies:** 0\
**Last updated:** [January 22, 2025, 11:48pm UTC](https://community.openhab.org/t/persisting-norwegian-electricity-price/161925 "2025-01-22T23:48:42Z")

</div>

My humble start was a simple rule that fetched the electricity price and updated an item every hour from a very simple to use open API: With the introduction of “Time Series Support for Forecasts and Historical Values”…

---

## [KNX - Calculation of Setpoint Shift for heating](https://community.openhab.org/t/knx-calculation-of-setpoint-shift-for-heating/161876)

<div class="topic-metadata">

**Author:** [@japhias](https://community.openhab.org/u/japhias)\
**Replies:** 1\
**Last updated:** [January 21, 2025, 6:16pm UTC](https://community.openhab.org/t/knx-calculation-of-setpoint-shift-for-heating/161876 "2025-01-21T18:16:26Z")

</div>

Hi all, I would like to share my option to calculate the shift of the setpoint for heating actuator. (German: Sollwertverschiebung) I had set the default setpoints for all rooms to 21°C and wanted to do the individual …

---

## [Multi threaded access requested by thread Thread\[OH-scheduler-14334,5,main\] but is not allowed for language(s) js](https://community.openhab.org/t/multi-threaded-access-requested-by-thread-thread-oh-scheduler-14334-5-main-but-is-not-allowed-for-language-s-js/161630)

<div class="topic-metadata">

**Author:** [@Oekel](https://community.openhab.org/u/Oekel)\
**Replies:** 3\
**Last updated:** [January 13, 2025, 2:32pm UTC](https://community.openhab.org/t/multi-threaded-access-requested-by-thread-thread-oh-scheduler-14334-5-main-but-is-not-allowed-for-language-s-js/161630 "2025-01-13T14:32:34Z")

</div>

I am simply testing some scripts for “fluttering contacts” (want to set an item\_delayed OPEN/CLOSE when a door/window stays at his state for a given time) Its a very simple script to test. The loop should simulate …

---

## [Javascript Transformation "service not found"](https://community.openhab.org/t/javascript-transformation-service-not-found/161388)

<div class="topic-metadata">

**Author:** [@clark](https://community.openhab.org/u/clark)\
**Replies:** 11\
**Last updated:** [January 4, 2025, 3:34pm UTC](https://community.openhab.org/t/javascript-transformation-service-not-found/161388 "2025-01-04T15:34:22Z")

</div>

Platform information: Hardware:i5 OS: Ubuntu 24.04 Java Runtime Environment: 17 openHAB version: 4.3 I am using a transformation to remove the unit from an item before sending it to the thing. I am 99% certain that…

---

## [event.itemState == "ON" always false](https://community.openhab.org/t/event-itemstate-on-always-false/161354)

<div class="topic-metadata">

**Author:** [@Penrose](https://community.openhab.org/u/Penrose)\
**Replies:** 10\
**Last updated:** [January 4, 2025, 4:38am UTC](https://community.openhab.org/t/event-itemstate-on-always-false/161354 "2025-01-04T04:38:03Z")

</div>

I’m not sure what I’m doing wrong here. The if condition testing the implicit variable event.itemState always returns false even when the trigger item changed to ON: 2025-01-02 20:29:28.492 \[INFO \] \[penhab.automation.sc…

---

## [Javascript startup rule doesn't fire](https://community.openhab.org/t/javascript-startup-rule-doesnt-fire/147353)

<div class="topic-metadata">

**Author:** [@mtrax](https://community.openhab.org/u/mtrax)\
**Replies:** 17\
**Last updated:** [January 2, 2025, 4:26pm UTC](https://community.openhab.org/t/javascript-startup-rule-doesnt-fire/147353 "2025-01-02T16:26:53Z")

</div>

openHAB version: 3.4 Javascript : openhab-js version 4.3.0 is there something I’m doing wrong I don’t see any think in my log to indicate the below rules fired after restart. rules.when().system().startLevel(50).then(…

[Next page](https://community.openhab.org/tag/javascript/540.md?match_all_tags=true&page=1&tags%5B%5D=javascript)
