Moving code from OH2.5 to OH 3 (var to Number) comparison issue

For OH 3 I need to move var in rules to item numbers and can’t find the solution for a comparison

Number GewenstBadkamerRadioVolume 
Number HuidigBadkamerRadioVolume
if ((HuidigBadkamerRadioVolume.state as Number) < (GewenstBadkamerRadioVolume.state as Number)) {

The error I get is

What is wrong?

I’m going to guess you have a missing closing ) or ] or } somewhere further up in the file. There is a mismatch in the parens in that if statement making it try to use one of the .state s as the boolean.

There is nothing about the statement itself that looks wrong.

Thanks for your very quick feedback.
With your remarks I check the code again and I couldn’t find a issue.
I closed all the files and restarted WinSCP and no error was shown.

One line left of a converted rule I can’t find a solution for

String SonosPlay1BadkamerRadio                "Radio"                         (SonosBadkamer,AllSonos,Group_Sonos) {channel="sonos:PLAY1:RINCON_7828CA90B06001400:radio"}
String Radio2 

System started. Below is working fine

    if (Radio2.state == NULL) { Radio2.postUpdate("NPO Radio 2 92.9 (Pop)")} 

I want to assign a String to a String but both options below are none working

    SonosPlay1BadkamerRadio.postUpdate (Radio2.state as Sting)  
    SonosPlay1BadkamerRadio.postUpdate (Radio2) 

I hope you can help again.
Thanks in advance.

Infinity is held in the works "not working’. Not working how? Errors in the log?

That’s just a meaningless line. You shouldn’t have ever seen any working examples with something like that. A String Item’s state is a StringType, not a String. You can’t just say “as” and convert types that are not related to each other. Usually you will see a call to toString to convert a State to a String.

Again, this line is kind of nonsense. A String Item isn’t a String. A String Item isn’t even a State. A String Item carries a state. A state can be posted as an update to an Item. But an Item cannot. But you should be able to send Radio2.state as an update.

If these were ever lines in a rule you are converting, that rule has never worked. If a lot of these sorts of things trip you up, consider looking at Blockly which makes you avoid a lot of these sorts of problems.

Thanks. That is working.
OH2 was working as well

val String Radio2 = "NPO Radio 2 92.9 (Pop)"          
sendCommand(SonosPlay1BadkamerRadio, Radio2)