How to create a calculated item in sitemap

I want to display on the UI the change in a temperature reading since 24 hours.
I know I can get this value with:

Thermometer1.deltaSince(now.minusHours(24)) )

How do I create an Item that will display this on the UI?

Hi,

First of all you need to create a virtual item (i.e. an item that is not associated with any physical device through a binding), e.g.

*.items
Number Thermometer1_DeltaLastDay

Then you need to create a rule that can update your virtual item (since it will not be updated automatically by any binding):

*.rules
rule "Thermometer1 - Update delta for last 24 hours"
when
Item Thermometer1 received update
then
Thermometer1_DeltaLastDay.postUpdate(Thermometer1.deltaSince(now.minusHours(24)))
end

Finally you need to display your new virtual item on the sitemap:

*.sitemap
Text item=Thermometer1_DeltaLastDay label="Delta for last 24 hours [%.1f °C]"

Note! I have not tested the above so it may need some tweaking, but as a general approach it should work.

3 Likes

Works perfect!

Thanks