# Access last value of an item in DSL rule

**URL:** <https://community.openhab.org/t/access-last-value-of-an-item-in-dsl-rule/130075>\
**Category:** Scripts & Rules\
**Created:** [December 14, 2021, 7:25pm UTC](https://community.openhab.org/t/access-last-value-of-an-item-in-dsl-rule/130075 "2021-12-14T19:25:53Z")\
**Posts on this page:** 1\
**Showing post:** 9

<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:** [December 14, 2021, 10:45pm UTC](https://community.openhab.org/t/access-last-value-of-an-item-in-dsl-rule/130075/9 "2021-12-14T22:45:51Z")

</div>

> [@apella12](#):
>
> Any idea why?

You didn’t show us the math, so that makes it harder. At a guess, you tried to subtract states. Or perhaps ‘state as Number’ - that will mess up too, because your states are Quantities, with units.

> [@Working with Number:Temperature Items in rules](https://community.openhab.org/t/working-with-number-temperature-items-in-rules/116197):
>
> openHAB provides Quantity Type features, which can seem baffling. On top of that, Temperature type Quantities have a few quirks all of their own. These notes intend to guide the rules author. I’ve shown work examples in DSL rules language, see below for other scripts examples. All have similar features, if different syntax. Knowing what can be done is half the battle. What is a Quantity Type? Simply, Item states and rule variables may contain Quantities - that just means a number AND a unit …

---

_[View the full topic](https://community.openhab.org/t/access-last-value-of-an-item-in-dsl-rule/130075)._
