LTE RSRP to variable with foreach

Two LTE interfaces on a RBM33G.

I tried, with the script below, to extract the RSRP in a variable. But there is a strange reaction from RouterOS. In the first part it wil return with, say, index 4. The LTE interface can be asked out on the fourth position. If you look at the interfaces pane in Winbox, correct… But I want the “/interfaces lte”. The second part uses the same command to extract the RSRP with position 4, but it is position 0 if you want anything meaningful. I have the idea that two different arrays are created. One from the /interfaces and one from the /interfaces lte.


 :foreach i in=[/interface lte find] do={:if ([:typeof [:find [/interface lte get $i name] "lte1"]]!="nil") do={:global "LTE01 RSRP Value" ([ / interface lte info [ :pick [ find ] $i ] once as-value ]->"rsrp")}}

Does anyone have a good idea.

I am not perfectly sure what you want to achieve… How about something like this?

:foreach Interface in=[/interface lte find] do={ :put ("RSRP value " . [/interface lte get $Interface name] . ": " . ([/interface lte info $Interface once as-value ]->"rsrp"))}

Output on my device is: RSRP value lte: -79

Of course my device has just one lte interface. With two interfaces you have two values… Do you want these values go into different variables?

I have two lte interfaces so yes, it should go into two different variables. It’s two o clock right now, I will test it some time in the morning. At first sight it solves the problem with the internal interface id’s.