No decimals in temperature

  • Platform information:
    • Hardware: Proxmox server with docker inside LXC
    • OS: Docker image openhab/openhab:5.1.4-debian
    • Java Runtime Environment: openhab/openhab:5.1.4-debian
    • openHAB version: 5.1.4
  • Issue of the topic:

I have added a temperature/humidity sensor using zigbee2mqtt. Channels are ok and I can add an item. When checking “analyze” temperature is recorded with decimals; but when showing the item in page, it don’t show decimals; and trending line is not working (I don’t know if it is related I think it happend because numbers are treated without decimals).

  • Please post configurations (if applicable):

    • Items configuration related to the issue
    version: 1
    things:
      homeassistant:device:9b1ed91559:zigbee2mqtt_5F0x00158d00023210b2:
        bridge: mqtt:broker:9b1ed91559
        label: menjadorTemp
        config:
          topics:
            - sensor/0x00158d00023210b2/battery
            - sensor/0x00158d00023210b2/humidity
            - sensor/0x00158d00023210b2/linkquality
            - sensor/0x00158d00023210b2/pressure
            - sensor/0x00158d00023210b2/temperature
            - sensor/0x00158d00023210b2/voltage
          basetopic: homeassistant
        channels:
          linkquality:
            type: number-advanced
            label: Linkquality
            config:
              component: sensor
              nodeid: 0x00158d00023210b2
              objectid:
                - linkquality
              config:
                - "{\"availability\":[{\"topic\":\"zigbee2mqtt/bridge/state\",\"value_template\":\"{{ value_json.state }}\"},{\"topic\":\"zigbee2mqtt/menjadorTemp/availability\",\"value_template\":\"{{ value_json.state }}\"}],\"availability_mode\":\"all\",\"default_entity_id\":\"sensor.menjadortemp_linkquality\",\"device\":{\"identifiers\":[\"zigbee2mqtt_0x00158d00023210b2\"],\"manufacturer\":\"Aqara\",\"model\":\"Temperature and humidity sensor\",\"model_id\":\"WSDCGQ11LM\",\"name\":\"menjadorTemp\",\"via_device\":\"zigbee2mqtt_bridge_0x00124b0012c38fda\"},\"enabled_by_default\":false,\"entity_category\":\"diagnostic\",\"icon\":\"mdi:signal\",\"name\":\"Linkquality\",\"object_id\":\"menjadortemp_linkquality\",\"origin\":{\"name\":\"Zigbee2MQTT\",\"sw\":\"2.11.0\",\"url\":\"https://www.zigbee2mqtt.io\"},\"state_class\":\"measurement\",\"state_topic\":\"zigbee2mqtt/menjadorTemp\",\"unique_id\":\"0x00158d00023210b2_linkquality_zigbee2mqtt\",\"unit_of_measurement\":\"lqi\",\"value_template\":\"{{ value_json[\\\"linkquality\\\"] }}\"}"
          temperature:
            type: number
            label: MQTT Sensor
            config:
              component: sensor
              nodeid: 0x00158d00023210b2
              objectid:
                - temperature
              config:
                - "{\"availability\":[{\"topic\":\"zigbee2mqtt/bridge/state\",\"value_template\":\"{{ value_json.state }}\"},{\"topic\":\"zigbee2mqtt/menjadorTemp/availability\",\"value_template\":\"{{ value_json.state }}\"}],\"availability_mode\":\"all\",\"default_entity_id\":\"sensor.menjadortemp_temperature\",\"device\":{\"identifiers\":[\"zigbee2mqtt_0x00158d00023210b2\"],\"manufacturer\":\"Aqara\",\"model\":\"Temperature and humidity sensor\",\"model_id\":\"WSDCGQ11LM\",\"name\":\"menjadorTemp\",\"via_device\":\"zigbee2mqtt_bridge_0x00124b0012c38fda\"},\"device_class\":\"temperature\",\"enabled_by_default\":true,\"object_id\":\"menjadortemp_temperature\",\"origin\":{\"name\":\"Zigbee2MQTT\",\"sw\":\"2.11.0\",\"url\":\"https://www.zigbee2mqtt.io\"},\"state_class\":\"measurement\",\"state_topic\":\"zigbee2mqtt/menjadorTemp\",\"unique_id\":\"0x00158d00023210b2_temperature_zigbee2mqtt\",\"unit_of_measurement\":\"°C\",\"value_template\":\"{{ value_json[\\\"temperature\\\"] }}\"}"
          humidity:
            type: number
            label: MQTT Sensor
            config:
              component: sensor
              nodeid: 0x00158d00023210b2
              objectid:
                - humidity
              config:
                - "{\"availability\":[{\"topic\":\"zigbee2mqtt/bridge/state\",\"value_template\":\"{{ value_json.state }}\"},{\"topic\":\"zigbee2mqtt/menjadorTemp/availability\",\"value_template\":\"{{ value_json.state }}\"}],\"availability_mode\":\"all\",\"default_entity_id\":\"sensor.menjadortemp_humidity\",\"device\":{\"identifiers\":[\"zigbee2mqtt_0x00158d00023210b2\"],\"manufacturer\":\"Aqara\",\"model\":\"Temperature and humidity sensor\",\"model_id\":\"WSDCGQ11LM\",\"name\":\"menjadorTemp\",\"via_device\":\"zigbee2mqtt_bridge_0x00124b0012c38fda\"},\"device_class\":\"humidity\",\"enabled_by_default\":true,\"object_id\":\"menjadortemp_humidity\",\"origin\":{\"name\":\"Zigbee2MQTT\",\"sw\":\"2.11.0\",\"url\":\"https://www.zigbee2mqtt.io\"},\"state_class\":\"measurement\",\"state_topic\":\"zigbee2mqtt/menjadorTemp\",\"unique_id\":\"0x00158d00023210b2_humidity_zigbee2mqtt\",\"unit_of_measurement\":\"%\",\"value_template\":\"{{ value_json[\\\"humidity\\\"] }}\"}"
          pressure:
            type: number
            label: MQTT Sensor
            config:
              component: sensor
              nodeid: 0x00158d00023210b2
              objectid:
                - pressure
              config:
                - "{\"availability\":[{\"topic\":\"zigbee2mqtt/bridge/state\",\"value_template\":\"{{ value_json.state }}\"},{\"topic\":\"zigbee2mqtt/menjadorTemp/availability\",\"value_template\":\"{{ value_json.state }}\"}],\"availability_mode\":\"all\",\"default_entity_id\":\"sensor.menjadortemp_pressure\",\"device\":{\"identifiers\":[\"zigbee2mqtt_0x00158d00023210b2\"],\"manufacturer\":\"Aqara\",\"model\":\"Temperature and humidity sensor\",\"model_id\":\"WSDCGQ11LM\",\"name\":\"menjadorTemp\",\"via_device\":\"zigbee2mqtt_bridge_0x00124b0012c38fda\"},\"device_class\":\"atmospheric_pressure\",\"enabled_by_default\":true,\"object_id\":\"menjadortemp_pressure\",\"origin\":{\"name\":\"Zigbee2MQTT\",\"sw\":\"2.11.0\",\"url\":\"https://www.zigbee2mqtt.io\"},\"state_class\":\"measurement\",\"state_topic\":\"zigbee2mqtt/menjadorTemp\",\"unique_id\":\"0x00158d00023210b2_pressure_zigbee2mqtt\",\"unit_of_measurement\":\"hPa\",\"value_template\":\"{{ value_json[\\\"pressure\\\"] }}\"}"
          battery:
            type: number
            label: MQTT Sensor
            config:
              component: sensor
              nodeid: 0x00158d00023210b2
              objectid:
                - battery
              config:
                - "{\"availability\":[{\"topic\":\"zigbee2mqtt/bridge/state\",\"value_template\":\"{{ value_json.state }}\"},{\"topic\":\"zigbee2mqtt/menjadorTemp/availability\",\"value_template\":\"{{ value_json.state }}\"}],\"availability_mode\":\"all\",\"default_entity_id\":\"sensor.menjadortemp_battery\",\"device\":{\"identifiers\":[\"zigbee2mqtt_0x00158d00023210b2\"],\"manufacturer\":\"Aqara\",\"model\":\"Temperature and humidity sensor\",\"model_id\":\"WSDCGQ11LM\",\"name\":\"menjadorTemp\",\"via_device\":\"zigbee2mqtt_bridge_0x00124b0012c38fda\"},\"device_class\":\"battery\",\"enabled_by_default\":true,\"entity_category\":\"diagnostic\",\"object_id\":\"menjadortemp_battery\",\"origin\":{\"name\":\"Zigbee2MQTT\",\"sw\":\"2.11.0\",\"url\":\"https://www.zigbee2mqtt.io\"},\"state_class\":\"measurement\",\"state_topic\":\"zigbee2mqtt/menjadorTemp\",\"unique_id\":\"0x00158d00023210b2_battery_zigbee2mqtt\",\"unit_of_measurement\":\"%\",\"value_template\":\"{{ value_json[\\\"battery\\\"] }}\"}"
          voltage:
            type: number
            label: MQTT Sensor
            config:
              component: sensor
              nodeid: 0x00158d00023210b2
              objectid:
                - voltage
              config:
                - "{\"availability\":[{\"topic\":\"zigbee2mqtt/bridge/state\",\"value_template\":\"{{ value_json.state }}\"},{\"topic\":\"zigbee2mqtt/menjadorTemp/availability\",\"value_template\":\"{{ value_json.state }}\"}],\"availability_mode\":\"all\",\"default_entity_id\":\"sensor.menjadortemp_voltage\",\"device\":{\"identifiers\":[\"zigbee2mqtt_0x00158d00023210b2\"],\"manufacturer\":\"Aqara\",\"model\":\"Temperature and humidity sensor\",\"model_id\":\"WSDCGQ11LM\",\"name\":\"menjadorTemp\",\"via_device\":\"zigbee2mqtt_bridge_0x00124b0012c38fda\"},\"device_class\":\"voltage\",\"enabled_by_default\":true,\"entity_category\":\"diagnostic\",\"object_id\":\"menjadortemp_voltage\",\"origin\":{\"name\":\"Zigbee2MQTT\",\"sw\":\"2.11.0\",\"url\":\"https://www.zigbee2mqtt.io\"},\"state_class\":\"measurement\",\"state_topic\":\"zigbee2mqtt/menjadorTemp\",\"unique_id\":\"0x00158d00023210b2_voltage_zigbee2mqtt\",\"unit_of_measurement\":\"mV\",\"value_template\":\"{{ value_json[\\\"voltage\\\"] }}\"}"
    
    
    version: 1
    items:
      menjadorTemp_temp:
        type: Number
        dimension: Temperature
        label: Temperatura 3
        unit: °C
        groups:
          - menjador
        tags:
          - Point
        channel: homeassistant:device:9b1ed91559:zigbee2mqtt_5F0x00158d00023210b2:temperature
    
    
    • Sitemap configuration related to the issue
    component: oh-label-cell
    config:
      item: menjadorTemp
      title: Temperatura
      trendItem: menjadorTemp
      trendSampling: 180
    
    

imatge

Often a binding will try to be helpful and push a State Description to the Item when it’s linked and often for a temperature it pushes %0.f %UNIT% which means a floating point number shown without decimal point and with the unit.

Even when that doesn’t happen, MainUI will often make it’s own attempts at reasonable defaults based on the Item type and semantic tagging.

But this is always overridable. Assuming you are using the UI to create the Item, you can navigate to the Item’s page and click “add metadata” and select “State Description”. You can fill in the pattern following Items | openHAB.

For exanmple, to show one decimal point, you’d use %.1f %UNIT%

Thanks, it worked (and I learned something new).