[SOLVED] MQTT 2.4 + Z-Wave: switches working(kinda), sensors not working

  • Platform information:
    • Hardware: RaspberryPi 3B+, Aeon labs Z-Stick Gen 5
    • OS: openhabian 1.4.1-454
    • Java Runtime Environment: openjdk 1.8.0_152
    • openHAB version: 2.5.0 Build #1533

I have spent whole day yesterday going through various post forums and documentation, but most of the information found related to the old MQTT binding. I did found the post explaining how to migrate the 1.x configs to 2.4 and build my configs accordingly, but was only able to get it partially working.
My goal is to have z-wave items state changes posted to mqtt.
Here is how I’ve set it all up

mqtt.things

    Bridge mqtt:broker:cloudmqttSecure [ host="mXX.cloudmqtt.com", port=XXXXX , secure=true, qos=0, clientID="malinka", retainMessages=true, certificatepin=true, publickeypin=true ,username="xxxxxxx", password="xxxxxxxxxxx" ]
    {
        Thing topic wejscie "MQTT drzwi wejściowe" {
            Channels:
                Type contact : drzwi "Otwarcie drzwi" [stateTopic="wejscie/drzwi", commandTopic="wejscie/drzwi/status", on="OPEN", off="CLOSED", retained="true"]
                Type number  : temperatura "Aktualna temperatura" [stateTopic="wejscie/temperatura", commandTopic="wejscie/temperatura/status", retained="true"]
                Type number  : bateria "Poziom baterii" [stateTopic="wejscie/bateria", commandTopic="wejscie/bateria/status", retained="true"]
        }
        Thing topic sypialnia "MQTT drzwi sypialnia" {
            Channels:
                Type contact : drzwi "Otwarcie drzwi" [stateTopic="sypialnia/drzwi", commandTopic="sypialnia/drzwi/status", on="OPEN", off="CLOSED", retained="true"]
                Type number  : temperatura "Aktualna temperatura" [stateTopic="sypialnia/temperatura",commandTopic="sypialnia/temperatura/status", retained="true"]
                Type number  : bateria "Poziom baterii" [stateTopic="sypialnia/bateria", commandTopic="sypialnia/bateria/status", retained="true"]
        }
        Thing topic wlacznik "MQTT włącznik korytarz" {
            Channels:
                Type switch : schody "oświetlenie schodów" [stateTopic="wlacznik/schody", commandTopic="wlacznik/schody/status", retained="true"]
                Type switch : korytarz "oświetlenie korytarza" [stateTopic="wlacznik/korytarz", commandTopic="wlacznik/korytarz/status", retained="true"]
                Type switch : wszystkie "wszystkie światła" [stateTopic="wlacznik/wszystkie", commandTopic="wlacznik/wszystkie/status", retained="true"]
        }
    }

and here are my home.items

// general wrapper
Group House                 "Dom"                       <house>

// location context
Group Locations             "pomieszczenia"                 (House)
Group Entrance  "drzwi wejściowe"           <groundfloor>   (Locations)
    Contact     SENS_ENTR_OPEN      "czujnik otwarcia drzwi"    (Entrance,DoorStatuses)         {channel="zwave:device:d22b75a6:node3:sensor_door", channel="mqtt:topic:cloudmqttSecure:wejscie:drzwi"}
    Number:Temperature      SENS_ENTR_TEMP      "czujnik temperatury [%.1f °C]"       (Entrance,Temperatures)         {channel="zwave:device:d22b75a6:node3:sensor_temperature", channel="mqtt:topic:cloudmqttSecure:wejscie:temperatura"}
    Number      SENS_ENTR_BATT      "poziom baterii [%d %%]"            (Entrance,BatteryLevels)        {channel="zwave:device:d22b75a6:node3:battery-level", channel="mqtt:topic:cloudmqttSecure:wejscie:bateria"}

