Rule for adding an Offset

I want to add 1.0 to the temperature I tell my device.
Everytime i tell Amazons Alexa to set the temperature to 23 Degrees, it gets set to 22 (always 1 below) so i want to create a rule to add 1, but this rule isn’t working:

rule "Thermo"
Item alexa_temp_set received command
alexa_temp_set = receivedCommand + 1.0

this is the firstitem.items:
Number alexa_temp_set “Thermo” [ “TargetTemperature” ] {channel=“homematic:HM-TC-IT-WM-W-EU:XXXXXXX:MEQXXXXXXX:2#SET_TEMPERATURE”}

this is the error-message i get:
[ERROR] [.script.engine.ScriptExecutionThread] - Rule ‘Thermo’: An error occured during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_plus(java.lang-Object,java.lang.String) on instance: null

can anyone help me?

You can’t do that with an Item (it is a complex object not a simple variable.
alexa_temp_set.postUpdate( somevalue ) might be a way to do it without getting a loop, re-triggering your rule.

thank you for your answer!
i tried:

rule "Thermo"
Item alexa_temp_set received command

but i still get an error…

You need to cast receivedCommand to a Number

alex_temp_set = (receivedCommand as Number) + 1

now this is my homematic.rules:
rule "Thermo"
Item alexa_temp_set received command
alexa_temp_set = (receivedCommand as Number) + 1

and i get a new error message:
[.script.engine.ScriptExecutionThread] - Rule ‘Thermo’: An error occured during the script execution: Cannot assign a value in null context.

any idea?

I guess @rlkoshak missed that alex_temp_set is an item,. Read the comments above on how to post an update on an item!

like this?
alexa_temp_set.postUpdate((receivedCommand as Number) + 1)

Worth a try

i get no errors, but i still get an offset…

That might be because you are treating the error, not the cause of the error.

Why do you get this unwanted offset?


well i don’t know, but when my homematic ccu can’t find the thermostat, openhab sends an error that the value (and there it is the wrong) could not sent

but when i change the temperature here, it is send correctly. i only get an offset when i tell alexa to change it.

So it looks like it is caused somehow by Alexa.

Does the log show what value is understood by Alexa?

yes, in the alexa app there is the right value.
but shouldn’t my rule fix it if i don’t get an error with it?

Where is the difference between sending a temperature from the UI ( which works as desired) and sending a temperature via Alexa or changing values by a rule That’s what to look for.

As Alexa is getting it in correct, that can ruled out.

but where can i look for an error?

Put all related bindings in DEBUG and compare the logs when setting a value via UI and via Alexa and also what the rules does.
The wrong value should appear somewhere down the road.

i will try it, but where can i find DEBUG?

Read Here