Can't receive mqtt data from temp/hum sensors

Hello,

New user here. Actually this is my 3rd time trying OpenHab and so far I had given up given its complexity. This time I believe I got good progress but still far from having a useful system, so I’m trying my luck here, so please be gentle :slight_smile:

I have implemented IoTStack on a RPI4 4G (Linux/6.1.21-v8+ (aarch64)) with slaeh’s cc2652rb_stick Zigbee dongle, and containerized Mosquitto, NodeRed, ZigBee2MQTT, InfluxDB2, Grafana, and OpenHab 4.1.3.

I’ve been surviving in the last years with some physical remotes, Z2MQTT GUI and Google home integration in NodeRed but now I’m trying (again) OpenHab. In other words, the zigbee layer is working fine with mosquitto/NodeRed (and also with InfluxDB2). I have some basic graphs in grafana, so the flows are working.

In OpenHab was able to set a basic model with locations and groups. There is “apartment” as root and then “living room”, “kitchen”, “bedroom”, etc. even though not sure if I classified it correctly (group, location, semantic classes? Seems too many parameters for a newbie).

I installed the MQTT binding and got all of my Zigbee devices in the inbox. I “created thing” from a few of these and associated to some of the different rooms in my apartment. It looks really great.

Now the problem is that I can’t seem to get information from Temp/Hum Sensors. I don’t think it is a wrong binding with MQTT because I can change actuators (switches, lamps) from OpenHab Equipment tab. The problem is only receiving (and displaying) the data. I’ve tried influxdb persistence as well as RRD4J, but no luck. Not a single piece of data shows in these “points”. The channel links show as “offline” but I’m getting the data in my original influxDB as well as I can see the last update some minutes ago in Z2MQTT.
(BTW, When I switch some actuators in OpenHab its status are updated in Z2MQTT, but when I switch the same switch in Z2MQTT, the status isn’t updated in OpenHab).

So I guess I have configured something wrong in the sensors.

UID: mqtt:homeassistant_zigbee2mqtt_5F0xa4c1385fdd2c5eab:4fc98e3aee:zigbee2mqtt_5F0xa4c1385fdd2c5eab
label: T&H Sensor
thingTypeUID: mqtt:homeassistant_zigbee2mqtt_5F0xa4c1385fdd2c5eab
configuration:
  topics:
    - sensor/0xa4c1385fdd2c5eab/battery
    - sensor/0xa4c1385fdd2c5eab/humidity
    - sensor/0xa4c1385fdd2c5eab/linkquality
    - sensor/0xa4c1385fdd2c5eab/temperature
    - sensor/0xa4c1385fdd2c5eab/voltage
  basetopic: homeassistant
