MQTT2.4 state topic, need Incoming value transformation

Hello,

I used MQTT2.4 for a 2 way tuya device , so with DPS . the problem is the tuya devise send a state “true” or “false” , but openhab don’ like true or false state . So i think i need to make a jsonpath transformation in PaperUI . but I don’t know to transform true value to on value with jsonpath in Incoming value transformation

here the error in logs :

2019-07-24 22:08:17.940 [ome.event.ItemCommandEvent] - Item 'Lum_hotte' received command OFF

2019-07-24 22:08:17.958 [nt.ItemStatePredictedEvent] - Lum_hotte predicted to become OFF

2019-07-24 22:08:17.967 [vent.ItemStateChangedEvent] - Lum_hotte changed from ON to OFF

==> /var/log/openhab2/openhab.log <==

2019-07-24 22:08:18.314 [WARN ] [eneric.internal.generic.ChannelState] - Command 'false' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.false

2019-07-24 22:08:18.389 [WARN ] [eneric.internal.generic.ChannelState] - Command 'false' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.false

2019-07-24 22:08:18.404 [WARN ] [eneric.internal.generic.ChannelState] - Command 'false' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.false 

if someone can hep me , please :slight_smile:

No i can’t, because I need to put { “dps”: 2, “set”: true } for on/open value and { “dps”: 2, “set”: false } for off/closed value …I use Tuya_mqtt client :slight_smile:

And for state , the device return true or false … i want transform incoming value …

Is the message always {"dps": 2, "set": true } and {"dps": 2, "set": false }? If so you can use the post rossko57 provided. Just use the full JSON string.

If that “dps” will changed or there might be other nodes in the JSON than if you upgrade to at least MQTT 2.5 M1 you have the option to chain transformations together. You can apply the JSONPATH first to extract the true/false and then apply a MAP to convert those to ON/OFF.

I don’t know if it would work to just apply the JSONPATH and then use the solution in the link. It’s worth a try. In that case the JSONPATH will extract the true/false and the field will convert the them to ON/OFF.