Skip to content
Stand with Ukraine flag

Tank days to empty

  • Widget
  • 2 installs
  • v1.0.0
  • Sep 21, 2026
  • MIT license
  • v4.2+
Tank days to empty

A level reading says where the tank is; it never says when to order. This card draws the tank filled to where it stands now, measures how fast it is falling since the last refill, and writes the dates up its wall at the heights the level is forecast to reach on each of them, down to the reorder level you set. Beside it are the days left, colored by how soon they run out, and the date to refill by. Deliveries are detected and the fit restarts, so topping up never flatters the forecast.

Widget Type
  • Timeseries
Category
  • Cards & Info
  • Charts & Graphs
  • Gauges & Indicators

Who it’s for

Anyone responsible for a tank that somebody else has to come and fill — diesel at a depot, water on a farm, a silo of feed, a dosing drum on a production line. They can already see the level on a dashboard. What they are actually asking is when to place the order, and whether it can wait for next week’s delivery run or has to go out today.

What it does

A diesel tank reads 62.0% and has been falling 12.0% a day since the last delivery. The card draws the tank filled to 62%, writes Tue, Wed, Thu and Sat up its wall at the heights the level reaches on each of those days, rules the 20% reorder level across it in red, and prints 3.5 days in amber over Refill by Thu 24 Sept.

  • Draws the tank as a tank, filled to where it stands now, so the state is read before any number is.
  • Writes the forecast dates up the wall of the tank, at the heights the level is expected to reach on each one. The step picks itself from how fast the tank is emptying, so one draining today is labeled in hours and one lasting a month is labeled in weeks.
  • Counts down to the reorder level rather than to an empty tank, because that is the moment somebody has to act, and prints the calendar date to refill by.
  • Detects deliveries and re-measures the rate from the last one. Fitting across a refill would average the drop and the top-up together and report a tank that never empties.
  • Keeps counting while the data is quiet. The days remaining are measured from now, not from the last reading, so a sensor that goes silent eats into the estimate instead of freezing it.
  • Colors the days remaining by how soon they run out and says Order now or Order soon, with the thresholds set to how long your deliveries take.
  • Prints the level, the consumption and the reorder level beside the tank, so the forecast can be checked rather than trusted.
  • Reads one tank on one key, and projects the current drawdown in a straight line. It does not model seasonality, a production schedule or a vessel that is meant to rise and fall.

How to set up

Data keys

The widget takes one key on one entity, and derives everything else from it.

  • Any numeric level keyTimeseries. The tank level, in whatever the sensor reports: percent, liters, centimeters or gallons. Decimals and units come from the key’s own configuration rather than from the widget. Until the key has values in the selected time window the card shows its no-data message, and with a single reading it draws the tank but reports that there is not enough to measure a rate yet.

The dashboard time window decides how much history the rate is measured over. Anything from a few hours to a few days works; what matters is that the window holds enough readings since the last delivery.

Forecast

  • Refill jump — empty by default, which means automatic. A rise this big, in the units of the data key, counts as a delivery and restarts the rate. Left empty, the widget takes the larger of 5% of the level range it can see and six times the typical step between two readings, so a noisy sensor is not mistaken for a delivery. Set it very high for a vessel that genuinely rises and falls, such as a buffer tank.

Reorder level

  • Reorder level from — a fixed number set here, by default. Choose a key on the same entity when the level differs per tank, or Nothing, count down to empty to count down to an empty tank.
  • Reorder level — 20 by default. The level that still leaves time for a delivery to arrive. Shown by the red rule across the tank, with everything below it shaded.
  • Key name — empty by default, and used only when the reorder level comes from a key. Both attributes and telemetry are read, so you do not have to say which it is; an attribute wins when the same name exists as both. While the key is empty or has never been written, the forecast counts down to empty. Not available on the simulated datasource, which has no entity.
  • Full level — empty by default. What a full tank reads, which is what the drawing needs and what a level series never carries: a tank that has not been full since it was installed has no reading to take it from. Left empty, a percentage reads as 100 and anything else takes the highest level in the time window rounded up to a round number.

How to customize

The picture and what sits beside it

  • To show the trend instead of the tank — set Picture to A trend chart (the tank is the default). The chart plots the readings since the last refill and carries the measured slope on as a dashed line, which is what shows whether the forecast rests on a steady draw or a line that wanders.
  • To leave only the days and the date — set Picture to Neither, for a small tile in a row of them.
  • To drop the three numbers — turn off Show the numbers, on by default. They hide themselves anyway once the card is too narrow for them.
  • To let the widget title name the tank — turn off Show the key label, on by default.
  • To keep the configured font sizes at any card size — turn off Scale to fit the card, on by default. Left on, the whole card grows and shrinks to fill whatever space the dashboard gives it.

Urgency

  • To match the warnings to your delivery time — set Critical, days left (2 by default) and Warning, days left (7 by default). The first turns the card critical and says to order now, the second says to order soon.
  • To change the alarm colorsCritical color, #D8536B by default, and Warning color, #C58A17. The critical color also draws the reorder level across the tank and the shading below it.

Dates, fonts and colors

  • To write the refill date differently, or not at allRefill date, Automatic by default, which adds the time of day only when the crossing is under two days out. The other choices are Day and month, Day, month and time, and Do not show it.
  • To recolor the liquidLevel color, #2D3A40 by default. It fills the tank and draws the line on the trend chart; the surface of the liquid is the same color lightened.
  • To resize or recolor the day countDays font and Days color. The color applies to the three numbers always, and to the days remaining whenever the tank is comfortable, filling or holding steady.
  • To restyle the supporting textLabel font and Label color, which also set the status text, the refill date, the numbers and the dates on the tank, each one step smaller.

Tips

  • Set Critical, days left to how long a delivery actually takes to arrive, not to how low you like the tank to get. That is the number that turns the card into an instruction.
  • Hold the reorder level as a server attribute on each device and point Key name at it. One dashboard then serves tanks of different sizes, and changing a contract changes the attribute rather than every widget.
  • For a tank measured in liters or gallons, set Full level to the nameplate capacity. Left automatic it is taken from the highest level seen in the window, which understates the tank until the day it is filled to the top.
  • Give the time window enough room to hold a full drawdown between deliveries. A one-hour window on a tank that is filled monthly measures the last hour of noise rather than the month’s consumption.
  • If the card says the level is rising while the tank is being drawn down, the sensor is probably reporting depth to the surface rather than depth of liquid. Invert it upstream, in a calculated field, and the forecast follows.

Share Your Widget with the Community

Built a custom widget? Export it as a JSON from ThingsBoard and publish it to the IoT Hub through a simple 4-step wizard (Upload, Listing, Readme, Review & Submit). Share it with thousands of ThingsBoard developers worldwide and get featured in the catalog.