bridgeUID: mqtt:broker:4fc98e3aee
channels:
  - id: 0xa4c1385fdd2c5eab_5Fvoltage_5Fzigbee2mqtt#sensor
    channelTypeUID: mqtt:0xa4c1385fdd2c5eab_5Fvoltage_5Fzigbee2mqtt_sensor
    label: MQTT Sensor
    description: null
    configuration:
      component: sensor
      config: '{"availability":[{"topic":"zigbee2mqtt/bridge/state"}],"device":{"identifiers":["zigbee2mqtt_0xa4c1385fdd2c5eab"],"manufacturer":"TuYa","model":"Temperature
        & humidity sensor with display (TS0201)","name":"T&H Sensor JP
        room","via_device":"zigbee2mqtt_bridge_0x00124b0021cc3d98"},"device_class":"voltage","enabled_by_default":false,"entity_category":"diagnostic","json_attributes_topic":"zigbee2mqtt/T&H
        Sensor JP
        room","object_id":"t&h_sensor_jp_room_voltage","origin":{"name":"Zigbee2MQTT","sw":"1.38.0","url":"https://www.zigbee2mqtt.io"},"state_class":"measurement","state_topic":"zigbee2mqtt/T&H
        Sensor JP
        room","unique_id":"0xa4c1385fdd2c5eab_voltage_zigbee2mqtt","unit_of_measurement":"mV","value_template":"{{
        value_json.voltage }}"}'
      nodeid: "0xa4c1385fdd2c5eab"
      objectid: voltage
  - id: 0xa4c1385fdd2c5eab_5Fhumidity_5Fzigbee2mqtt#sensor
    channelTypeUID: mqtt:0xa4c1385fdd2c5eab_5Fhumidity_5Fzigbee2mqtt_sensor
    label: MQTT Sensor
    description: null
    configuration:
      component: sensor
      config: '{"availability":[{"topic":"zigbee2mqtt/bridge/state"}],"device":{"identifiers":["zigbee2mqtt_0xa4c1385fdd2c5eab"],"manufacturer":"TuYa","model":"Temperature
        & humidity sensor with display (TS0201)","name":"T&H Sensor JP
        room","via_device":"zigbee2mqtt_bridge_0x00124b0021cc3d98"},"device_class":"humidity","enabled_by_default":true,"json_attributes_topic":"zigbee2mqtt/T&H
        Sensor JP
        room","object_id":"t&h_sensor_jp_room_humidity","origin":{"name":"Zigbee2MQTT","sw":"1.38.0","url":"https://www.zigbee2mqtt.io"},"state_class":"measurement","state_topic":"zigbee2mqtt/T&H
        Sensor JP
        room","unique_id":"0xa4c1385fdd2c5eab_humidity_zigbee2mqtt","unit_of_measurement":"%","value_template":"{{
        value_json.humidity }}"}'
      nodeid: "0xa4c1385fdd2c5eab"
      objectid: humidity
  - id: 0xa4c1385fdd2c5eab_5Ftemperature_5Fzigbee2mqtt#sensor
    channelTypeUID: mqtt:0xa4c1385fdd2c5eab_5Ftemperature_5Fzigbee2mqtt_sensor
    label: MQTT Sensor
    description: null
    configuration:
      component: sensor
      config: '{"availability":[{"topic":"zigbee2mqtt/bridge/state"}],"device":{"identifiers":["zigbee2mqtt_0xa4c1385fdd2c5eab"],"manufacturer":"TuYa","model":"Temperature
        & humidity sensor with display (TS0201)","name":"T&H Sensor JP
        room","via_device":"zigbee2mqtt_bridge_0x00124b0021cc3d98"},"device_class":"temperature","enabled_by_default":true,"json_attributes_topic":"zigbee2mqtt/T&H
        Sensor JP
        room","object_id":"t&h_sensor_jp_room_temperature","origin":{"name":"Zigbee2MQTT","sw":"1.38.0","url":"https://www.zigbee2mqtt.io"},"state_class":"measurement","state_topic":"zigbee2mqtt/T&H
        Sensor JP
        room","unique_id":"0xa4c1385fdd2c5eab_temperature_zigbee2mqtt","unit_of_measurement":"°C","value_template":"{{
        value_json.temperature }}"}'
      nodeid: "0xa4c1385fdd2c5eab"
      objectid: temperature
  - id: 0xa4c1385fdd2c5eab_5Fbattery_5Fzigbee2mqtt#sensor
    channelTypeUID: mqtt:0xa4c1385fdd2c5eab_5Fbattery_5Fzigbee2mqtt_sensor
    label: MQTT Sensor
    description: null
    configuration:
      component: sensor
      config: '{"availability":[{"topic":"zigbee2mqtt/bridge/state"}],"device":{"identifiers":["zigbee2mqtt_0xa4c1385fdd2c5eab"],"manufacturer":"TuYa","model":"Temperature
        & humidity sensor with display (TS0201)","name":"T&H Sensor JP
        room","via_device":"zigbee2mqtt_bridge_0x00124b0021cc3d98"},"device_class":"battery","enabled_by_default":true,"entity_category":"diagnostic","json_attributes_topic":"zigbee2mqtt/T&H
        Sensor JP
        room","object_id":"t&h_sensor_jp_room_battery","origin":{"name":"Zigbee2MQTT","sw":"1.38.0","url":"https://www.zigbee2mqtt.io"},"state_class":"measurement","state_topic":"zigbee2mqtt/T&H
        Sensor JP
        room","unique_id":"0xa4c1385fdd2c5eab_battery_zigbee2mqtt","unit_of_measurement":"%","value_template":"{{
        value_json.battery }}"}'
      nodeid: "0xa4c1385fdd2c5eab"
      objectid: battery
  - id: 0xa4c1385fdd2c5eab_5Flinkquality_5Fzigbee2mqtt#sensor
    channelTypeUID: mqtt:0xa4c1385fdd2c5eab_5Flinkquality_5Fzigbee2mqtt_sensor
    label: Linkquality
    description: null
    configuration:
      component: sensor
      config: '{"availability":[{"topic":"zigbee2mqtt/bridge/state"}],"device":{"identifiers":["zigbee2mqtt_0xa4c1385fdd2c5eab"],"manufacturer":"TuYa","model":"Temperature
        & humidity sensor with display (TS0201)","name":"T&H Sensor JP
        room","via_device":"zigbee2mqtt_bridge_0x00124b0021cc3d98"},"enabled_by_default":false,"entity_category":"diagnostic","icon":"mdi:signal","json_attributes_topic":"zigbee2mqtt/T&H
        Sensor JP
        room","name":"Linkquality","object_id":"t&h_sensor_jp_room_linkquality","origin":{"name":"Zigbee2MQTT","sw":"1.38.0","url":"https://www.zigbee2mqtt.io"},"state_class":"measurement","state_topic":"zigbee2mqtt/T&H
        Sensor JP
        room","unique_id":"0xa4c1385fdd2c5eab_linkquality_zigbee2mqtt","unit_of_measurement":"lqi","value_template":"{{
        value_json.linkquality }}"}'
      nodeid: "0xa4c1385fdd2c5eab"
      objectid: linkquality

