[SOLVED] Items, Sitemap and Persistence

Hello,

I’ve got a Z-Wave Node 2: FGSD002 Smoke Detector / FGSD002 Smoke Detector.
The ID in PaperUI is: zwave:device:34fd5856:node2:sensor_temperature
I want to read out the current temperature for my own sitemap.

For this I defined this Item.

Number RM_EG_Flur_Temp    		 "Rauchmelder EG Flur Temperatur [%.1f C]"  <temperature>	(gThermometer)		{ zwave="2:command=sensor_multilevel,sensor_type=1" }

and this frame in my sitemap:

	Frame label="Rachmelder Infos" 
		{
		Text item=RM_EG_Flur_Temp label="Temperatur RM_EG_Flur_Temp [%.1f C]" icon="temperature"	
		}	

But in my Sitemap no temperature is shown.

I’ve also add this to my persist file:

RM_EG_Flur_Temp : strategy = everyMinute, restoreOnStartup

But mySQL does not recognize this. There is no Table for this item.

What is missing in my configuartion? Or what is my mistake?

The control panel in PaperUI shows me the current temerature.

Thanks for hints!

Hi,

your part in curly brackets of the item definition is wrong. This is how it was defined in OH1.

In OH2 it’s like { channel=“your thing id here” }

I don’t know if this also solves your persistence problem. I do not use mysql for persistence. For my temperature (I am using the same smoke sensor) I am using rrd4j and for the rest I am using mapdb.

As @jaydee73 indicates, the Item is incorrect. Therefore the Item has yet to receive a value. Until it receives a value, the MySQL persistence will not create a table for the Item.

Thanks! This was the right solution! Now it works.

I have a similar problem, I have a two variables in my rules called “wnAvg” and “dnAvg” that I’m trying to display that in my sitemap with no luck?

Items:

Number dnAvg            "Dryer Power Avg [%.2f kW]"                                             //(GetPower)  
Number wnAvg            "Washing Machine Power Avg [%.2f kW]"                         //(GetPower) 

Rules:

val Number wnAvg = tplinksmarthome_hs110_B16E5F_power.averageSince(now.minusMinutes(2)) as Number

val Number dnAvg = tplinksmarthome_hs110_B1AFF9_power.averageSince(now.minusMinutes(2)) as Number


StiteMap:

   Text item=wnAvg label="testw [%.1f]"
   Text item=dnAvg label="testd [%.1f]"

I have it logging and it is being working there:

Any help would be appreciated.

Thanks

What your logging does not show is your two new Items being updated.
The rule is incomplete. Perhaps it never runs.

What you didn’t tell us is what you can see in your UI - items with blank values, nothing at all?
The sitemap is incomplete.

In addition to what @rossko57 said,
you have two items and two variables in a rule (hopefully the posted lines are not your complete rule) both named the same, however those variables inside the rule will NOT set the Items state! You would need something like:

wnAvg.postUpdate(tplinksmarthome_hs110_B16E5F_power.averageSince(now.minusMinutes(2)) as Number)

Logging shows both being updated.

SiteMap:

May we see this logging showing your Items being updated? events.log snippet.

However, in the following post you show the sitemap with values for those items. What is your problem?

Items Logging:

Variables logging:

The two are not being posted:

 Text item=wnAvg label="testw [%.1f]"
 Text item=dnAvg label="testd [%.1f]"

What’s being posted is the actual value from the two outlets and not the average from the rules, wnAvg & dnAvg .

Text item=tplinksmarthome_hs110_B1AFF9_power label="Dryer Power [%.2f w]" icon="dryer"
Text item=tplinksmarthome_hs110_B16E5F_power label="WashingMachine Power [%.2f w]" icon="washingmachine"

I think there is confusion about Items and variables.

You can only show Items in your sitemap. You cannot show variables.

You’ve defined two Items, wnAvg and dnAvg

As you have shown us in your events.log extract, your two sitemapped Items wnAvg and dnAvg never get updated.
So there is nothing to see in sitemap.

As @opus already said, your rule fragment that you showed creates two variables called wnAvg and dnAvg. These two new variables are NOT the Items with the same name. You cannot show variables in the sitemap. When the rule ends, these variables disappear anyway, they are only local to this rule.

As @opus said, in your rule you need to send updates to your existing Items using postUpdate.

1 Like

Here is one of the complete rules:


rule "Dryer Consumption State Machine"

when
    Item tplinksmarthome_hs110_B1AFF9_power changed
then
    val Number dnAvg = tplinksmarthome_hs110_B1AFF9_power.averageSince(now.minusMinutes(2)) as Number
    

     if(dnAvg < 1.45) {
        dryer_OpState.postUpdate(0)
    }
    else if(dnAvg > 250) {
        dryer_OpState.postUpdate(2)
        logInfo("dryer ", "Power average  is {}",dnAvg)   
    }
    else if(dnAvg < 200) {
        if ((dryer_OpState.state as Number) == 0)
          
            dryer_OpState.postUpdate(1)
            logInfo("dryer ", "Power average  is {}",dnAvg)  
    }
        else if ((dryer_OpState.state as Number) == 2) {
            dryer_OpState.postUpdate(3)
            sendBroadcastNotification("Dryer finished")
            logInfo("dryer ", "Dryer finished!")
            logInfo("dryer ", "Power average  is {}",dnAvg) 
        }
    
end  

DId you want me to replace this:

val Number dnAvg = tplinksmarthome_hs110_B1AFF9_power.averageSince(now.minusMinutes(2)) as Number

with this?

dnAvg.postUpdate(tplinksmarthome_hs110_B1AFF9_power.averageSince(now.minusMinutes(2)) as Number)

Well, it’s your rule. Better to understand than blindly copy.

Note - that your rule already updates some other Item with postUpdate, it’s the same idea.

In this case, now that you’ve shown the whole rule (always a good idea) we can see that you also use the same value later in the rule. To save messing about tryingto read back the state of an Item that may not have been updated yet, how about

val Number xxx = tplinksmarthome_hs110_B1AFF9_power.averageSince(now.minusMinutes(2)) as Number

    dnAvg.postUpdate(xxx)    // the Item

     if(xxx < 1.45) {
... // and so on

Thanks, seems to be working I added the following:

rule "Dryer Consumption State Machine"

when
    Item tplinksmarthome_hs110_B1AFF9_power changed
then
    val Number dnAvg1 = tplinksmarthome_hs110_B1AFF9_power.averageSince(now.minusMinutes(2)) as Number
    dnAvg.postUpdate(dnAvg1) 

     if(dnAvg1 < 1.45) {
        dryer_OpState.postUpdate(0)
        
    }
    else if(dnAvg1 > 250) {
        dryer_OpState.postUpdate(2)
        logInfo("dryer ", "Power average  is {}",dnAvg)   
    }
    else if(dnAvg1 < 200) {
        if ((dryer_OpState.state as Number) == 0)
          
            dryer_OpState.postUpdate(1)
            logInfo("dryer ", "Power average  is {}",dnAvg)  
    }
        else if ((dryer_OpState.state as Number) == 2) {
            dryer_OpState.postUpdate(3)
            sendBroadcastNotification("Dryer finished")
            logInfo("dryer ", "Dryer finished!")
            logInfo("dryer ", "Power average  is {}",dnAvg) 
        }
    
end  

Updated site map:

Anyway I can round the number to 2 decimal places?
Log:

Does it matter? You are displaying two places, why discard data.

But if you must, multiply by 100, add 0.499, take integer value ,divide by 100…
There’s other methods.