{"id":1028,"date":"2024-05-09T23:06:27","date_gmt":"2024-05-09T21:06:27","guid":{"rendered":"https:\/\/www.homeserver.lu\/?p=1028"},"modified":"2024-05-10T13:12:04","modified_gmt":"2024-05-10T11:12:04","slug":"openhab-gauge-for-car-fuel-tank-status","status":"publish","type":"post","link":"https:\/\/www.homeserver.lu\/?p=1028","title":{"rendered":"openHAB gauge for car fuel tank status"},"content":{"rendered":"\n<p>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 <em>valueText<\/em> component.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>component: oh-gauge-card\nconfig:\n  action: navigate\n  actionPage: page:cars\n  actionPageTransition: f7-dive\n  borderColor: =(items.myCar_FuelLevel.state&lt;0.26)?&quot;orange&quot;:&quot;red&quot;\n  item: myCar_FuelLevel\n  max: 1\n  min: 0\n  title: My car\n  type: semicircle\n  valueText: =(items.myCar_FuelLevel.state*100) + &quot; %&quot;\n  valueTextColor: white\nslots: null<\/code><\/pre><\/div>\n\n\n\n<p>renders to:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"370\" height=\"308\" src=\"https:\/\/www.homeserver.lu\/wp-content\/uploads\/2024\/05\/MyCarPercentage.png\" alt=\"\" class=\"wp-image-1032\" style=\"width:235px;height:auto\" srcset=\"https:\/\/www.homeserver.lu\/wp-content\/uploads\/2024\/05\/MyCarPercentage.png 370w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2024\/05\/MyCarPercentage-300x250.png 300w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/><\/figure>\n<\/div>\n\n\n<p>It might be more interesting to show the remaining mileage in the text though:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>component: oh-gauge-card\nconfig:\n  action: navigate\n  actionPage: page:cars\n  actionPageTransition: f7-dive\n  borderColor: =(items.myCar_FuelLevel.state&lt;0.26)?&quot;orange&quot;:&quot;red&quot;\n  item: myCar_FuelLevel\n  max: 1\n  min: 0\n  title: My car\n  type: semicircle\n  valueText: =(items.MyCar_DistanceLeft.state)\n  valueTextColor: white\nslots: null<\/code><\/pre><\/div>\n\n\n\n<p>which renders to:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"368\" height=\"306\" src=\"https:\/\/www.homeserver.lu\/wp-content\/uploads\/2024\/05\/MyCarKm.png\" alt=\"\" class=\"wp-image-1031\" style=\"width:235px\" srcset=\"https:\/\/www.homeserver.lu\/wp-content\/uploads\/2024\/05\/MyCarKm.png 368w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2024\/05\/MyCarKm-300x249.png 300w\" sizes=\"auto, (max-width: 368px) 100vw, 368px\" \/><\/figure>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>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. renders to: It might [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[7],"tags":[],"class_list":["post-1028","post","type-post","status-publish","format-standard","hentry","category-openhab"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/posts\/1028","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1028"}],"version-history":[{"count":17,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/posts\/1028\/revisions"}],"predecessor-version":[{"id":1047,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/posts\/1028\/revisions\/1047"}],"wp:attachment":[{"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1028"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1028"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1028"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}