Setting Virtual Contact Sensor state via MQTT Command


I am running into a wall with a project I am working on. I am trying to use MQTT/smartthings-mqtt-bridge to set the state of a virtual contact sensor.

Is the command ‘contact’ read-only?

I have a real contact sensor, it reports as


When i try to issue either command to a virtual contact sensor, it never changes. The smartthings sample one has a open/closed press action, but trying to set it via MQTT never changes the state.

Is there something I am missing, or does ST not allow this?

my log looks like this:

Received device event from bridge: [name:Office Window, value:close, command:true, type:contact]

Essentially I have combined rtl_433 with MQTT and a python script to re-use about 15 SimpliSafe 433mhz sensors. Everything is working except for the state of the contact changing.

edit 1: This works perfectly fine with a “Simluated Switch” so I know everything up and into SmartThings is working. I am not sure where to proceed…


What smartapp are you using to change the state of the virtual contact sensor? Also, why don’t you just use the MQTT Bridge device to set up a device that would update directly from MQTT rather than having a virtual device?

There are details on how to set up the smartthings devices over in the github for the bridge.


I think that’s what I am doing.

My config is as follows.

rtl_433 publishes an MQTT message as follows

smartthings/Office Window/contact open

MQTT Bridge is running as a device in smartthings called z_MQTT and is subscribing to all events.

The config for the MQTT device requires that I choose my devices to be updated when event shows come in via MQTT, e.g. locks, sensors, alarms, etc.

So the MQTT bridge/smartapp/device is trying to set my virtual contact sensor Office Window ‘contact’ to ‘open’

That device doesn’t seem to accept that input. If I change Office Window to a switch and issue the command ‘switch’ ‘on’ that works perfectly fine.

Is there a link to what you were referring to with making devices another way?


Okay, let me re-phrase. What DTH are you using for the “virtual contact sensor”?


I’ve tried a handful, but mainly had been trying these:


That’s because the smartapp is going to share your ST devices TO MQTT and the events you subscribe to in the bridge will be displayed in the MQTT device. If you want to then change the status of other devices, you’d have to use WebCore to do it based on the events logged in your MQTT device.


It works both directions. I am using this smart app to do so.

Note the architecture where commands can go both directions as well as device statuses.

Like I said, if I replace the “Virtual/Simulated Contact Sensor” with a “Virtual/Simulated Switch” and issue the on/off it works fine. I see the switch turn from on to off and back again in ST when I issue the “smartthings/Office Windows/switch on” command. I’ve correctly setup the MQTT Bridge and Bridge Device/SmartApp

it’s only the DTH of “Contact Sensor” that I can’t set.


Oh… Because the contact sensor should be open close not on/off.


Yes, when testing type contact I am issuing the open/close command. No status change.

When testing type switch, I’ve modified it to use on/off. Successful status change.

I think this issue has to do with ST handling of contact switches.


Try on/off with the virtual contact sensor. I know the DTH i use responds to both.