Hi,
I’m new to HA, I have been using Domoticz, but I maybe switch to HA if I’m geting everything working.
At the moment I’m having the problem to get my oil tank info into HA. For that I had a lua program in Domoticz (see below) but I have no idea how to do that in HA…
I’m have the sensors in HA
sensor.nodemcu_ds18b20_temperature
sensor.nodemcu_sr04_distance
but I do not know where and how to make the calculation and display this in HA.
Maybe someone can help or point me in the right direction.
Kind regards
chriwo
in Domoticz I had this:
– Input devices: Temperature and level index of Domoticz devices
– Temp and Distance of NodeMCU DS18B20 and distances
temp_idx = 15
temp_name = ‘oil tank temperature’
depth_idx = 16
depth_name = ‘oil tank dictance’
– Output devices: In percent and liters index of virtual device in Domoticz virtual
pct_sensor_idx = 17
volume_sensor_idx = 18
– liquid expansion
– reference temperature 15°C
ref_temp = 15
– Heizöl Flüssigkeitsausdehnung 8,4 l pro 1.000 l
expansion_coeff = 1.00084
– tank dimensions
tank_height = 148
tank_area = 147 * 197
commandArray = {}
if (devicechanged[depth_name]) then
-- Get the current distance to oil
depth = otherdevices_svalues[depth_name]
-- Calculate percentage and volume
pct = (tank_height - depth) / tank_height * 100
volume = (tank_height - depth) * tank_area / 1000
-- Calculate the liquid expansion
tank_temp = otherdevices_svalues[temp_name]
if (tank_temp ~= nil) then
temp_delta = tank_temp - ref_temp
scale = math.pow(expansion_coeff, temp_delta)
pct = pct * scale
volume = volume * scale
end
commandArray[1] = {['UpdateDevice'] = pct_sensor_idx .. "|0|" .. math.ceil(pct)}
commandArray[2] = {['UpdateDevice'] = volume_sensor_idx .. "|0|" .. math.ceil(volume)}
end
return commandArray