I have my Watchman Sonic Oil monitor sending to OpenHab via MQTT, that all works fine but I just get raw data, in this case depth which I believe is in cm’s
I am trying to convert this to litres but this is proving a bit more challenging than I initially thought.
The following script is exactly what I am trying to achieve but I can’t get it to work in OpenHAB
I just store the raw data, then I have a rule that calculates the percentage left when the depth changes - I don’t see why you couldn’t do some maths to work out the volume instead
val float height = 115 // height of the tank
rule "Oil Calc"
when
Item GF_Oil_Depth changed // this is the mqtt item that holds the depth from the sensor
then
val float depth = Float::parseFloat(GF_Oil_Depth.state.toString) as Number
val float left = height - depth
val float per = (left / height) * 100
GF_Oil_Remaining.sendCommand(per) // update the item that holds the percentage
end