2021-07-02 19:57:10.744 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'HeizungsDaten_Neu' failed: <eval>:40:26 Expected an operand but found >
idx=arr.find(item->item.feature==="heating.sensors.temperature.outside");
^ in <eval> at line number 40 at column number 26
The displayed help for FindIndex (findIndex( callback: fn( element:number, index:number, array:TypedArray) -> bool:thisArg?) ->number leaves me without a clue.
Reasoning:
As a response to an API call requesting several datapoints I get a JSON formated return. This JSON is containing an array of those data-points, sadly the order of the array elements is not as requested and can change (as I had to notice).
Show the code that parsed the JSON and extracted the array.
Assuming you are using the built in JavaScript, I don’t think -> is an operator in ECMAScript 5.1 which is the version openHAB comes with. You need to find the approach that works for that older version.
Thanks for all inputs! @pacive : Sorry, but that didn’t help either.
My (personal) solution:
While digging into the findIndex stuff I found that all solutions with .findIndex or .indexOf etc. are using a for..next loop behind the scene anyhow. As I would be using such method (correct term?) on virtually all array members the code in my rule migth look good, however I would run such a loop for every member. By running a single for..next loop in the rule once and using a select case on every member in order to get the correct value I should be fine!
My code is working!