I have a helper that calculates the depth of oil in my tank. (Simply the air-gap from the tank sensor deducted from the tank height)
If HA is restarted and there is no value / unavailable for the tank air-gap sensor, then the calculation is incorrect and the value jumps up to the height of the tank.
Here is the code from the state template in the GUI:
{{ (states("input_number.oil_tank_height") | int(0) -states("sensor.oil_tank_gauge_depth") | int(0)) }}
How do I add a IF statement into this code in the GUI, to check that the sensor.oil_tank_gauge_depth is not unavailable before doing the calculation?
I tried following examples post on here, but they all seem aimed at YAML file configs, so the syntax is not quite right.