# Comparing states in rules DSL in OH3

**URL:** <https://community.openhab.org/t/comparing-states-in-rules-dsl-in-oh3/110668>\
**Category:** Scripts & Rules\
**Tags:** rules-dsl, openhab3\
**Created:** [December 20, 2020, 6:11pm UTC](https://community.openhab.org/t/comparing-states-in-rules-dsl-in-oh3/110668 "2020-12-20T18:11:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanielMalmgren](https://community.openhab.org/user_avatar/community.openhab.org/danielmalmgren/32/6783_2.png) [@DanielMalmgren](https://community.openhab.org/u/DanielMalmgren)\
**Post date:** [December 20, 2020, 6:11pm UTC](https://community.openhab.org/t/comparing-states-in-rules-dsl-in-oh3/110668/1 "2020-12-20T18:11:08Z")

</div>

Hi.  
I’ve found another strange thing that works if written in a .rules file but that doesn’t seem to work when using the rules DSL in the GUI, and that is comparing states of Items. I have two Items that both are Number:Temperature. I’m trying to compare them like this:

```auto
if(item1.state < item2.state)

```

This works fine if it’s in a .rules file (read by OH3). However when I put the exact same line of code into the GUI editor I get the following in the log:

```auto
cannot convert from State to Number

```

I fixed it using this instead:

```auto
(item1.state as QuantityType<Number>).doubleValue < (item2.state as QuantityType<Number>).doubleValue

```

…but it feels like something that shouldn’t be needed for just comparing two states of the same type, or am I wrong?

I’m running RC1.

---

<div class="post-metadata">

**Author:** ![Bruce\_Osborne](https://community.openhab.org/user_avatar/community.openhab.org/bruce_osborne/32/38531_2.png) [@Bruce\_Osborne](https://community.openhab.org/u/Bruce_Osborne)\
**Post date:** [December 20, 2020, 7:00pm UTC](https://community.openhab.org/t/comparing-states-in-rules-dsl-in-oh3/110668/2 "2020-12-20T19:00:18Z")

</div>

You could try RC2 and if there is still an issue. open an Issue on GitHub.  
I think things are pretty frozen now for the 3.0 release.

---

<div class="post-metadata">

**Author:** ![DanielMalmgren](https://community.openhab.org/user_avatar/community.openhab.org/danielmalmgren/32/6783_2.png) [@DanielMalmgren](https://community.openhab.org/u/DanielMalmgren)\
**Post date:** [December 21, 2020, 9:07am UTC](https://community.openhab.org/t/comparing-states-in-rules-dsl-in-oh3/110668/3 "2020-12-21T09:07:39Z")

</div>

> [@Bruce\_Osborne](#):
>
> You could try RC2 and if there is still an issue. open an Issue on GitHub.

I got the same problem in RC2.

[https://github.com/openhab/openhab-core/issues/1975](https://github.com/openhab/openhab-core/issues/1975)

---

<div class="post-metadata">

**Author:** ![DaDen](https://community.openhab.org/user_avatar/community.openhab.org/daden/32/91955_2.png) [@DaDen](https://community.openhab.org/u/DaDen)\
**Post date:** [December 29, 2020, 8:55pm UTC](https://community.openhab.org/t/comparing-states-in-rules-dsl-in-oh3/110668/4 "2020-12-29T20:55:06Z")

</div>

I might have a similar problem here. but i trie to compare two dimmer states. i dont get an error in the logs and i dont think its a conversion problem.

```
if (item1.getState() == item2.getState()

```
