Hello @Prachar Marek
Did you try adding a null check for the hexString parameter before calling the split method. Here is an updated version of your TypeScript code that includes the null check:
function splitAndConvertHex(hexString) {
if (hexString == null) {
return null;
}
// "03.00.20.80.0F.00.00.68.98.01" --> 198
let x = parseInt(hexString.split('.').slice(-2).reverse().join(''));
const firstNumber = parseInt((x / 10).toString(), 16);
const secondNumber = parseInt((x % 10).toString(), 16);
// Převod na float hodnotu
const floatValue = parseFloat(`${firstNumber}.${secondNumber}`);
return floatValue;
}
With this null check in place, the function will return null if the hexString parameter is null or undefined, and the split method will not be called.
Another thing to consider is the format of the input data. Make sure that the TemperatureHex
field in your input data is in the expected format (i.e. "03.00.20.80.0F.00.00.68.98.01"). If the input data is not in the expected format, this could cause issues with the function.
I hope this helps! If you have any further questions or concerns, please let me know in the below comment section.