Silas

Moderator: leecollings
Code: Select all
2015-11-11 19:31:09.043 (1-Wire) RFXMeter (Total Energi)
2015-11-11 19:31:09.271 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_counter_vp.lua
2015-11-11 19:31:09.138 (1-Wire) RFXMeter (VP Energi)
2015-11-11 19:31:09.332 (1-Wire) RFXMeter (Total Energi)
2015-11-11 19:31:09.610 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_counter_vp.lua
2015-11-11 19:31:09.502 (1-Wire) RFXMeter (VP Energi)
Code: Select all
--Domoticz Script to get medium actual energy between energy counter readings and puts it on a dummy device
--First create a dummy energy meter and two user variables as numbers.
--Then enter the details below
--Name of the real energy counter
energyCounter = 'VP Energi'
newValue = tonumber(otherdevices_svalues[energyCounter]) * 10
--ID of the created dummy energy meter with the new actual value
dummyEnergyMeterid = 65
hour = 3600
--The names of two user variables to keep track of previous value due to wrong values from dummy in otherdevices_lastupdate and other$
userVariableTimestamp = 'LastEnergyTimestamp'
userVariableLastCount = 'LastEnergyCount'
commandArray = {}
if devicechanged[energyCounter] then
--calculate new actual value
actual = ((newValue) - tonumber(uservariables[userVariableLastCount])) * hour / ((os.time()-uservariables[userVariableTimesta$
--update dummy energy meter
commandArray[1] = {['UpdateDevice'] = dummyEnergyMeterid .. "|0|" .. actual .. ";" .. newValue}
--update user variables
commandArray[2] = {['Variable:'..userVariableTimestamp] = tostring(os.time())}
commandArray[3] = {['Variable:'..userVariableLastCount] = tostring(newValue)}
-- print("DummyEnergy: " .. actual .. " W, " .. newValue .. " kWh")
function sleep(n)
n = 1
os.execute("sleep " .. tonumber(n))
end
end
return commandArray
Users browsing this forum: No registered users and 1 guest