# Can Javascript transformation service return "no change value"?

**URL:** <https://community.openhab.org/t/can-javascript-transformation-service-return-no-change-value/38117>\
**Category:** Other\
**Tags:** mqtt, javascript\
**Created:** [January 2, 2018, 12:38pm UTC](https://community.openhab.org/t/can-javascript-transformation-service-return-no-change-value/38117 "2018-01-02T12:38:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![9a4gl](https://community.openhab.org/user_avatar/community.openhab.org/9a4gl/32/72990_2.png) [@9a4gl](https://community.openhab.org/u/9a4gl)\
**Post date:** [January 2, 2018, 12:38pm UTC](https://community.openhab.org/t/can-javascript-transformation-service-return-no-change-value/38117/1 "2018-01-02T12:38:14Z")

</div>

Using following item with mqtt and JS transformation  
String Alarm\_State “Alarm [%s]” (gAlarm) { mqtt=“\<[homemqtt:Paradox/Events:state:JS(alarmState.js)]”}

Sometimes I do receive Paradox/Events mqtt message that do not contain alarm state. Can alarmState.js somehow return a special value meaning “no change” or maybe “previous value” ?

BR,  
Tihomir Heidelberg

---

<div class="post-metadata">

**Author:** ![luckymallari](https://community.openhab.org/user_avatar/community.openhab.org/luckymallari/32/15259_2.png) [@luckymallari](https://community.openhab.org/u/luckymallari)\
**Post date:** [January 2, 2018, 2:28pm UTC](https://community.openhab.org/t/can-javascript-transformation-service-return-no-change-value/38117/2 "2018-01-02T14:28:54Z")

</div>

You can use a proxy item and base your logic from that proxy item.

> [@Design Pattern: Proxy Item](https://community.openhab.org/t/design-pattern-proxy-item/15991):
>
> Edit: Updates for OH 4 Please see [Design Pattern: What is a Design Pattern and How Do I Use Them](https://community.openhab.org/t/design-pattern-what-is-a-design-pattern-and-how-do-i-use-them/40319) for information on what a DP is and how to use them. Problem Statement Often one faces one or more of the following situations: perform additional logic before sending a command to a device (e.g. make sure the device can safely receive the command) send a command to multiple devices based on a single event and Groups, the follow profile, or linking multiple Channels to one Item is not feasible t…

You can also use persistence. On a rule, check if updated value is an accepted value. If not, restore previous state.

---

<div class="post-metadata">

**Author:** ![9a4gl](https://community.openhab.org/user_avatar/community.openhab.org/9a4gl/32/72990_2.png) [@9a4gl](https://community.openhab.org/u/9a4gl)\
**Post date:** [January 2, 2018, 4:53pm UTC](https://community.openhab.org/t/can-javascript-transformation-service-return-no-change-value/38117/3 "2018-01-02T16:53:44Z")

</div>

I got that idea too, but looks a bit overengineering. And it get quite ugly when you have 20 such items. I would expect javascript null does the job here. Another solution is to write bogus javascript that will throw exception in case there is no required value, it does the job, but then log is too ugly ☹
