At the bottom of this documentation, it says how to get the topic of the MQTT channel.
I’m not able to get this to work, and have tried all of these incantations:
Type trigger : trigger_accessControl "Access control" [stateTopic="zwave/#/Kwikset/notification/endpoint_0/Access_Control/#"]
Type trigger : trigger_accessControl "Access control" [stateTopic="zwave/+/T6Pro/#",trigger=true,publishTrigger=true]
Type trigger : trigger_accessControl "Access control" [stateTopic="zwave/+/T6Pro/#",separator="#" ]
Type trigger : trigger_accessControl "Access control" [stateTopic="zwave/+/T6Pro/#" ]
Type trigger : trigger_accessControl "Access control" [stateTopic="zwave/+/T6Pro/#",trigger=true ]
Type trigger : trigger_accessControl "Access control" [stateTopic="zwave/+/T6Pro/#",separator="#",trigger=true ]
Type publishTrigger : trigger_accessControl "Access control" [stateTopic="zwave/+/T6Pro/#",separator="#",trigger=true ]
Type publishTrigger : trigger_accessControl "Access control" [stateTopic="zwave/+/T6Pro/#",separator="#" ]
I have a rule like this, trying to get the topic to show.
rule "Lock alarm triggered"
when
Channel 'mqtt:topic:generic:trigger_accessControl' triggered
then
// var actionName = receivedEvent.getEvent()
logInfo("LockAlarmTriggered",receivedEvent.toString)
end
I don’t use and don’t support .things files so I cannot help if there is a syntax error or the like.
I can confirm the configuration parameters are stateTopic and separator. I don’t know where you are getting these trigger and publishTrigger properties from. The type of the Channel is trigger, there’s nothing else to configure after that.
Inside your rule, when triggered, receivedEvent should be a String of the format <topic><separator character><message> (e.g. "zwave/something/T6Pro/something#ON").
Make sure you are using the subscription wildcards correctly. + is a single level wildcard. zwave/+/T6Pro will match zwave/foo/T6Pro but it will not match zwave/foo/bar/T6Pro. # is a multilevel wildcard. zwave/#/T6Pro will match both zwave/foo/T6Pro and zwave/foo/bar/T6Pro.
Trigger Channels have a type of trigger. If OP changes the type to string it will change the Channel to be a state Channel instead of an event Channel. If the Channel is defined on the Broker Thing, it needs to be of type publishTrigger. If it’s a Channel on a Generic MQTT Thing it need to be of type trigger.
And the channelTypeUID is set to mqtt:trigger instead of there being a separate configuration parameter.
channels:
- id: test
channelTypeUID: mqtt:trigger
label: test
description: ""
configuration:
stateTopic: test/topic/#
transformationPattern: "#"
Maybe the docs are out of date? Maybe there is a wide difference between managed MQTT Things and .things files, though that is very unusual. The names of the properties and how they are used usually map between the two.
Here’s a “switch” state Channel for comparison.
channels:
- id: online
channelTypeUID: mqtt:switch
label: Online status
description: Indicates online status of this sensor_reporter
configuration:
stateTopic: sensor_reporter/hydra/status
off: OFFLINE
on: ONLINE
==> /var/log/openhab/openhab.log <==
2024-05-31 11:49:59.237 [WARN ] [rnal.handler.GenericMQTTThingHandler] - Configuration error for channel 'mqtt:topic:generic:trigger_accessControl'
java.lang.IllegalArgumentException: ChannelTypeUID not recognised: publishTrigger
at org.openhab.binding.mqtt.generic.values.ValueFactory.createValueState(ValueFactory.java:86) ~[bundleFile:?]
at org.openhab.binding.mqtt.generic.internal.handler.GenericMQTTThingHandler.initialize(GenericMQTTThingHandler.java:189) [bundleFile:?]
at org.openhab.core.thing.binding.BaseThingHandler.thingUpdated(BaseThingHandler.java:157) [bundleFile:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
at org.openhab.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:147) [bundleFile:?]
at org.openhab.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
at java.lang.Thread.run(Thread.java:840) [?:?]