RFXCom binding and Transforms

Hi,

Trying to get a simple multiply to happen on an current reading for an Owl rfx device using Javascript transform on an item. I’ve read that the bindings need to support the transform but I can’t find anywhere any info saying if the rfxcom binding supports them or not?
Item:
Number Owl_p3 { rfxcom="<[36352:Channel3Amps:JS(multiply240.js)]" }

multiply240.js file in transform directory…
(function(in) {
return in * 240;
})(input);

Hoping it is supported and my syntx is wrong - any pointers?

Thanks,
Steve

Looking at the source code for the rfxcom binding, I don’t see support for transforms. But you could use a rule and a “proxy item” to achieve what you are after.
items:

Number Owl_p3_proxy { rfxcom="<[36352:Channel3Amps]" }
Number Owl_p3

rule:

rule MultiplyP3
when
  Item Owl_p3_proxy received update
then
  Owl_p3.postUpdate((Owl_p3_proxy.state as DecimalType) * 240)
end

Great thanks! Will give it a try!

tried:
rule "AmpsToWatts"
when
Item Owl_p3 received update
then
Owl_p3_watts.postUpdate((Owl_p3.state as DecimalType) *240)
end

but log shows:

  • Channel3 Amps = 0.2
    21:34:17.004 [DEBUG] [m.r.internal.engine.RuleEngine:305 ] - Executing rule 'AmpsToWatts’
    21:34:17.094 [ERROR] [o.o.c.s.ScriptExecutionThread :50 ] - Error during the execution of rule ‘AmpsToWatts’: Cannot cast org.openhab.core.library.types.DecimalType to void

items:
Number Owl_p3 { rfxcom="<36352:Channel3Amps" }
Number Owl_p3_watts

Oops. Do you have

import org.openhab.core.library.types.DecimalType

at the top of the rules file?