I am getting a reading in cm via MQTT from an Oil Tank sensor which i display in HA. However I am struggling to work out how to convert the value into litres and a bar graph. I have a spreadsheet with the value from 1 - 10 for the bar graph and the litres like this:
Thanks for the response. I have tried the above, but unfortunately the tank is not round so makes the calculation way out. However I was able to get the manufacturers data for the tank, and have worked out the exact litres from the height which I have in a spreadsheet. What I am trying to understand is how to use that information. So I know that at 68cm I have 602 litres according to my spreadsheet. I am trying to work out how to get that from the spreadsheet, and I thought I might be able to do it via a condition, ie if I have a reading of 68cm it would equal 602l. I can attach the spreadsheet if that makes it easier to understand. I don’t really want to use the spreadsheet but somehow create a condition or something that allows me to say that at 65cm it = xx litres and at 70cm it = xx litres etc.
Essentially The Depth is from the manufacturer I have converted this to CM and also Litres the last column (column D) is what the watchman oil guard I have displays, it shows a 1 to 10 and I have worked out what they would be in the spreadsheet as well. I guess what I am looking for is a way to add the litres. Note I am not doing any calculation of the temp so I am aware this will always be slightly incorrect. I wish I could do it via a PHP script but like I said the dimensions of the tank made it way to tricky for me to figure that out.
The details I used to figure out the tank details are from these two websites:
Sorry for making it so difficult. I’m sorry I don’t even know what a linear treadline is.
I put the code you suggested and get the following in the logs:
[homeassistant.components.template.sensor] Template sensor oil_tank_liters has no entity ids configured to track nor were we able to extract the entities to track from the value template(s). This entity will only be able to be updated manually.
The code I had originally to display the Oil Tank Depth in CM is:
- platform: mqtt
name: "Oil Tank Depth"
state_topic: "oiltank/level"
value_template: "{{ value_json.depth }}"
unit_of_measurement: cm
That is working correctly now as far as I can tell.
So am I correct in saying I cannot crate an actual gauge or bar graph graphically to display the oil tank bars without using lovelace which won’t work because of the value_template?
Thanks @petro, so my last question, am I right in saying that I cannot use value templates with lovelace based on what you said above? Which is why they don’t show?
I don’t know what you’d use a value template for? Lovelace is an opt in user interface. That means you have to place the items in the interface. If they aren’t showing up its probably because you didn’t configure them to show up.
name: "Oil Tank Bars"
state_topic: "oiltank/level"
value_template: "{{ value_json.depth | int // 14 + (value_json.depth | int % 14 != 0) | int }}"
unit_of_measurement: bar ```
I need to somehow configure them to show? Sorry I am new to this.
it should already be in your interface if you’ve never set it up. It will show up as an entity row and it will just show a value of 5. It will not look like a bar. For configuring the UI take a look at the lovelace documentation and watch the video and read the blurbs and play around with the test interface.