hobaka
(hobaka)
July 12, 2023, 10:58am
1
Platform information:
*raspi 4b, OH 3.41 in Docker
Would like to run a rule if a temperature value is reached; However, all attempts have so far been unsuccessful;
SYS_WEA_TMP = item type Number:Temperature
UI-CODE:
configuration: {}
triggers:
id: “2”
configuration:
itemName: SYS_WEA_TMP
type: core.ItemStateUpdateTrigger
conditions:
inputs: {}
id: “3”
configuration:
itemName: SYS_WEA_TMP
state: “28.5”
operator: =
type: core.ItemStateCondition
or
conditions:
inputs: {}
id: “3”
configuration:
itemName: SYS_WEA_TMP
state: 28.5 C°
operator: =
type: core.ItemStateCondition
rlkoshak
(Rich Koshak)
July 12, 2023, 1:13pm
2
First, “unsuccessful” could mean almost anything. Please describe what’s happening. Does the rule not run? Does it run but do the wrong thing?
If you are dealing with floating point numbers you will almost never have a case where the value is exactly 28.5. It might be 28.49999999999897 or it might be 28.5000000000000012, neither of which is exactly 28.5.
You don’t show what you want to do when this temperature is reached so it’s impossible to say exactly how you should proceed. The most common approach is to use operator >= 28.5 and in the action or additional conditions test to see whether you need to do something or not (e.g. if the action is to turn off a Switch, check to see if it’s already OFF and only command it if it’s not OFF).
apella12
(Bob Eckhoff)
July 12, 2023, 1:52pm
3
I don’t know if this is the case here, but comparing temperatures can be tricky. See this;
Working with Number:Temperature Items in rules - Tutorials & Examples - openHAB Community
In my DSL rule I have to use this
var upsetpointnow = (UpstairsThermostat21_SetpointCooling.state as QuantityType<Temperature>).toUnit("°F")
to compare setpoints
rlkoshak
(Rich Koshak)
July 12, 2023, 2:23pm
4
That isn’t an issue here. In the UI rules you’ll get a warning in the logs if you don’t add units to your number but it will still work.
1 Like
hobaka
(hobaka)
July 14, 2023, 6:11am
5
Dear, thank you very much for helping.
Yes, I would check within the rules about other conditions. And I change the operator to >= 28.5; so the rule works fine …
but now I get some warnings - if I write value as >= 28.5 C°, so no warnings, but the rule does not start… Why?
configuration: {}
triggers:
- id: "2"
configuration:
itemName: SYS_WEA_TMP
type: core.ItemStateChangeTrigger
conditions:
- inputs: {}
id: "3"
configuration:
itemName: SYS_WEA_TMP
state: "28"
operator: ">="
type: core.ItemStateCondition
- inputs: {}
id: "5"
configuration:
itemName: WDW_ROO_ROOF
state: OPEN
operator: =
type: core.ItemStateCondition
actions:
- inputs: {}
id: "4"
label: RWA-Dachfenster bei hohen Temperaturen nach Lüften schließen
configuration:
type: application/javascript;version=ECMAScript-2021
script: >-
//WDW_MGT_ROOF_CLOSED: RWA-Dachflächenfenster schließen
//Bedingungen: bei Dachflächen-Temperatur >= 28 Grad
hobaka
(hobaka)
September 4, 2023, 3:25pm
7
I found the error.
not 28,5 C° >> right is: 28,5 °C