Det enda man skulle kunna tjäna på det är om bilen inte hunnit kylts ned till utetemperatur. Alltså om man två timmar tidigare kört bilen och den inte behöver värmas i x timmar till för att bli varm. Annars så kan man lika gärna använda sig av utomhustemperaturen.nylund skrev:Hej!
Någon som testat att montera en trådlös stektermometer mot motorblocket eller i en kylarslang för att mäta motortempen och därigenom kunna avgöra hur länge motorvärmaren behöver vara inkopplad?
Tex. http://www.kjell.com/se/sortiment/hus-h ... ter-p48659
Mvh/Nylund
Kod: Markera allt
return {
on = {
timer = { 'every minute' },
httpResponses = {
'avresetid'
}
},
data = {
timeroffmotorv = { initial = 120 }, -- maximal tid vid manuell start
},
execute = function(domoticz, item)
local motorv = "Daniel_Motorv" --Namnet på brytaren
local UteLudvika = domoticz.devices('UteLudvika') --Namnet på temperaturgivaren indom parantes
local maxtid = 130 --Langsta tiden motorvarmare kan ga till avresea (om man ej har ordnat sina kurvor ordentligt
if (item.isTimer) then
if (domoticz.devices(motorv).state == 'Off') then
domoticz.openURL({
url = 'http://192.168.1.46:8060/json.htm?idx=14&type=timers', -- byt ip och idx=14 mot ditt ip och din dummy switch idx
method = 'GET',
callback = 'avresetid',
})
end
if(domoticz.devices(motorv).lastUpdate.minutesAgo >= domoticz.data.timeroffmotorv and domoticz.devices(motorv).state == 'On') then
domoticz.devices(motorv).switchOff()
domoticz.data.initialize('timeroffmotorv')
end
end
if (item.isHTTPResponse and item.ok and item.json.result ~= nil) then
local Time = require('Time')
local currentTime = Time()
local day = tonumber(os.date("%w"))
local past = Time( os.date("%Y-%m-%d %H:%M:%S", os.time() - 1*24*3600))
local init_tid = Time( os.date("%Y-%m-%d %H:%M:%S", os.time() + 7*24*3600 ))
local nuavresetid = Time( os.date("%Y-%m-%d %H:%M:%S", os.time() + 7*24*3600 ))
local i = 1
while item.json.result[i]
do
if (item.json.result[i]['Active'] == "true") then
if (item.json.result[i]['Days'] == 0) then
nuavresetid = Time(item.json.result[i]['Date'] .. " " .. item.json.result[i]['Time'] .. ":00")
end
if (item.json.result[i]['Days'] == 256 and day >= 1 and day <= 5) then
nuavresetid = Time(domoticz.time.rawDate .. " " .. item.json.result[i]['Time'] .. ":00")
--print(day)
end
if(currentTime.compare(nuavresetid).minutes <= currentTime.compare(init_tid).minutes and past.compare(currentTime).minutes < past.compare(nuavresetid).minutes) then
init_tid = nuavresetid
end
--print(currentTime.compare(init_tid).minutes)
--print(currentTime.compare(nuavresetid).minutes)
end
i=i+1
end
--print(UteLudvika.temperature)
local omtemp = 11 - UteLudvika.temperature
local x_plus = 0.0044*omtemp^3+0.3377*omtemp^2-1.1128*omtemp+21.496
local x_min = 0.0045*omtemp^3-0.4306*omtemp^2+15.086*omtemp-64.824
local onfor = currentTime.compare(init_tid).minutes + 20 -- +25 är tiden som den är igång efter avresetid
--print ("om plus: " .. x_plus .. " minus_temp: " .. x_min .. " omtemp: " .. omtemp)
if (UteLudvika.temperature <= 10 and UteLudvika.temperature > 0 and x_plus >= currentTime.compare(init_tid).minutes) then
domoticz.devices(motorv).switchOn()
domoticz.data.timeroffmotorv = onfor
--print("Temp: " .. UteLudvika.temperature .. " Startar nu igång: " .. onfor)
end
if (UteLudvika.temperature <= 0 and x_min >= currentTime.compare(init_tid).minutes and currentTime.compare(init_tid).minutes < maxtid) then
domoticz.devices(motorv).switchOn()
domoticz.data.timeroffmotorv = onfor
end
--print(domoticz.data.timeroffmotorv)
--print(domoticz.devices(motorv).lastUpdate.minutesAgo)
end
end
}
dapersson skrev: ↑24 sep 2020, 20:35 Var tvungen att uppdatera raspbian och då även domoticz, snubblade då över lite nyheter så jag gjorde om skriptet lite från första inlägget.
Största förändringen är att man i sin dummy switch ställer timern på avresetid istället så slipper man räkna tillbaka tiden och hur lång tid brytaren är igång beror nu på temperaturkurvorna som jag moddat lite efter egen smak.
T.ex avresetid 07:00, temp +8 så startar den ca 06:39 och stängs av 07:25
avresetid 07:00, temp -4, startar 05:41 och slås av 07:25
Ej i ett lua skript utan använde dzvents
Domoticz - Setup - More Options - Events
Tänk på loggningen, rekommenderar när ni fått den att fungera att gå in i Setup - Settings -Other - dzVents: log level errors only
OBS! Har bara lagt in stöd för timer typ <On Time - weekdays> och <Fixed Date/Time> då det är de jag använder, vill ni använda något annat så måste ni göra ett json anrop med det valet och se skillnaderna på svaret och lägga in några rader kod.
Lycka till kopiera, modda gör vad ni önskar. Dela gärna med er till andra.
Kod: Markera allt
return { on = { timer = { 'every minute' }, httpResponses = { 'avresetid' } }, data = { timeroffmotorv = { initial = 120 } -- maximal tid vid manuell start }, execute = function(domoticz, item) if (item.isTimer) then domoticz.openURL({ url = 'http://192.168.1.46:8060/json.htm?idx=14&type=timers', -- byt ip och idx=14 mot ditt ip och din dummy switch idx method = 'GET', callback = 'avresetid', }) end if (item.isHTTPResponse and item.ok) then local motorv = "Daniel_motorv" --Namnet på brytaren local UteLudvika = domoticz.devices('UteLudvika') --Namnet på temperaturgivaren indom parantes local Time = require('Time') local currentTime = Time() local day = tonumber(os.date("%w")) local past = Time( os.date("%Y-%m-%d %H:%M:%S", os.time() - 1*24*3600)) local init_tid = Time( os.date("%Y-%m-%d %H:%M:%S", os.time() + 7*24*3600 )) local nuavresetid = Time( os.date("%Y-%m-%d %H:%M:%S", os.time() + 7*24*3600 )) local i = 1 while item.json.result[i] do if (item.json.result[i]['Active'] == "true") then if (item.json.result[i]['Days'] == 0) then nuavresetid = Time(item.json.result[i]['Date'] .. " " .. item.json.result[i]['Time'] .. ":00") end if (item.json.result[i]['Days'] == 256 and day >= 1 and day <= 5) then nuavresetid = Time(domoticz.time.rawDate .. " " .. item.json.result[i]['Time'] .. ":00") --print(day) end if(currentTime.compare(nuavresetid).minutes <= currentTime.compare(init_tid).minutes and past.compare(currentTime).minutes < past.compare(nuavresetid).minutes) then init_tid = nuavresetid end --print(currentTime.compare(init_tid).minutes) --print(currentTime.compare(nuavresetid).minutes) end i=i+1 end --print(UteLudvika.temperature) local omtemp = 11 - UteLudvika.temperature local x_plus = 0.0044*omtemp^3+0.3377*omtemp^2-1.1128*omtemp+21.496 local x_min = 0.0045*omtemp^3-0.4306*omtemp^2+15.086*omtemp-64.824 local onfor_plus = x_plus + 25 -- +25 är tiden som den är igång efter avresetid local onfor_min = x_min + 25 -- +25 är tiden som den är igång efter avresetid --print ("om plus: " .. x_plus .. " minus_temp: " .. x_min .. " omtemp: " .. omtemp) if (domoticz.devices(motorv).state == 'Off' and UteLudvika.temperature <= 10 and UteLudvika.temperature > 0 and x_plus >= currentTime.compare(init_tid).minutes) then domoticz.devices(motorv).switchOn() domoticz.data.timeroffmotorv = onfor_plus end if (domoticz.devices(motorv).state == 'Off' and UteLudvika.temperature <= 0 and x_min >= currentTime.compare(init_tid).minutes) then domoticz.devices(motorv).switchOn() domoticz.data.timeroffmotorv = onfor_min end if(domoticz.devices(motorv).lastUpdate.minutesAgo >= domoticz.data.timeroffmotorv and domoticz.devices(motorv).state == 'On' and currentTime.compare(init_tid).minutes >= 20) then domoticz.devices(motorv).switchOff() domoticz.data.initialize('timeroffmotorv') end --print(domoticz.data.timeroffmotorv) --print(domoticz.devices(motorv).lastUpdate.minutesAgo) end end }
Okej, tackar för svar!dapersson skrev: ↑25 sep 2020, 15:03 Hej TheeDude
Jodå det ska fungera, vad jag menade med fixed date och on time är när man skapar en ny timer så finns det en massa alternativ som on sunrise m.m. I skriptet så tittar jag efter vad det står på Days:
Står det 256 där så tar skriptet och tittar vilken veckodag det är och är det en vardag så tar den avresetiden.
Står det 0 så finns det även ett datum så då tar jag datumet och tiden.
Sen loopar den igenom alla "timers" för att hitta vilken som är närmast aktuell tid och till slut tittar om det är dags att starta motorvärmaren.
Ekvationerna som jag använder går vid -20 grader i 123min och vid -30 i 140minuter osv. så du måste kanske se över kurvorna så de passar dig. Vet att du ville ha betydligt längre tid igång.
Sen såg jag i ditt inlägg att det skiljer 4 timmar mellan avresorna vilket i teorin kan bli ett litet problem om det är väldigt kallt och värmaren varit igång i nästan 4 timmar. Tänkte på det förut och gjorde en "fuling". Skulle egentligen behöva göra om det lite och sätta ännu en global variabel att den startats och att den slagit av sig och ändra lite till. Som det är nu kan du få problem om ni delar skriptet med fler "bilar" och tiderna går i varandra.
Ska fundera lite på saken.
"result" :
[
{
"Active" : "true",
"Cmd" : 0,
"Color" : "",
"Date" : "",
"Days" : 256, märkte att det står 256 om man väljer on time weekdays
"Level" : 100,
"MDay" : 0,
"Month" : 0,
"Occurence" : 0,
"Randomness" : "false",
"Time" : "07:05",
"Type" : 2,
"idx" : "1"
},
{
"Active" : "true",
"Cmd" : 0,
"Color" : "",
"Date" : "2020-09-26",
"Days" : 0, 0 om det är specifik dag och tid tar då det datumet och tiden
"Level" : 100,
"MDay" : 0,
"Month" : 0,
"Occurence" : 0,
"Randomness" : "false",
"Time" : "10:00",
"Type" : 5,
"idx" : "2"
}
],
"status" : "OK",
"title" : "Timers"
}
Kod: Markera allt
if (domoticz.devices(motorv).state == 'Off' and UteLudvika.temperature <= 20 and UteLudvika.temperature > 0 and x_plus >= currentTime.compare(init_tid).minutes) then
Kod: Markera allt
function timedifference(s)
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = os.difftime (t1, t2)
return difference
end
commandArray = {}
if (otherdevices['Timer Motorvärmare Jonas'] == 'On' and otherdevices['Motorvärmare Jonas'] == 'Off') then
sWeatherTemp = otherdevices_svalues['Utomhus']:match("([^;]+)")
sWeatherTemp = tonumber(sWeatherTemp);
difference = timedifference(otherdevices_lastupdate['Timer Motorvärmare Jonas'])
if (sWeatherTemp < -25) then
commandArray['Motorvärmare Jonas']='On'
commandArray['Timer Motorvärmare Jonas']='Off'
end
omtemp = 11 - sWeatherTemp
x_plus = 0.0044*omtemp^3+0.3377*omtemp^2-1.1128*omtemp+21.496
x_plus = (240-x_plus) * 60
x_min = -0.2024*omtemp^2+11.821*omtemp-50.548
x_min = (240-x_min) * 60
if (difference < 60) then
if (sWeatherTemp <= 0) then
tempprint = "Jonas motorvärmare beraknas starta om: " .. (x_min - difference)/60 .. "min"
print(tempprint)
end
if (sWeatherTemp > 0) then
tempprint = "Jonas motorvärmare beraknas starta om: " .. (x_plus - difference)/60 .. "min"
print(tempprint)
end
end
if (sWeatherTemp < 10 and sWeatherTemp > 0 and difference > x_plus) then
commandArray['Motorvärmare Jonas']='On'
commandArray['Timer Motorvärmare Jonas']='Off'
end
if (sWeatherTemp <= 0 and sWeatherTemp >= -24 and difference > x_min) then
commandArray['Motorvärmare Jonas']='On'
commandArray['Timer Motorvärmare Jonas']='Off'
end
else if (otherdevices['Motorvärmare Jonas'] == 'On') then
difference = timedifference(otherdevices_lastupdate['Motorvärmare Jonas'])
if (difference > (300 * 60)) then
commandArray['Motorvärmare Jonas']='Off'
end
end
end
return commandArray
Kod: Markera allt
local x_plus = 0.0044*omtemp^3+0.3377*omtemp^2-1.1128*omtemp+21.496
20 55,6573
19 49,7584
18 44,3237
17 39,3796
16 34,9525
15 31,0688
14 27,7549
13 25,0372
12 22,9421
11 21,496
10 20,7253
9 20,6564
8 21,3157
7 22,7296
6 24,9245
5 27,9268
4 31,7629
3 36,4592
2 42,0421
1 48,538
0 55,9733 55,0089
local x_min = 0.0045*omtemp^3-0.4306*omtemp^2+15.086*omtemp-64.824
-1 61,9776
-2 68,4091
-3 74,3304
-4 79,7685
-5 84,7504
-6 89,3031
-7 93,4536
-8 97,2289
-9 100,656
-10 103,7619
-11 106,5736
-12 109,1181
-13 111,4224
-14 113,5135
-15 115,4184
-16 117,1641
-17 118,7776
-18 120,2859
-19 121,716
-20 123,0949
-21 124,4496
-22 125,8071
-23 127,1944
-24 128,6385
-25 130,1664
-26 131,8051
-27 133,5816
-28 135,5229
-29 137,656
-30 140,0079
-31 142,6056
-32 145,4761
Kod: Markera allt
-1 63,016
-2 70,8342
-3 78,4716
-4 85,933
-5 93,2232
-6 100,347
-7 107,3092
-8 114,1146
-9 120,768
-10 127,2742
-11 133,638
-12 139,8642
-13 145,9576
-14 151,923
-15 157,7652
-16 163,489
-17 169,0992
-18 174,6006
-19 179,998
-20 185,2962
-21 190,5
-22 195,6142
-23 200,6436
-24 205,593
-25 210,4672
-26 215,271
-27 220,0092
-28 224,6866
-29 229,308
-30 233,8782
-31 238,402
-32 242,8842
Kod: Markera allt
return {
on = {
timer = { 'every minute' },
httpResponses = {
'avresetid' <------byt ut
}
},
data = {
timeroffmotorv = { initial = 120 }, -- maximal tid vid manuell start
},
execute = function(domoticz, item)
if (item.isTimer) then
domoticz.openURL({
url = 'http://192.168.1.46:8060/json.htm?idx=14&type=timers', -- byt ip och idx=14 mot ditt ip och din dummy switch idx
method = 'GET',
callback = 'avresetid', <----byt ut
})
end
Det var märkligt har fungerat här i alla fall. Tog du den senaste varianten? Jag gjorde några ändringar för länge sedan. Skrev i inlägget någon gång tidigare att jag gjort det men ifall du kopierade koden direkt så kanske du har en gammal variant.TheeDude skrev: ↑09 okt 2020, 01:41 Nu är det testat..
Det verkar fungera bra, förutom en sak, och det fanns vid första testet också.
Timerbrytaren startade 16:30 och avslutade 17:00.
Motorvärmaren startade två gånger, se bild, förstår inte riktigt vart den andra starten kommer ifrån..
Det är egentligen inget problem, då jag ska ha lämnat huset vid den tidpunkten, men ändå!
domoticz.png
Kod: Markera allt
timeroffmotorv = { initial = 120 }, -- maximal tid vid manuell start
Kod: Markera allt
domoticz.data.timeroffmotorv = onfor
--print("Temp: " .. UteLudvika.temperature .. " Startar nu igång: " .. onfor)
end
if (domoticz.devices(motorv).state == 'Off' and UteLudvika.temperature <= 0 and x_min >= currentTime.compare(init_tid).minutes and currentTime.compare(init_tid).minutes < maxtid) then
domoticz.devices(motorv).switchOn()
domoticz.data.timeroffmotorv = onfor
end
if(domoticz.devices(motorv).lastUpdate.minutesAgo >= domoticz.data.timeroffmotorv and domoticz.devices(motorv).state == 'On') then
domoticz.devices(motorv).switchOff()
domoticz.data.initialize('timeroffmotorv')
end
--print(domoticz.data.timeroffmotorv)
--print(domoticz.devices(motorv).lastUpdate.minutesAgo)
end
end
}
Kod: Markera allt
Så om du vill att den ska gå längre så kanske
local x_min = 0,0008*omtemp^3-0,1216*omtemp^2+10,483*omtemp-46,652
blir då
Kod: Markera allt
2020-11-10 02:37:00.894 Status: dzVents: om plus: 90.926649297385 minus_temp: 0 omtemp: 14.599999904633
Kod: Markera allt
local x_min = 0.0008*omtemp^3-0.1216*omtemp^2+10.483*omtemp-46.652