It looks little different from what i use via zigbee2mqtt, especially the outside []…i tried several ways but simply states invalid path in the logs…so something is wrong here…but what. Can you please help me to recevei for example the ist temp at 23°C.
This does not work at all: Type number : miAC_TempIn "Temp Inside [%.1f °C]" [ stateTopic="/miAC/state", transformationPattern="JSONPATH:$.ist" ]
It’s not a rule based solution, it’s a test bed so that you can test out different ideas for the JSONPATH parameter you were struggling with. Of course you also need sample data, which you most helpfully provided.
I don’t know what you mean. You don’t need any rule for your original problem, just a revised JSONPATH parameter.
Now i struggle at the other direction. Sidenote I removed the useless Array completely in the AirCon Code.
The AirCon status can be seen here:
[ stateTopic="/miAC/state", transformationPattern="JSONPATH:$.conf.on",on="true", off="false" ]
…which works fine…but setting the AC to ON/OFF simply does not work.
Turning ON the AC should be sending MQTT to /miAC/cmd the following…{"on":true}
Which works great if i directly publish this via MQTT.fx client
Putting this into the same thing i thought it would be like this (similar to other working zigbee2mqtt switches)
Type switch : miAC_Power "miAC Power [%s]" [ stateTopic="/miAC/state", commandTopic="/miAC/cmd", transformationPattern="JSONPATH:$.conf.on", transformationPatternOut="JSONPATH:$.on", on="true", off="false" ]
After each successful integration of MQTT json messages i have some believe I now can handle this, but situations like right now show me the opposite.
Error log shows:
2021-05-15 00:19:39.665 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.on' in 'true'
I now did it that way, which works: Type switch : miAC_Power "miAC Power [%s]" [ stateTopic="/miAC/state", commandTopic="/miAC/cmd", transformationPattern="JSONPATH:$.conf.on", formatBeforePublish="{ \"on\": %s }", on="true", off="false" ]
Still few question. if there is no JSONPATH backward possible, what is the transformationOutPattern for?
Is there any documenttaion available for this part?
Another question i ask myself now many times before.
Is the order important? like stateTopic and directly afterwards the mapping table like on=“true”,…and after this the commandTopic…or first stateTopic, then commandTopic and in the end the mappings?
is the mapping on=“true”,… also used/valid for the commandTopic ?
You want to send the payload {"on":true} (or presumably {"on":false}
This is relatively simple, as JSON goes.
So you can build your required message as a string
{“on”: + substituteYourValue + }
sorry @rossko57, i do not get your second message. it already works so not sure why you explain it a second time.
I guess you are aware here as well and can bring light into these questions:
Is the order inside the thing definition important? like stateTopic first and directly afterwards the mapping table like on=“true”,…and after this the commandTopic…or first stateTopic, then commandTopic and in the end the mappings?
Is the mapping on=“true”,… also used/valid for the commandTopic ?..meaning that if you use stateTopic and commandTopic, who of them is using the on="true,off=“false” mapping? both i guess…
My guess was/is that as advanced as MQTT2 is it would also be able to directly handle the map file.
So I found in the community the following example:
Type switch : reachable "Reachable" [
stateTopic="tele/sonoff-SW01/LWT",
transformationPattern="MAP:reachable.map"
Which brings me to my question…how can I bring togehter the two transformationPattern when first i need the JSONPATH and second I would need the ACmode.map?
hmm, I suppose you might be able to chain two transformations, one after the other. So you’d use JSONPATH to extract a value, and MAP to convert it to something else by lookup.
which says to do it like this JSONPATH:$.conf.mode∩MAP:ACmode.map.
I tried it based on my map file but did not work. map file looks correct to me.
But in the documentation you mentioned there is no word written about this “∩” special character.
update: found it in the doc but still no success.
Transformations can be chained by separating them with the mathematical intersection character “∩”. Please note that the incoming value will be discarded if one transformation fails
As you’re configuring from file, it’s worth remembering that small Thing/channel edits are not always immediately implemented, depending on binding. Sometimes a package restart is need to ensure latest config is in use.