Rules are not working

rules
openhab2
problem
Tags: #<Tag:0x00007f0141834868> #<Tag:0x00007f01418346b0> #<Tag:0x00007f0141834570>

(Rossko57) #21

Bear in mind an Item sent a command will usually autoupdate after a short time to the value of the command. That might overwrite any postUpdate that happened in between. Maybe you need autoupdate=“false” here.


(Max) #22

and where should it be added? like this?

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import org.java.math.*
import org.joda.time.*

rule "Thermo"
when
Item temp_set received command
then
autoupdate="false"
Thread::sleep(30)
temp_set.postUpdate((receivedCommand as Number) + 1)
logInfo("Test", "Test Log Entry triggered by thermo command")
end

(Rossko57) #23

No, it is a property of an Item. It goes in the Item’s definition curly brackets {} just like a binding.

http://docs.openhab.org/configuration/items.html#binding-configuration


(Max) #24

so like this?

//Wandthermostat
Number temp_set "Thermostat" [ "TargetTemperature" ] {channel="homematic:HM-TC-IT-WM-W-EU:0a924f93:MEQ0743206:2#SET_TEMPERATURE", autoupdate="false"}

(Angelos) #25

correct


(Max) #26

ok, i try it, but it will take until monday :wink:


(Max) #27

hey again!
it didn’t work as well…

i said “15”, 14 is received, (12 is the previous value) my rule changed it to 15, but at the end again to 14…

18:36:27.116 [INFO ] [.eclipse.smarthome.model.script.Test] - Test Log Entry triggered by thermo command
18:36:27.215 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'temp_set' received command 14
18:36:27.218 [INFO ] [marthome.event.ItemStateChangedEvent] - temp_set changed from 12.00 to 15
18:36:27.232 [INFO ] [marthome.event.ItemStateChangedEvent] - temp_set changed from 15 to 14.00

this is the .items:
Number temp_set "Thermostat" [ "TargetTemperature" ] {channel="homematic:HM-TC-IT-WM-W-EU:ff0a6a69:MEQ0743206:2#SET_TEMPERATURE", autoupdate="false"}

and this is .rules:
import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import org.java.math.*
import org.joda.time.*

rule "Thermo"
when
Item temp_set received command
then
Thread::sleep(30)
temp_set.postUpdate((receivedCommand as Number) + 1)
logInfo("Test", "Test Log Entry triggered by thermo command")
end