[SOLVED] Problem with space in mqtt messages for generic thing (mqtt 2.0)


I have a MQTT device that sends the following message:

fhem/Krigsstigen/pir1/state on-old-for-timer 60

It’s a motion detection (PIR) device from my legacy ELV/FHEM system that I want to use as a contact. I have the following thing definition, that should convert the message to a contact (as described in the docs) :

Thing topic tvrum "TV-rum" @ "Krigsstigen" {
  Type contact : motion "TV-rum" [ stateTopic="fhem/Krigsstigen/pir1/state", on="on-old-for-timer 60" ]

However, I get the following error in the logs.

2019-01-07 20:38:30.744 [WARN ] [eneric.internal.generic.ChannelState] - Command 'on-old-for-timer 60' not supported by type 'OpenCloseValue': No enum constant org.eclipse.smarthome.core.library.types.OpenClosedType.on-old-for-timer 60

I guess that the problem is that there is a space in the message, but as I understand from the MQTT standard, this should be allowed. When I use the similar setup for contacts or switches without spaces, it works fine.

Should this be possible with the new binding (i.e. is it a bug?) or am I understanding things wrong?

Did you try “escaping” the space:

on="on-old-for-timer\ 60"

Otherwise you may need to go through the MAP transformation way

If you try on paper UI you can check if escaping is really the problem. In item and thing files you need to escape a lot.

Tried to escape as you desribed but that didn’t work. I fixed with a transformation instead:

Thing topic tvrum "TV-rum" @ "Krigsstigen" {
  Type contact : motion "TV-rum" [ stateTopic="fhem/Krigsstigen/pir1/state", transformationPattern="MAP:fs20_contact.map" ]

and transform/fs20_contact.map:

on-old-for-timer\ 60=OPEN
1 Like

Please tick the solution, thanks

Thanks, good idea!