Hello everyone ,
I would need a little help to create a virtual device.
This virtual device will display the calculation result of the efficiency of a controlled mechanical ventilation double flow .
This is a calculation device with temperatures of a universal sensor of fibaro .
The calculation is ((supply_temp - outside_temp)/(dirty_temp - outside_temp))*200
The solution :
Creat a device with a % for the unit (I have choose Humidity sensor)
Go to Apps → Develop apps → Create device
and put
Device type = urn:schemas-micasaverde-com:device:HumiditySensor:1
Description = VMC efficiency
Upnp Device Filename = D_HumiditySensor1.xml
Reload engin
Now, you can watch your new device
Clic on the arrow at the right of the device and go to advanced
Remember the ID number
Go to the scene creator
and creat a scene like the picture i add
In the “Also, execute the following Luup code:” section, put this code
[code]-- VMC efficiency calculation
local ID = {
Outside = 21, – the new outside air
Supply = 20, – the new supply air
Dirty = 22, – the dirty indoor air
Result = 23, – PICK YOUR OUTPUT DEVICE ID HERE
}
local SID = {
temperature = “urn:upnp-org:serviceId:TemperatureSensor1”,
efficiency = “urn:micasaverde-com:serviceId:HumiditySensor1”,
}
local function get_temp (id)
local t = luup.variable_get (SID.temperature,“CurrentTemperature”,id)
return t
end
local outside_temp = get_temp (ID.Outside)
local supply_temp = get_temp (ID.Supply)
local dirty_temp = get_temp (ID.Dirty)
if dirty_temp > outside_temp then
local VMC_efficiency = ((supply_temp - outside_temp)/(dirty_temp - outside_temp))*200
local round = “%0.0f”
VMC_efficiency = round:format (VMC_efficiency)
luup.variable_set (SID.efficiency, “CurrentLevel”, VMC_efficiency, ID.Result)
end[/code]
Change the 20,21,22 and 23 with your ID
Be carful, the dirty temp must be > at the outside temp to work