Your magic stuff could be a JS script (JavaScript transformation) that concatenates the XML part before the value, the value and the XML part after the value.
@J-N-K
so it not possible to concat directly in the commandTransformation?
like commandTransformation=""string1" + item.state.toString + "string2""
if this does work … I didn’t find the correct way how to put it in there and how to escape stuff.
and no way around to call a JS?
So must look like this? commandTransformation: JS:myCmd.js
Yes, unfortunately that is not possible at the moment. Maybe a formatBeforeSend like the MQTT binding implements would be a good idea. However, for a complete XML this is probably not a perfect fit, either.
My choice would be a new formatTransformation, which takes an input file, applies String.format on that file with value (probably transformed by other transformations before) as parameter. Unfortunately that transformation does not exist in openHAB.
I guess my (input) is just the value of the item itself then?
If I make 1 JS per room this works but If I want to use just one JS for all the room heatings I would need a reference within the JS by what Item or Channel it was triggered to slightly modify the first part of the xml aswell.
The part before the value in the XML has a number (Heatarea) which is for the individual room.
Example:
Channel:
Type number : FBH_Wohnen_SOLL [ commandTransformation="SOLLwert.js ]
Type number : FBH_Schlafen_SOLL [ commandTransformation="SOLLwert.js ]
Concat in the JS
Triggered by FBH_Wohnen_SOLL
<?xml version="1.0" encoding="UTF-8"?><Devices><Device><ID>fixed</ID><HEATAREA nr="1"><T_TARGET>"
+ value from the input item +
</T_TARGET></HEATAREA></Device></Devices>
Triggered by FBH_Wohnen_SOLL
<?xml version="1.0" encoding="UTF-8"?><Devices><Device><ID>fixed</ID><HEATAREA nr="2"><T_TARGET>"
+ value from the input item +
</T_TARGET></HEATAREA></Device></Devices>
Is that possible?
Cheers
edit:
(function(i) {
var str1 = "xmlpart1";
var str3 = "xmlpart3";
result = str1 + i + str3;
return result;
})(input)
probably this should be the script for a single room.
and “xmlpart1” should be filled by a case statement where the triggering item is considered.
just don’t know how
the error shows up every 30 seconds in the log.
But this Thing/Channel is not configured with a refresh parameter?
(For the same item there is another Thing/Channel defined which actually has a refresh of 30 secs …however I would expect that this only applies for the channel where it is configured?)
If you use the channel only for sending commands, set it to WRITEONLY, otherwise there will be a request every refresh seconds (as configured in the thing configuration).
edit 2:
I still see the WARN in the log
but the base unit actually gets the value !
So I guess the WARN is about the Answer from the base unit.
The manual say (sorry german) that the unit responds.
Is there a way to do something with the response? at least suppress the WARN or something? hopefully my final question.
Thank you @J-N-K or guiding me to this point happy already
I will write up a small tutorial for the forum and post it so others can copy if needed.
You shouldn’t see GET requests for WRITEONLY channels. My best advice at that point is restarting openHAB. I have seen things not properly disposed when textual configuration is used, so it could be that the warnings are GET requests from a channel that should have been discarded.