Any idea what am I doing wrong?

Thanks,
Joao

Welcome (back) to openHAB!

I don’t use the HASS autodiscovery. Many of us just add “Generic MQTT Things” and then manually add the channels. I know that @ccutrer has been working on improvements that I think made it into OH 4.2, but I see that you’re on 4.1.3.

I suggest trying to make a generic MQTT thing to see if you can get the values floating in. If that works, then something’s not quite right with the autodiscovery, and we can focus on that. A channel in a generic thing will have zigbee2mqtt/DEVICE/CHANNEL as the stateTopic.

Are you committed to this approach? It’s fine if you are, but most/all of this can be done with the openHABian image. No containers, just a lightweight Raspbian image that automatically installs OH and then allows you to add features from the openhabian-config menu. I don’t use NoteRed, InfluxDB, or Grafana, but I’m reasonably certain they’re all available.

Thanks for replying back.

I’ve been using this setup for about 3+ years and so far it has been fulfilling my needs. This doesn’t mean I won’t ever change, but for a Openhabian based setup, I really need to ensure I could get OpenHab working so it would worth all the migration effort. Also, with containers, I kind of ensure everything fits into the small RPI4 capabilities, since it re-uses resources among containers.

I’m trying to follow the documentation to manually create a MQTT thing but I have to say the documentation is misleading.
The picture shows the “settings” selected and while selected, there is a “transformations” option in settings/configuration that has nothing to do with the “transformations add-on store” that are really meant in the article. I’ve spent 2 hours trying to figure it out and even upgraded my whole stack (including OpenHab to 4.2) in the expectation that the GUI could become similar to the picture shown in the article.

This is already a complex product. If the documentation isn’t clear, it becomes a nightmare for any newbie like me.

Haven’t gone throughout the whole process of manually adding the MQTT thing, but I was kind of expecting Temp&Hum to be working in 4.2 release, and it is not…

