openHAB gauge for car fuel tank status

I need a gauge style widget that shows the percentage of fuel left in the tank. The item delivers a number between 0 and 1 and I wanted to display a percentage number between 0 and 100. Here is the functioning code that modifies an item value in the valueText component.

component: oh-gauge-card
config:
  action: navigate
  actionPage: page:cars
  actionPageTransition: f7-dive
  borderColor: =(items.myCar_FuelLevel.state<0.26)?"orange":"red"
  item: myCar_FuelLevel
  max: 1
  min: 0
  title: My car
  type: semicircle
  valueText: =(items.myCar_FuelLevel.state*100) + " %"
  valueTextColor: white
slots: null

renders to:

It might be more interesting to show the remaining mileage in the text though:

component: oh-gauge-card
config:
  action: navigate
  actionPage: page:cars
  actionPageTransition: f7-dive
  borderColor: =(items.myCar_FuelLevel.state<0.26)?"orange":"red"
  item: myCar_FuelLevel
  max: 1
  min: 0
  title: My car
  type: semicircle
  valueText: =(items.MyCar_DistanceLeft.state)
  valueTextColor: white
slots: null

which renders to:

Leave a Reply