MQTT topic autodiscovered type - can it be changed?

Dear all

with reference to my previous post (almost solved :wink: )

I cannot still do a straightforward configuration of my door/window sensors. The following warning is visible in the log

2021-01-24 20:53:58.606 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command 'CLOSED' not supported by type 'OnOffValue': No enum constant org.openhab.core.library.types.OnOffType.CLOSED

And when I look to the channel list of my (autodiscovered sensor hub) I see all opening are classified as “switch” instead of “contact”

However, mosquitto seems to report the right values for a contact type

openhabian@openhabHost:~ $ mosquitto_sub  -v  -t homie/+/+/status
homie/esp_gateway/mainDoorSensor/status CLOSED
homie/esp_gateway/guestRoomWindowSensor/status CLOSED
homie/esp_gateway/livingRoomDoorSensor/status CLOSED
homie/esp_gateway/livingRoomWindowSensor/status CLOSED
homie/esp_gateway/kitchenWindowSensor/status CLOSED
homie/esp_gateway/bedroomWindowSensor/status CLOSED
homie/esp_gateway/kidsBedroomWindowSensor/status CLOSED
homie/esp_gateway/kidsBedroomTH/status CLOSED
homie/esp_gateway/livingRoomTH/status CLOSED
homie/esp_gateway/bedRoomTH/status CLOSED

If you read my previous post, I had to change topic value “on-the-fly” (from ON/OFF to OPEN/CLOSED), but since then I have already deleted the thing twice, unlinked/relinked channels, etc…

Is there anything else I have to do to clean the past mistakes, or a way to force OH to classify those channels as contacts instead of switches? I cannot see any place in the UI where MQTT channles type can be changed.

Thanks in advance for your help

No, you cannot change the Channel type on an automatically discovered MQTT Thing. But it should be choosing a Contact as the type anyway so either there is a bug in the MQTT binding that failed to detect that this is a Contact and not a Switch, or there is a bug in the device where it failed to report the correct information for the binding to correctly identify the Channel type. I don’t know that much about Homie so beyond that I can’t say.

Thanks @rlkoshak

I am going to file an issue for this, I think the device is OK, since I programmed it :wink:

Seriously, the only unknown in the homie specs is the sensor node attribute. There is no list of possible types, but I am wondering if the Autodiscovery infers the “OH-type” out of the type attribute. I quickly tried “contact” as sensor type but nothing changed.

Is the Homie binding maintainer around so he/she can shed some light on this issue? :hugs:


Wait… I have just discovered that the Thing database /var/lib/openhab/jsondb/org.openhab.core.thing.Thing.json contains the type information

          "acceptedItemType": "Switch",
          "kind": "STATE",
          "uid": {
            "segments": [
            "uid": "mqtt:homie300:Localhost:esp_gateway:bedroomWindowSensor#status"

I guess this is the last resource, but in case I cannot find another way :cowboy_hat_face:

Just checked in the code (link), it explicity mention that

// Type has no meaning yet and is currently purely of textual, descriptive nature
public String type;


it seems you are the maintaner of the binding - what is your view on my issue?


Not really, see this file for each add-on maintainer:

@wborn apologize, I have misread the commit log!


It semms you are the mqtt master :wink: any thoughts on the issue?

Let me know if I need to provide more data or doing more tests…