Condition on two Sitepoints causes error

Hello hello!

I’m using OpenHAB 2.4.0 and have trouble to make visibility work with multiple items of the same name in the Basic UI.

My goal is to display a custom icon on a Setpoint item, based on the state of a Switch.

Below is my config:

File default.items:

Number:Temperature Temperature_Should_Office_Helper "Büro Soll [%.1f °C]"
Switch Heating_Office                               "Heizung"        <innogysmarthome> { channel="innogysmarthome:PSS:...:switch" }

File default.sitemap:

sitemap default label="Home"
{
    Switch   item=Heating_Office
    Setpoint item=Temperature_Should_Office_Helper minValue=18 maxValue=24 step=0.5 icon="heizung_an"  visibility=[Heating_Office==ON]
    Setpoint item=Temperature_Should_Office_Helper minValue=18 maxValue=24 step=0.5 icon="heizung_aus" visibility=[Heating_Office==OFF]
}

So, I have two Setpoint’s with the same name Temperature_Should_Office_Helper. One should be shown if the Switch is on, the other should be shown if the Switch is off.

With those conditions in place, I can only click exactly once on the up/down buttons of the Setpoint. When I click a 2nd time, nothing will happen and I see this error in the logs:

==> userdata/logs/openhab.log <==
2019-02-18 12:01:05.850 [WARN ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/Temperature_Should_Office_Helper' with an invalid status value 'NaN °C'.

The value NaN °C is also what I see is being sent from the client to /rest/items/Temperature_Should_Office_Helper, which responds with http 400.

If I remove the conditions, it starts working, with both elements in place:

sitemap default label="Home"
{
    Switch   item=Heating_Office
    Setpoint item=Temperature_Should_Office_Helper minValue=18 maxValue=24 step=0.5 icon="heizung_an"
    Setpoint item=Temperature_Should_Office_Helper minValue=18 maxValue=24 step=0.5 icon="heizung_aus"
}

Of course, now I have two Sitepoints…

09

Does anyone know a solution to this? Or another way to archive the goal of changing the icon?

Thanks,
Daniel

Any rules involving these items?
What may happen it that you click on the setpoint, the switch changes, visibility becomes false (Although) the sitemap doesn’t update…) and when you click again, the sitemap is confused

This may be a problem associated with units of measurement, taking ‘NaN °C’ as a hint.

I’d try a test setup involving just a plain Number Item.

Yes, there is a rule that changes the switch state based on the temperature.

rule "OfficeTemperature"
when
    Item Temperature_Is_Office changed or
    Item Temperature_Should_Office_Helper changed
then
    logInfo("OfficeTemperature", "Triggered")
    val isVal = (Temperature_Is_Office.getStateAs(DecimalType)).floatValue
    val shouldVal = (Temperature_Should_Office_Helper.getStateAs(DecimalType)).floatValue
    if (isVal < shouldVal) {
        Heating_Office.sendCommand(ON)
    }
    else {
        Heating_Office.sendCommand(OFF)
    }
end

Temperature_Is_Office is a temperature sensor, not listed in the items file above bc it isn’t relevant.

The problem also happens if the Switch state isn’t changed, e.g. it is on, I lower the temperature on the Setpoint, it stays on, next click is broken.

==> userdata/logs/events.log <==
2019-02-18 13:09:31.298 [ome.event.ItemCommandEvent] - Item 'Temperature_Should_Office_Helper' received command 23.5 °C
2019-02-18 13:09:31.309 [vent.ItemStateChangedEvent] - Temperature_Should_Office_Helper changed from 24 °C to 23.5 °C
2019-02-18 13:09:31.343 [ome.event.ItemCommandEvent] - Item 'Heating_Office' received command ON
2019-02-18 13:09:31.346 [nt.ItemStatePredictedEvent] - Heating_Office predicted to become ON

==> userdata/logs/openhab.log <==
2019-02-18 13:09:31.334 [INFO ] [thome.model.script.OfficeTemperature] - Triggered

==> userdata/logs/openhab.log <==
2019-02-18 13:09:44.665 [WARN ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/Temperature_Should_Office_Helper' with an invalid status value 'NaN °C'.

All log items except the last are from the first click. In that example the shouldVal is 22, so a change from 24 to 23.5 doesn’t change the state of the Switch.

To be fair, that rule will still be invoked and send commands to Heating_Office. I don’t think that has anything to do with it, but I would modify the rule to only send ON when the target wasn’t already ON etc. Just to reduce churn, not a fix for the setpoint.

Changing the type does not help, only the error message adjusts:

Received HTTP POST request at 'items/Temperature_Should_Office_Helper' with an invalid status value 'NaN'.

I also removed the value format:

Before:

Number:Temperature Temperature_Should_Office_Helper "Büro Soll [%.1f °C]"

After:

Number Temperature_Should_Office_Helper "Büro Soll"

Interestingly, the item is still shown with the formatted value, 22.0 °C.

I have poked around with this kind of thing; without being definitive about it, binding or rule can somehow “suggest” a unit of measurement to a plain old Number Item in an update, and it somehow remains attached. Damned if I know how this works, but I think you’ve eliminated it as relevant here.

EDIT - very odd, I’ve fiddled with combinations of setpoint, icon, visibility, Number, Number:Temperature, BasicUI, ClassicUI and cannot reproduce the error on 2.4.0 release.

Sorry for not replying here so long. Just didn’t have time to work on my HA.

I yesterday tried the milestone 2.5.0.M1, deleted all my config and set up everything from scratch. Unfortunately with the exact same outcome.

As soon as I have a rule like the above OfficeTemperature, that modifies the Heating_Office state,
the UI breaks. Though If both sitepoints are visible: no problem

I upgraded to 2.5.0.M1 because it has support for minValue/maxValue on sliders. So I tried to avoid the problem by simply switching to a slider.

It is not as broken as before but not working either.

Items:

Number:Temperature Temperature_Should_Office_Helper "Büro Soll [%.1f °C]"

Sitemap:

Slider item=Temperature_Should_Office_Helper minValue=18 maxValue=24 step=0.5 icon="heizung_an" visibility=[Heating_Office==ON]
Slider item=Temperature_Should_Office_Helper minValue=18 maxValue=24 step=0.5 icon="heizung_aus" visibility=[Heating_Office==OFF]

Rules:

rule "OfficeTemperature"
when
    Item Temperature_Is_Office changed or
    Item Temperature_Should_Office_Helper changed
then
    logInfo("OfficeTemperature", "Triggered")
    val isVal = (Temperature_Is_Office.getStateAs(DecimalType)).floatValue
    val shouldVal = (Temperature_Should_Office_Helper.getStateAs(DecimalType)).floatValue
    if (isVal < shouldVal) {
        Heating_Office.sendCommand(ON)
    }
    else {
        Heating_Office.sendCommand(OFF)
    }
end

The result is, when the visibility of the slider elements change, the slider is reset to its lowest value. The shown value "Büro Soll [%.1f °C]" has the correct temperature, just the slider mark is on the very left position.

Again, if both sliders are visible (conditions removed) all is working fine, it only happens with the conditions in place.

Is this really supposed to work? I don’t think what I’m trying to do is too fancy… Maybe I’ll just give the HABPanel a try next time. :slight_smile: