From my heatpump, i get a json with all the values. There is one value, that delivers the state of different “items”, if they are on or not. Item B0 - B14. According to the manual of the heatpump, this is information is 16bit binary decoded.
83 as value for example, would be converted to binary 00000000 01010011.
That gives the information that the following items are on: B0, B1, B4, B6
My aim is of course, to have for every single item the information of the state, so that i can use them for persistence services.
I guess, i need to that with a rule, convert the Value to binary and then map the information to the items.
That is where i need help. What is the smartest way to do that? I guess in Java there are functions for the conversion, i also saw something regarding bittesting, but im a bit los.
So i would really appreciate if you could help me with an example or point me in another direction if im wrong with the rule.
This is what you will need to use. There is nothing built into the Rules DSL for processing binary and shockingly the Rules DSL even lacks an XOR operator. So you will want to use the also inadequate Java libraries to parse and shift the binary to extract the bitpacked information. If you search for examples of processing binary in Java tutorials you should be able to apply those to a Rule.
Thanks for your quick reply. I feared that, since im a noob in Java
There is a Stiebel-Eltron Binding available, from Kai Kreutzer i think. This is based on the modbus connection, maybe there is already some code for that available, that can be used, need to ask there.
Bro, thank you so much. With just some small corrections, it works like a charm. Just for the case someone has the same question in the future, here the working code