Can't convert yahoo temperature to Fahrenheit

I’m using the Yahoo Weather binding in OH2 and it returns the temperature is Celsius. This works fine, but I want to convert it to Fahrenheit, so I’m using a rule, but I can’t get it quite right. I think I’m close looking at examples and other posts, but I’m missing an understanding of something. Here is temperature in my items file:
Number Temperature "Current Temperature [%.1f °F]" <temperature> { channel="yahooweather:weather:918d6903:temperature"}

Here is my rule:

when
        Item Temperature received update
then
        val num = Temperature as DecimalType
        var temp_transform=transform("JS", "celsius2fahrenheit.js", num)
        Temperature.postUpdate(temp_transform)
end```

I've tried a number of things, but this rule gives this error:
```Rule 'Transform temperature': org.eclipse.smarthome.core.library.types.DecimalType```

My Thing is defined in PaperUI, not in a Things file. The .js file is located in confusion/transform/celsius2fahrenheit.js

Any ideas?

Maybe this will help (add .state)

Get a different error:
Rule 'Transform temperature': An error occured during the script execution: Could not invoke method: org.eclipse.smarthome.core.transform.actions.Transformation.transform(java.lang.String,java.lang.String,java.lang.String) on instance: null

At some point prior to this, I have a rule that generated this error:
Rule 'Transform temperature': For input string: "Temperature (Type=NumberItem, State=15, Label=Current Temperature, Category=temperature)"

This leads me to believe that I can reference the temperature value as a property of the item Temperature, like this:
Temperature.State
But I get a different error:
The name '<XFeatureCallImplCustom>.State' cannot be resolved to an item or type

@lazloman you spelled .state with a capital S

It is .state
watch out for the lower case “s” in .state

Thanks for the reply, I tried lower case before and got the same error. Looking at the output from a previous error, State=15, I thought uppercase may have been the correct one, but of course, no.

In any case, here is my current rule:

when
        Item Temperature received update
then
        val temp = Temperature.state
        val temp_transform=transform('JS', 'celsius2fahrenheit.js', temp)
        //Temperature.postUpdate(temp_transform)
end```

Im getting the error:
```Rule 'Transform temperature': An error occured during the script execution: Could not invoke method: org.eclipse.smarthome.core.transform.actions.Transformation.transform(java.lang.String,java.lang.String,java.lang.String) on instance: null```

I commented out the transform line and got no error, so I suspect the syntax of that line is somehow incorrect, but I'm not sure how. The javascript is located at conf/transform/celsius2fahrenheit.js with the openhab user having full rights.

Sorry @lazloman, never tried using transforms that way; obviously you have a reason for using a transform, but if you want to give yourself a break why not code it in a rule directly?
Here something I just tried that works well:

rule test
when Item Temperature received update
then 
        val temp = Temperature.state as DecimalType+32*5/9
        logInfo("conversion",temp.toString)
        Temperature.postUpdate((Temperature.state as DecimalType+32*5/9).toString)
end

Please note that the first two lines are not necessary
But you will see that some more casting of variables and states are necessary to make it work.
the whole rule could just read:

rule test
when Item Temperature received update
then 
        Temperature.postUpdate((Temperature.state as DecimalType+32*5/9).toString)
end

Finally, as you just work with a postUpdate, it seems that you want to just have it displayed, you can do that it the item definition much more easily (but if you do that the stored value will not change, just the value displayed on your sitemap.

Number Temperature "Current Temperature [JS(celsius2fahrenheit.js):%.1f F] <temperature> { channel="yahooweather:weather:918d6903:temperature"}

Again, I a not using it, so I am typing from memory of what others have written in the forum.
Hope that helps

temp.toString

Transforms work on strings, not other Item types and the Rules DSL always had problems converting Numbers to Strings automatically.

I did try this, but it did not work, so I thought I’d try a rule instead.
But, in any case, it works now. Thanks much, I can get on with my life now!