OH3 | Correct “channelTypeUID” for MQTT motion sensor?

Raspberry PI Openhab3
Mosquitto MQTT broker
MQTT Binding 3.0.0

I’m new in the world of MQTT in combination with Openhab
I have a Motion Sensor that on the state topic publish true or false.

My Channel info

 UID: mqtt:topic:b8be661fe1:WC_Motion_sensor
label: WC Motion Sensor
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:b8be661fe1
location: WC
channels:
  - id: motion
    channelTypeUID: mqtt:switch
    label: Motion Status
    description: ""
    configuration:
      stateTopic: zigbee2mqtt/WC_Motion_sensor/occupancy

openhab.log

2021-01-15 16:56:56.446 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command 'true' not supported by type 'OnOffValue': No enum constant org.openhab.core.library.types.OnOffType.true

What is de correct “channelTypeUID”for a motion sensor?
I now have channelTypeUID: mqtt:switch

I only find the following Channel types:

Text Value
Number Value
Percentage Value
On/Off Switch
Open/Close Contact
Color Value (Red,Green,Blue)
Color Value (Hue,Saturation,Brightness)
Color Value (HSB, RGB or CIE xyY)
Date/Time Value
Image
Location
Rollershutter
Trigger

which do not contain any type of: Movement/Motion
i have tried the following type: Switch, Contact and Trigger

2021-01-15 23:20:52.375 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command 'true' not supported by type 'OnOffValue': No enum constant org.openhab.core.library.types.OnOffType.true

Thanks for looking at it

Which is fine. Just change your YAML to include the on and off parameters:

channels:
  - id: motion
    channelTypeUID: mqtt:switch
    label: Motion Status
    description: ""
    configuration:
      stateTopic: zigbee2mqtt/WC_Motion_sensor/occupancy
      on: true
      off: false

By default, openHAB only understands on and off for a switch, so if it’s receiving anything else you must explicitly tell openHAB what to expect.

Thanks,

Somehow I don’t think of a switch when I see a motion sensor
I understand it now and wil expiriment with it

Greetings,
Michiel

Sure! I think the Switch and the Contact Channels are probably most appropriate for a motion sensor, though others may have other preferences. As you mentioned earlier though, openHAB doesn’t have a specific Motion Channel.

slowly I learn to find my way in OH3 and MQTT
Thank for your help

Do you have any experience with light bulbs via MQTT?
Openhab expects a value from 0 to 100 on a dimmer channel
My bulb expects a value from 0 to 254.
I read some topic where they use a jave script to transform the value, but I have no idea how to apply that via OH3’s gui

Maybe better to create a new topic for this.

Yes, via zigbee2mqtt:

Your the best , i have some reading to do :slightly_smiling_face:

What you do, is use a “trigger” channel and then define rules for your motion sensor.

Have a watch of this:

/M