Skip to content

Semantic Model Location Card - Humidity badge averages non % numbers #4777

Open
@ghostface

Description

@ghostface

I have a Room with items for both relative (in %) and absolute humidity in (g/m³).

The location card generated from the semantic model shows an incorrect humidity value badge by showing the average value of relative humidity+absolute humidity.

Expected Behavior

Absolute humidity is a Number:Density Item with g/m³ as unit so adding it to the relative humidity percentage doesn't make a lot of sense. Just ignoring non percentage units is what I would expect.

Current Behavior

It shows the average of rel humidity % and absolute humidity (g/m³) in %

So the following:

  • temperature of 21.6°C
  • rel. Humidity of 58.48%
  • abs. Humidity of 11.09 g/m³

Will show up as 35% humidity on the location card badge.

Possible Solution

Ignore units which can't be converted to % ?

Steps to Reproduce (for Bugs)

semantic model

        Group   gSemanticRoom      "Room"            <niveau>                    ["Room"]
            Group gSemanticSensorEquipment         "Sensor"  <heating>          (gSemanticRoom)             ["Sensor"]

things

  Type number        : sensorHumidty           "rel. Humidity    [ ga="9.007:<5/0/1" ]
  Type number        : sensorTemperature           "Temperatur"    [ ga="9.001:<5/0/0" ]

items

  Number:Dimensionless  sensor_relHumidity   "rel. Humidity  [%.1f %]"                <humidity>       (gSemanticSensorEquipment,G_Humidity)      ["Measurement","Humidity"]      { channel="knx:device:bridge:generic:sensorHumidity", unit="%" , stateDescription=""[ pattern="%.2f %unit%" ] }
  Number:Density        sensor_absHumidity   "abs. Humidity  [%.1f g/m³]"             <humidity>       (gSemanticSensorEquipment)      ["Measurement","Humidity"]      { unit="g/m³",stateDescription=""[ pattern="%.2f %unit%" ] }
  Number:Temperature    sensor_Temperatur   "Temperatur  [%.1f °C]"                <temperature>      (gSemanticSensorEquipment,G_Temperature)      ["Measurement","Temperature"]      { channel="knx:device:bridge:generic:sensorTemperature", unit="°C", stateDescription=""[ pattern="%.2f %unit%" ]}

rule

import org.openhab.core.model.script.ScriptServiceUtil 

rule "humidityMonitoringAbsoluteConversion"
when
    Member of G_Humidity changed or
    Member of G_Temperature changed
then
    val ir = ScriptServiceUtil.getItemRegistry
    var base_name = triggeringItem.name.split("_").get(0)
    try {
        var rel_humidity = ir.getItem(base_name + "_relHumidity").state as QuantityType// as DecimalType
        var temperature = ir.getItem(base_name + "_Temperature").state as QuantityType// as DecimalType
        var Number c1 = ((17.67*temperature.floatValue)/(temperature.floatValue+243.5))
        val abs_humidity = (Math::pow(Math::E,c1.doubleValue)*6.112*2.1674*rel_humidity.floatValue) /(273.15+temperature.floatValue)
        var abs_humidity_item = ir.getItem(base_name + "_absHumidity")// as DecimalType
        abs_humidity_item.postUpdate(abs_humidity)
    } catch(org.openhab.core.items.ItemLookupException e) {
        //oops not found
    }
end

Context

I do calculate the absolute humidity via a rule from the temperature and relative humidity. But I don't think that's totally relevant.

Your Environment

  • Openhab 4.3.5
  • Archlinux
  • Raspberrypi 4

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn unexpected problem or unintended behavior of the Core

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions