Hello,
I was seraching quite a lot of ressources but could not get anythunbg to work in openhab.
Problem: I have a setpoint item for temperatures. I want to send for example the value 20 (it is a temperature value as number) via my serial binding.
As the serial binding is a String item, my “20” is send as hex “32 30” corresponding to “2” “0” in ASCII code.
It should be “14” as hex code via my serial code.
Question: what can I do to either
a.) convert my “20” decimal value to the ASCII code
b.) convert my “20” to hex and actually send hex instead of ASCII (so far I found /uxxxx, but I can not use a variable with this)
question: do oyu mean “cc2.sendCommand(70)”, where “cc2” is my item and “70” is my number? (cc2 binding is serial bus)
In this case, I will see on the log the command “70” as send indeed, but on serial bus the hex codes “37” “30”, which are the Hex codes of “7” and “0”.
Target: I would need to the the hex code “14” on my serial bus, which corresponds to “46” hex which stands for decimal “70”.
So far I did not find another solution as to parse first my “70” to the asci code and send the ascii code afterwards.
Yesterday evening, after horus of searching (as Java code is not really working in openhab), I found this, which si working for me now:
" var strVal = String::valueOf(Character::toChars(50))"
, where “50” is my value to be translated (just example). Now the decimal “50” is tranlated and i send the “strVal” via serial binding.
Still a bit complicated, so if there is another way, I am still interested.
Yes, if cc2 is a Number Item and you call cc2.sendCommand(70) it might send out the numerical value instead of the String. I don’t use this binding so I’m only making an educated guess.