Latest beta domoticz
LUA script
Problem:
After my switch turns on, i want to check if it uses power (otherwise my device is defect)
Problem is that when i put on the device it takes 15 seconds for the powerusage is available, so i need kind of sleep function.
i get print 07c with value 0.0 en when the script is finished it does give a value with print 07a! larger timer does not help...
I tried one, it does pause but it looks like the the powerconsumption cant be read during this lua
Code: Select all
local switchlint = 'warmtelint' -- schakelaar die bij onderschreiding temperatuur aangezet wordt
local switchverbruik = 'Verbruikwarmtelint' -- schakelaar die bij onderschreiding temperatuur aangezet wordt
local curwatlimit = 1 -- minimale onderwaarde temperatuur
local wacht=2000
function round2(num, numDecimalPlaces)
return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
end
commandArray = {}
curwat = otherdevices_svalues["Verbruikwarmtelint"]
print ('07a Stroomlintverbruik heeft waarde' .. curwat .. '/')
curwat=0
if devicechanged[switchlint] == 'On' then
i = 1
while i <= wacht do
ping_success=os.execute('ping -c1 -w 1 192.168.20.1')
--print ('teller:'..tostring(i)..'')
i = i + 1
end
curwat = otherdevices_svalues["Verbruikwarmtelint"]
if tonumber(curwat) > tonumber(curwatlimit) then -- lint gebruikt stroom, dus werkt
print ('07b Stroomlint werkt. Verbruikt ' .. curwat)
else
print ('07c Stroomlint werkt niet. Verbruikt ' .. curwat)
end
end
return commandArray