Hi,
i want to make a rule, which can change the number of a number item.
My heatpump sometimes generates an alarm on a number item. With this number i can see, which alarm is active. But often there comes a false alarm number. The alarm item should be hidden in my sitemap, but it always shows up with this false number.
So i want to make another item where i can send alarm from first item - but if item will change to false number, it should keep old number.
If alarm-number item changes to number 16384 it should keep old value.
is: (item.state == xxx) correct for a number item?
rule "Alarmmeldung 16384 unterdrĂĽcken"
when
Item HeatPump_alarm changed
then
if (HeatPump_alarm.state == 16384)
HeatPump_alarm_rule.postUpdate(HeatPump_alarm.state -----xxxxx-----)
else
HeatPump_alarm_rule.postUpdate(HeatPump_alarm.state -----xxxxx-----)
end
If your goal is to just hide the Item in your sitemap and only show it if a “real” alarm happens, you could do without any rule and just use visibility.
//show item only on certain alarms
Number Item HeatPump_alarm label="We have an Alarm:" visibility=[HeatPump_alarm==1, HeatPump_alarm==2 ]
//show item if value is not 16384
Number Item HeatPump_alarm label="We have an Alarm:" visibility=[HeatPump_alarm!=16384]
you could use Olis solution, but your solution is not far from success, if i understand the problem right. Maybe you should change your if clause to something like that:
if (HeatPump_alarm.state != 16384) {
HeatPump_alarm_rule.postUpdate(HeatPump_alarm.state)
}
Maybe the HeatPump_alarm.state should be something like that HeatPump_alarm.state as DecimalType
@Dibbler42:
Thank you! That´s the answer. != instead of ==
@Oli:
I tried this before, but i want to hide the item in the sitemap if it has the value 0 or the value 16384 and you only can give one number to hide. With two numbers to hide it will not work. So my idea was to work with two number items.
I used this on several of my Items. However I can say it doesn’t work quite right in OH 2, I’m not sure if the problem is mine or not though. It might not work any longer, but if that is the case the wiki needs to be updated as it clearly states the above is valid.
Now I remember the problem. The conditionals are an OR, not an AND. So it comes along an asks “Is something other than zero? No, OK, is it something other than 16384? Yes, so visibility is true.”
It isn’t a limitation that you can have only one comparison, it is that state != 0 || state != 16384 will always be true.
I think this is a use case the visibility tag does not support.
“It is important to note, that it is not possible to decide visibility on more than one condition at the same time.”
If you need to decide visibility on more than one condition, you need to define another item (sometimes called virtual item because it will not be bound to a binding) being set in a rule, based on all conditions relevant.
For the record, since I’m procrastinating what I’m supposed to be doing:
Items
Number HeatPump_alarm <yada yada yada>
Switch HeatPump_visibility
Rule
rule "Update HeatPump_visibility"
when
HeatPump_alarm changed
then
val alarmNum = HeatPump_alarm.state as DecimalType
if(alarmNum == 0 || alarmNum == 16384) HeatPump_visibility.sendCommand(OFF)
else HeatPump_visibility.sendCommand(ON)
end
Sitemap
Text item=HeatPump_alarm visibility=[HeatPump_visibility==ON]