Group Bedroom   "sypialnie"                 <door>          (Locations)
    Contact     SENS_BR_OPEN        "czujnik otwarcia drzwi"    (Bedroom,DoorStatuses)          {channel="zwave:device:d22b75a6:node2:sensor_door", channel="mqtt:topic:cloudmqttSecure:sypialnia:drzwi"}
    Number:Temperature      SENS_BR_TEMP        "czujnik temperatury [%.1f °C]"       (Bedroom,Temperatures)          {channel="zwave:device:d22b75a6:node2:sensor_temperature", channel="mqtt:topic:cloudmqttSecure:sypialnia:temperatura"}
    Number      SENS_BR_BATT        "poziom baterii [%d %%]"            (Bedroom,BatteryLevels)         {channel="zwave:device:d22b75a6:node2:battery-level", channel="mqtt:topic:cloudmqttSecure:sypialnia:bateria"}

Group Corridor  "korytarz"                  <corridor>      (Locations)
    Switch      SW_COR_COR          "włącznik korytarz"         (Corridor)                      {channel="zwave:device:d22b75a6:node5:switch_binary1", channel="mqtt:topic:cloudmqttSecure:wlacznik:korytarz"}
    Switch      SW_COR_SC           "włącznik schody"           (Corridor)                      {channel="zwave:device:d22b75a6:node5:switch_binary2", channel="mqtt:topic:cloudmqttSecure:wlacznik:schody"}
    Switch      SW_COR_MAIN         "włącznik (wszystkie)"      (Corridor)                      {channel="zwave:device:d22b75a6:node5:switch_binary", channel="mqtt:topic:cloudmqttSecure:wlacznik:wszystkie"}

// functional context
Group Sensors           "zbiór wszystkich czujników"                    (House)
Group Temperatures      "czujniki temperatur"           <temperature>   (Sensors)
Group BatteryLevels     "poziomy baterii"               <batterylevel>  (Sensors)

my problem with this config is:

  • if I toggle the light switch via openhab, the mqtt updates (which is what I expect it to)
  • if I press the light switch (physically), the mqtt does not update
  • no sensor update is sent to mqtt (door open/close, temperature, battery)
  • if i change the light switch value via mqtt, openhab dashboard changes the light switch state, but the light does not go on.

I did a lot of digging, but since I got it partially working, I must be missing something. Could anyone point me in the right direction here?

bindings version for Z-Wave and MQTT are 2.5.0-snapshot (updated yesterday)

Sounds like is the normal behaviour with respect to command and update.
The default state of affairs is that UI actions generate Item commands, these get passed along by bindings. Device changes result in bindings issuing Item state updates.
So you wouldn’t expect Item state changes to be sent out via MQTT by default.

MQTT2 binding does allow an exception - use of postCommand will cause an incoming message to trigger an OH command.

The old MQTT1 binding allowed for the opposite as well, Item state changes to be tracked by MQTT broadcasts. So far as I know there is not yet a direct MQTT2 equivalent.
You could implement a rule based action, or try this technique

1 Like

aaah awesome!
so I have updated all the mqtt connected items from this

Number      SENS_ENTR_BATT      "poziom baterii [%d %%]"            (Entrance,BatteryLevels)        {channel="zwave:device:d22b75a6:node3:battery-level", channel="mqtt:topic:cloudmqttSecure:wejscie:bateria"}

to this:

Number      SENS_ENTR_BATT      "poziom baterii [%d %%]"            (Entrance,BatteryLevels)        {channel="zwave:device:d22b75a6:node3:battery-level", channel="mqtt:topic:cloudmqttSecure:wejscie:bateria" [profile="follow"] }

and values are nicely reported via MQTT. Also when phisically pressing the light switch.

However, toggling light switch via MQTT does not work (tried with all possible profile values), nor is the switch state updated. I guess I am gonna have to make a profile then?

Does it matter which channel has follow profile set? During my tests (zwave, mqtt, both) it did not seem to matter.

And I think I stumbled upon an error.
If I have a numeric item like:

Number      SENS_BR_BATT

its values do get published on MQTT.
But if I have an item like:

Number:Temperature      SENS_BR_TEMP

nothing gets sent to the broker. As soon as I remove the “Temperature” part, that item’s state changes start being published.

The MQTT 2 binding doesn’t support units of measure at this time. That’s why it doesn’t work with the Temperature.

oh, OK. Good to know. Gonna have to keep tabs on the MQTT binding updates, then.
thank you @rlkoshak
thank you @rossko57

OH community never fails :slight_smile: