I have a simple rule to set a switch ON/OFF depending on a number value, but it seems to be giving the opposite result. The rule takes a value from an Number item
Number OS_Oil_Battery “Gauge” (OS) {channel=“mqtt:topic:61db7b94:B1”}
And if the item has a value 128 should turn a switch item ON, if its anything else, turn it OFF.
The rule is:
rule "Oil Battery"
when
Item OS_Oil_Battery changed
then
if (OS_Oil_Battery == 128) {
sendCommand(OS_Oil_Battery_State, "ON")
} else {
sendCommand(OS_Oil_Battery_State, "OFF")
}
end
But when Oil_Battery gets set to 128, the rule sends OFF command, i must be missing something obvious, but i cannot fathom it out.
Heres the log for the Oil_Battery state change.
2021-01-15 14:57:45.689 [vent.ItemStateChangedEvent] - OS_Oil_Battery changed from NULL to 128
2021-01-15 14:57:45.695 [ome.event.ItemCommandEvent] - Item 'OS_Oil_Battery_State' received command OFF
2021-01-15 14:57:45.700 [vent.ItemStateChangedEvent] - OS_Oil_Battery_State changed from NULL to OFF
Thanks, i did see the note about using code tags, but there is no message as to what they are!! tried using the ``` but only seems to be a start tag, how do i close them?
Thanks Steffen i’ll look into profiles, in my particular case i believe that a value of 128 is a good battery state, and anything else is ‘bad’ i don’t have manufacturer documentation to go on just comments from other people that have used this Oil tank gauge. So i am not sure if a bad value will be lower or higher than 128 (i suspect it will be lower).
In this case, you can also have a look on the transform binding SCALE. That will offer all options you need. And also here, you don’t have to create extra rules. All can be defined within the item definition.