In addition to the mime type being wrong as @glhopital points out, the code itself looks like a transformation, not a script action. There is no such variable input in a script action. You have event instead.
Did you try to use a chatbot to create this rule? Mixing up rules languages like this (logInfo also doesn’t exist in JS Scripting) is one of the many reasons these chatbots are worthless for OH rules.
Always post the error. Failing to do so is like going to the Dr. and refusing to tell them where it hurts.
In the new rule, when you create an Inline Script Action, choose JS Scripting from the list of languages. If you don’t have that as an option, you haven’t installed the JS Scripting add-on.
The code should look something like:
(Assuming you are not using units)
var total = event.itemState.floatValue * 0.38;
console.info("total for solar - " + total);
items.total_energy_savings_amount.postUpdate(total)
If you are using units we need more info.
Or if you really mean this to be a transformation:
Create a new JS Script transformation (Settigns → Transformations)
The code should look something like this:
var total = parseFloat(input) * 0.38;
console.info("total for solar - " + total);
return total;
All that function stuff doesn’t add anything in an OH context, there is no global environment to pollute so there’s no need to create a self executing function. But if you insist:
(function(reading) {
var total = parseFloat(reading) * 0.38;
console.info("total for solar - " + total);
return total;
})(input)
If you get rid of the log statement it can be an inline script transform.
JS:| parseFloat(input) * 0.38
Add a link between the Channel that feeds “all_time_energy_solar” to “total_energy_savings_amount” and add a Script profile that calls the transformation created in 2 as the “Thing to Item” transformation.
You’ve not provided enough details to say which approach is better.
If you are suing modbus, it comes with an offset profile you can use instead of a custom JS Scripting rule or transformation.