I have a Tuya dimmer with Tasmota firmware.
Binding the Power ON/OFF works fine. As response to some command changing the power I receive messages on two topics:
22:58:39 MQT: stat/tuya-1/RESULT = {"POWER":"ON"}
22:58:39 MQT: stat/tuya-1/POWER = ON
So when I bind the power, I use “cmnd/tuya-1/POWER” as the command topic and “stat/tuya-1/POWER” as the status topic. All fine.
But with the dimmer value, that is a bit different; when I change the value by sending e.g. “42” to “cmnd/tuya-1/DIMMER” topic, it responds with:
23:02:40 MQT: stat/tuya-1/RESULT = {"POWER":"ON","Dimmer":42}
This uses the same topic as seen above in the power example, it just has a different additional “Dimmer” tag in the JSON (!) message body.
For clarity: I do NOT receive something on a topic like
23:02:40 MQT: stat/tuya-1/DIMMER = 42
So I have to live with the JSON for the time being.
For other numeric values I have already successfully used the JSONPath transformation (e.g. the RSSI value in the general status topic). But here it is different, because the Dimmer tag is not present in all messages comming on this topic; some have power and dimmer values, some only have the power value.
As a consequence I get exceptions from the transformer when the MQTT broker deliveres the messages without dimmer value.
(And, by the way, it very much seems to me that when I change a thing definition to use a different json path, the openhab.log tells me that it has read that thing-file without problems, but the changes do not come into effect until I restart openhab service. Is that expected/known behaviour?)
Anyhow: do you have any proposals how you typically would bind the result messages I listed above with the current MQTT-Binding 2.4.0? Is it okay to use JSONPath transformers in a read/write binding with a command topic and a status topic, but the transformation only applies to the status, not to the command? Or is it standard that a transformer is only applied for incoming messages?
Any help appreciated, cheers, Michael