Simple Counter in Sitemap


#1

Hi there,

I‘m trying to realize a GAS-Meter.
I have a working Mqtt-connection between my Arduino and Openhab .
Now i want to count up every time the mqtt publishes a change from Open to closed…
This Number should be visualized on basic ui…
How can i get this?
Thx a lot


#2
rule "Gas meter"
when
    Item gas changed to OFF
then
    val curState = Counter.state as Number
    Counter.postUpdate(curState+1)
end

You’ll have to make the items yourself. “gas” is the gas item, Counter is a number item


#3

Thx.

I coded the rule and created 2 items Gas as contact and Counter as Number.
But i don’t get the integration of the number item in the Sitemap!

I tried

 Frame label="Demo"
    {
       Switch item=DEMOSW
       Text item=MKDoorSensor1
       Number item  = Counter
    }

But it results in Sitemap not working anymore… Shurely I#m too stupid, but please help…


#5

I’m not too good with rules so you might have some errors
Does it update the number? try to see in habpanel