[SOLVED] Cannot retrieve visibility item for Chart after Frame got visible

Hi! I did rules to display error message in web instead of sensor value if sensor sends error code (in my case: -99). Also rules change visibility of Frame with corresponding Chart. It works fine, BUT I see this in opehab.log:

Cannot retrieve visibility item Bedroom_Hum_Chart_Period for widget org.openhab.model.sitemap.Chart

If simply remove visibility condition from Frame and sensors work fine - Chart is initializing ok and no messages as above in logs, but in configuration I write below everything works fine, but just ERROR messages in openhab.log are annoying.

Also If in web to choose one of 3 Bedroom_Hum_Temp_Chart_Period buttons and press one - error messages no longer appear in logs until openhab service restart.

My Items:

Group All
Group Bedroom (All)
Group Bedroom_Hum_Temp_Chart (Bedroom)
Number Bedroom_Hum "Bedroom Humidity" (Bedroom,Bedroom_Hum_Temp_Chart) {mqtt="<[mainmqtt:/sensor/home/bedroom/humidity:state:default]"}
String Bedroom_Hum_Display "Humidity: [%s]" (Bedroom)
Number Bedroom_Temp "Bedroom Temperature" (Bedroom,Bedroom_Hum_Temp_Chart) {mqtt="<[mainmqtt:/sensor/home/bedroom/temperature:state:default]"}
String Bedroom_Temp_Display "Temperature: [%s]" (Bedroom)
Number Bedroom_Hum_Temp_Chart_Period
Number Bedroom_Hum_Temp_Chart_Visibility

My Sitemap:

Frame label="Bedroom" {
        Text item=Bedroom_Hum_Display valuecolor=[=="Sensor Error"="red",Bedroom_Hum>60="red",Bedroom_Hum>50="orange",Bedroom_Hum>35="green",>30="orange",Bedroom_Hum>0="red"]
        Text item=Bedroom_Temp_Display valuecolor=[=="Sensor Error"="red",Bedroom_Temp>26="red",Bedroom_Temp>24="orange",Bedroom_Temp>18="green",Bedroom_Temp>0="blue"]
    }
Frame visibility=[Bedroom_Hum_Temp_Chart_Visibility==1] {
        Switch item=Bedroom_Hum_Temp_Chart_Period label="Period" mappings=[0="Hour", 1="Day", 2="Week"]
        Chart item=Bedroom_Hum_Temp_Chart period=h refresh=6000 visibility=[Bedroom_Hum_Temp_Chart_Period==0, Bedroom_Hum_Chart_Period=="Uninitialized"]
        Chart item=Bedroom_Hum_Temp_Chart period=D refresh=30000 visibility=[Bedroom_Hum_Temp_Chart_Period==1]
        Chart item=Bedroom_Hum_Temp_Chart period=W refresh=30000 visibility=[Bedroom_Hum_Temp_Chart_Period==2]
    }

My rules:

var String sensorErrorMsg = "Sensor Error"
rule "Bedroom Humidity changed"
when
    Item Bedroom_Hum changed
then
    if (Bedroom_Hum.state == -99) {    
        postUpdate(Bedroom_Hum_Display, sensorErrorMsg)
    }
    else {
        var hum = Bedroom_Hum.state as DecimalType
        postUpdate(Bedroom_Hum_Display, String::format("%.0f %%",hum.floatValue))
    }
    postUpdate(Bedroom_Hum_Temp_Chart_Visibility,
        if (Bedroom_Hum.state != -99 && Bedroom_Temp.state != -99) {
            if (Bedroom_Hum_Temp_Chart_Visibility.state!=1) {1}
        } else {
            if (Bedroom_Hum_Temp_Chart_Visibility.state!=0) {0}
        }
    )
end

rule "Bedroom Temperature changed"
when
    Item Bedroom_Temp changed
then
    if (Bedroom_Temp.state == -99) {
        postUpdate(Bedroom_Temp_Display, sensorErrorMsg)
    }
    else {
        var temp = Bedroom_Temp.state as DecimalType
        postUpdate(Bedroom_Temp_Display, String::format("%.1f ±2 ºC",temp.floatValue))
    }
    postUpdate(Bedroom_Hum_Temp_Chart_Visibility,
        if (Bedroom_Hum.state != -99 && Bedroom_Temp.state != -99) {
            if (Bedroom_Hum_Temp_Chart_Visibility.state!=1) {1}
        } else {
            if (Bedroom_Hum_Temp_Chart_Visibility.state!=0) {0}
        }
    )
end

My rrd4j.persist:

Strategies {
    everyMinute : "0 * * * * ?"
}
Items {
    Bedroom_Hum_Temp_Chart* : strategy = everyMinute, restoreOnStartup
}

You define the Item with the name Bedroom_Hum_Temp_Chart_Visibility but refer to it in your sitemap as Bedroom_Hum_Chart_Period.

Not really, Bedroom_Hum_Temp_Chart_Visibility is visibility option for Frame, but Bedroom_Hum_Chart_Period is for switch time in chart (hour, day, week), I can’t use one switch for both, because Bedroom_Hum_Temp_Chart_Visibility is just 0 or 1, and Bedroom_Hum_Chart_Period is 0,1,2

Sorry, copy and paste error. That should have read:

You define the item with the name Bedroom_Hum_Temp_Chart_Period but used it in your sitemap as Bedroom_Hum_Chart_Period.

To elaborate, the error is saying that it can’t find “Bedroom_Hum_Chart_Period” and in your sitemap for period=h you use this instead of “Bedroom_Hum_Temp_Chart_Period”.

Oh, thanks! Strange that IDE cannot see this mistype…