MqttPairItem not working?

Hi,

In my HAPApp rule I am adding an item that is an (mqtt) rollershutter with different topics to get & set the value. I thought this was an ideal candidate for HABApp’s “MqttPairItem”, however: when I try that, I get the following error:

AssertionError: <class 'HABApp.mqtt.items.mqtt_pair_item.MqttPairItem'> != <class 'HABApp.mqtt.items.mqtt_item.MqttItem'>

below is a screenshot with my code. The first 2 instances (=line 32 and 33) of MqttPairItem.get_create_item are just dummies I copy pasted from the online documentation. These do work. However, mine (line 34), which also is just a ctor with 2 strings fails:

Not sure what I am doing wrong?

Thanks & BR, Johan

I’m guessing that the topic that fails is sent with the retain flag?
Topics with a retain flat will automatically create a corresponding MqttItem in the HABApp item registry.
Since the item does already exists but is not an MqttPairItem you get the error you are observing.

There are multiple ways to tackle this:

  • Configure zwave2mqtt to send the topics without the retain flag
  • Remove the retained topics before starting HABApp
  • Edit the subscribe config so you don’t subscribe to the topic during startup and then dynamically subscribe in the rules

I think the first option is the most sensible one and it’s how I am doing it.

Thanks @Spaceman_Spiff - indeed this item is created with Zwave2mqtt, and it uses default options, so that’s probably what is going on. I’m not sure if I want to ditch the retain flag… I’ll play with it one day.

After posting this, I went forward with 2 separate topics: a _get and a _set topic. It’s a bit less elegant, but it works.

Thanks again & BR, Johan.