Semantic features and air humidity

representing the Semantic features of an openHAB Item to Blockly
and
a calculator for humidity

Beginner with bad English skills. Sorry.
Error messages (and solutions?) Are expressly desired.

Blocks

Parents of Item

return equipment and location as a Item

Type of …

return a String

Whether the Item is a …

return a Boolean

Calculator for air humidity

Calculated based on this Function absolute air humidity, dew point and vapor pressure.
Input only in Units % and °C. The Unit for Output Is included.

Changelog

Version 0.3

  • Fine-tuning code

Version 0.2

  • Optical changes

Version 0.1

  • first published version

Ressourcen

-requires JavaScript (ECMAScript 2022+/GraalJS)

uid: Semantic_Humidity
tags: []
props:
  parameters: []
  parameterGroups: []
timestamp: May 31, 2025, 5:20:40 PM
component: BlockLibrary
config:
  name: Semantic & Humidity
slots:
  blocks:
    - component: BlockType
      config:
        args0:
          - name: optSemantic
            options:
              - - Equipment
                - equipment
              - - Location
                - location
            type: field_dropdown
          - align: right
            name: semanticItem
            type: input_value
        colour: 0
        helpUrl: https://openhab.github.io/openhab-js/items.ItemSemantics.html
        message0: semantic %1 parent of item %2
        output: ""
        tooltip: equipment/location of Item. In for_each use get_name_of_item if
          necessary
        type: SemanticItem
      slots:
        code:
          - component: BlockCodeTemplate
            config:
              template: items.getItem({{input:semanticItem}}).semantics.{{field:optSemantic}}
        toolbox:
          - component: PresetInput
            config:
              name: semanticItem
              shadow: true
              type: oh_item
    - component: BlockType
      config:
        args0:
          - name: optSemantic
            options:
              - - Equipment
                - equipmentType
              - - Location
                - locationType
              - - Point
                - pointType
              - - Property
                - propertyType
              - - Semantic
                - semanticType
            type: field_dropdown
          - align: right
            name: semanticItem
            type: input_value
        colour: 165
        helpUrl: https://openhab.github.io/openhab-js/items.ItemSemantics.html
        message0: semantic %1 type of item %2
        output: String
        tooltip: Type of equipment/location/point/property/semantic. Return string
        type: SemanticString
      slots:
        code:
          - component: BlockCodeTemplate
            config:
              template: items.getItem({{input:semanticItem}}).semantics.{{field:optSemantic}}
        toolbox:
          - component: PresetInput
            config:
              name: semanticItem
              shadow: true
              type: oh_item
    - component: BlockType
      config:
        args0:
          - name: optSemantic
            options:
              - - Equipment
                - isEquipment
              - - Location
                - isLocation
              - - Point
                - isPoint
            type: field_dropdown
          - align: right
            name: semanticItem
            type: input_value
        colour: 210
        helpUrl: https://openhab.github.io/openhab-js/items.ItemSemantics.html
        message0: semantic is %1 ? of item %2
        output: Boolean
        tooltip: Is Equipment/Location/Point? Return Boolean
        type: semanticBoolean
      slots:
        code:
          - component: BlockCodeTemplate
            config:
              template: items.getItem({{input:semanticItem}}).semantics.{{field:optSemantic}}
        toolbox:
          - component: PresetInput
            config:
              name: semanticItem
              shadow: true
              type: oh_item
    - component: BlockType
      config:
        args0:
          - name: Ausgabe
            options:
              - - Humidity g/m3
                - af
              - - dew point °C
                - tt
              - - vapor pressure hPa
                - dd
            type: field_dropdown
          - name: relativ
            type: input_value
          - align: right
            name: temp
            type: input_value
        colour: 60
        helpUrl: https://www.smarthome-tricks.de/iobroker-scriptsammlung/taupunkt-berechnen/
        lastDummyAlign0: right
        message0: "%1 from rel. humidity % %2 and temperature °C %3"
        output: Number
        tooltip: calculates values for humidity
        type: Humidity
      slots:
        code:
          - component: BlockCodeTemplate
            config:
              template: "{{utility:taupunkt}}({{input:relativ}},{{input:temp}}).{{field:Ausga\
                be}}"
        toolbox:
          - component: PresetInput
            config:
              fields:
                NUM: 50
              name: relativ
              shadow: true
              type: math_number
          - component: PresetInput
            config:
              fields:
                NUM: 15
              name: temp
              shadow: true
              type: math_number
  utilities:
    - component: UtilityFunction
      config:
        code: >
          function {{name}}(rel ,temp) {
            // Block Humidity
            var r = parseFloat(rel);
            var t = parseFloat(temp);
            var mw = 18.016; var gk = 8314.3;     
            var t0 = 273.15; var tk = t + t0;    
            var a, b;     
            if (t >= 0) {
              a = 7.5; b = 237.3;
            } else if (t < 0) {
              a = 7.6; b = 240.7;
            }    
            var sdd = 6.1078 * Math.pow(10, (a*t)/(b+t)); 
            var dd = sdd * (r/100);
            var af = Math.pow(10,5) * mw/gk * dd/tk;    
            var v =  Math.log(dd/6.1078)/ 2.302585092994046;
            var tt = (b*v) / (a-v);
            return { tt: tt.toFixed(4) + ' °C', af: af.toFixed(4) + ' g/m³', dd: dd.toFixed(4) + ' hPa'};
          }
        name: taupunkt

2 Likes