One approach is to set up a rule triggered by the value item.
I assume this documentation link might help you, it also takes tresholds into consideration
I´m not sure how to interpret your use case, so let me give an example.
“itemA” is the sensor item, so “itemA.state” is its value
“threshold” is the fixed threshold value. Could be an item or, like here, a fixed value
“test_switch” is a light bulb
In my mind, the switch needed to go ON and OFF, if being above/below “threshold”.
You could set up a rule, triggered by “itemA changed”. Advantage is that in this rule you could also switch the bulb OFF.
In the rule, let´s say in ECMAscript 11, I´d write something like this (just typed in, didn´t test)
var threshold=123
console.log("itemA="+itemA.state)
if (itemA.rawState >= threshold){
console.log("Bulb on")
items.test_switch.sendCommand("ON")
} else {
console.log("Bulb off")
items.test_switch.sendCommand("OFF")
}
Later, a hysteresis might be worth to be implemented to avoid switching on and off around the threshold. E.g., like this
Thanks for your answer, I think I should show you my case in this way. I defined a switch for dusk, which I set to a static value of 179 Lux. This means, if brightness falls to a value of 179 or below, the switch changes its status to ON.
What I want now is to set a dynamic value with an setpoint-item (daemmerungsschwelle) that I can control without changing the rule itself. I’ve tried several approches, but I can’t get this work.
Maybe worth to mention that a new item (type number) is necessary, which should e.g be placed on a page with a “Knob & Rounded Slider” cell. So at least here you can adhust the item value to later compare it.
My example in Post#5 illustrates the current functionality. However, as I mentioned, I intend to use a setpoint item to manage the threshold for when the item ‘switch_daemmerung’ should switch to ON. In this case, I’ll require a Knob & Rounded Slider. Couldn’t it be considered an event when a value falls below a certain level?
@Oliver2: I’m not sure what you mean. It appears I may have been too vague; however, the rule I created is functioning as intended.
In order to to use a setpoint-item I think it might work if you selected in “But only if condition” an inline script instead of item. This way you can replace the setpoint value by an item state
I am not a DSL expert, maybe set brackets to make sure comparison works right:
(fiktive_helligkeit.state as Number) <= (daemmerungsschwelle_lichter.state as Number)
Furthermore, could you log out
(fiktive_helligkeit.state as Number).toString()
and
(daemmerungsschwelle_lichter.state as Number).toString()
so that we can see the result (UoM, etc)