It is strange that I can interact with automatically discovered actuators and cannot receive data from sensors discovered in the same way. Could it be some wrong parameter I’m using, probably lost within the semantic parameters?

Thanks,
Joao

I not an expert, but have bounced around a bit between generic mqtt things and HA discovery. I’m currently just using generic. One thing is the HA configs need both JSONPath and JinJava transform (If I recall correctly). Do you have those installed? Also have you linked the HA discovered topics (they are really channels in OH lingo) to items? It is the items that display the sensor data.

On the generic thing I’d advise getting MQTT Explorer (if you don’t have already and copy paste the topics into the right place. After you get one working look at the code tab as you can copy/paste and just change names to add new channels. Again linkage to items is needed.

you’ll get there :smile:

Thanks for replying.

I’ve installed the JSONPath and JinJa add-ons and the Temp&Hum values are now magically appearing!

I wish this was written somewhere in the documentation.

Thanks a million!
Joao

I totally get that you’re frustrated with the documentation. The thing is, this is a 100% volunteer project, and we just don’t have enough people who want to work on it.

If there are improvements that can be made to specific sections, I’d encourage you to submit edits. We welcome them from anybody, and people who are newer often have perspectives that old-timers can no longer see. The edits don’t have to be big–sometimes an extra sentence can go a long way.

Beyond volunteers, the main problem our docs have is that openHAB is not a focused product. It’s highly flexible open-source software that can be:

  1. Installed on pretty much any modern operating system.
  2. Customized to a user’s unique needs and desires.

This makes it extremely difficult to write documentation that’s both general enough to apply to everyone and specific enough to cover the edge cases.

Anyway, I’m glad you got it working. I suggest putting openHABian on a spare SD card and seeing if it can meet your needs. But if everything works and your happy, that’s really all that matters.

Go to the addons docs section:

Type “mqtt” in the search field, go to “Home Assistant MQTT components”, look for the requirements:

and you will find:

The Home Assistant MQTT binding requires two transformations to be installed:

  • JINJA-Transformations
  • JSONPath-Transformations

These can be installed under SettingsAddonTransformations

I think you have your initial problem solved but I wanted to step in with some info not already mentioned and some encouragement.

First of all, there are a few bindings in OH which are low level and require a lot of expertiese in OH to get working. Among these is MQTT. At it’s basic level it’s just messages. What are the messages? :man_shrugging: Could be anything. This flexibility also makes it hard to work with, particularly if one is not already familiar with both MQTT and how OH works with MQTT.

My point in saying this is you’ve pretty much jumpped into the deep end with complexity when it comes to OH. You’ve chosen one of the hardest things to get working so it largely should be easier going forward.

Also, unlike a lot of products, you really can’t get by without monitoring the logs, openhab.log in particular. I suspect there were errors in the logs telling you you needed those missing transformations. Not all errors in openHAB’s logs are quite so meaningful and actionable by end users, but a lot of effort has been made to try to generate meaningful errors.

openHABian comes with a product called Frontail which can let you monitor logs in a browser. If you are not comfortable tailing logs on an ssh console, you should look into setting that up.

Now, for the semantic model I want to say don’t stress it. The semantic model is optional for one thing so you don’t even have to use it at all. Beyond that it’s primary purpose is to automatically build the Locations, Equipment, and Properties tags of the Overview page in MainUI. The only way to really get it wrong is to try to put the same Item in multuple places at the same time (i.e. member of multiple Equipment or member of multiple Locations. Beyond that, if it makes sense to you and you like how those three tabs are rendered, you’ve done it right.

It really only reuses the kernel between containers. Running services in containers comes with lots of great benefits. I use them myself for everything. But the need for fewer resources is not one of them. A container based deployment will definitely require more RAM than running as installed.

Beyond that all I can do is second everythig else said:

  • MQTT Explorer is a must
  • We try our best to make the docs clear but always need more help
  • the best skill you can learn with OH is knowing where to look to find the information you need; the docs are probably more complete than you might guess but finding the right info can be challenging at times
2 Likes