# Ignore read of temperature if

**URL:** <https://community.openhab.org/t/ignore-read-of-temperature-if/123934>\
**Category:** Scripts & Rules\
**Created:** [June 25, 2021, 10:59am UTC](https://community.openhab.org/t/ignore-read-of-temperature-if/123934 "2021-06-25T10:59:42Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![rossko57](https://community.openhab.org/user_avatar/community.openhab.org/rossko57/32/70263_2.png) [@rossko57](https://community.openhab.org/u/rossko57)\
**Post date:** [June 26, 2021, 9:15pm UTC](https://community.openhab.org/t/ignore-read-of-temperature-if/123934/15 "2021-06-26T21:15:05Z")

</div>

We can test your script and logic in a rule

```auto
val rawjson = '{"message":{"id":0,"temperature":-67.77,"humidity":0.00,"battery":1,"channel":1},"protocol":"tfa","length":"0","value":"0","repeats":2,"status":2}'
val intermediate = transform("JSONPATH", "$.message.temperature", rawjson)
logInfo("test", "from JSON " + intermediate)
val chained = transform("JS", "temp.js", intermediate)
logInfo("test", "from JS " + chained)

```

and get expected results

```auto
2021-06-26 21:53:25.840 [INFO] [.eclipse.smarthome.model.script.test] - from JSON -67.77
2021-06-26 21:53:25.871 [INFO] [.eclipse.smarthome.model.script.test] - from JS UNDEF

```

The only other thing that has to happen is the MQTT binding to pass UNDEF through the number type channel. Maybe it doesn’t,but it used to.

> [@goofas](#):
>
> so i see the id is different too

Makes more sense than random values, a report from some different device with a missing sensor.

You can select messages by ID, but use a different technique. Forget the JS altogether, use a REGEX transformation to select messages with the wanted ID (and discard messages without), then chain on your JSONPATH to select the data value you want.

> [@MQTT 2.5 M1+ How to implement the equivalent to MQTT1 REGEX filters](https://community.openhab.org/t/mqtt-2-5-m1-how-to-implement-the-equivalent-to-mqtt1-regex-filters/68350):
>
> Problem In the MQTT1 binding there was a feature that let us filter messages published to a given topic and only pass those that match a given REGEX to the transformation and/or on to the Item. This was useful to handle devices that publish messages to a single well known topic for all their devices. For example, the official firmware from the vendor of Shelly devices have a request/response protocol over MQTT to get meta data about the devices (IP address, MAC address, firmware version, whethe…

---

_[View the full topic](https://community.openhab.org/t/ignore-read-of-temperature-if/123934)._
