Hello,
trying to optimize and shorten programs here, but sometimes i'm out of ideas. Is it possible to shorten this script that raise up heating at 3 points in the week?
if heizpause == 'Heizen' then
print('Modus Bad aktualisieren')
if (t.matchesRule('at 04:45 on mon, tue, wed, thu, fri') or ('at 16:05 on mon, tue, wed, thu, fri') or ('at 06:30 on sat, sun')) then
spirit.updateMode('Heat')
end
end
Or Or Or optimized? [Solved]
Moderator: leecollings
- Solderbro
- Posts: 80
- Joined: Tuesday 18 September 2018 15:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.1
- Location: Hamburg, Germany
- Contact:
Or Or Or optimized?
Raspi 3B+RTC, SSD 128GB, Aeotec Gen5, Eurotronic SpiritZ, Fibaro FRGBW, Zipato PIR, Everspring AN180, Neo Coolcam Plug, Fibaro FGMS, Neo Coolcam Doorsensor, Popp Z-Weather
-
- Posts: 35
- Joined: Tuesday 04 June 2019 21:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Location: France
- Contact:
Re: Or Or Or optimized?
Hello I think you can do like that, maybe someone will have another idea 

Code: Select all
return {
on =
{
timer = { 'at 04:45 on mon, tue, wed, thu, fri','at 16:05 on mon, tue, wed, thu, fri','at 06:30 on sat, sun'},
devices = {'heizpause'},
},
execute = function( dz, item)
if heizpause == 'Heizen' then
print('Modus Bad aktualisieren')
end
if item.isTimer then
spirit.updateMode('Heat')
end
end
}
- Solderbro
- Posts: 80
- Joined: Tuesday 18 September 2018 15:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.1
- Location: Hamburg, Germany
- Contact:
Re: Or Or Or optimized? [Solved]
Uhm i just realized that such OR statements won't work at all. It seems not to be possible to optimize that, so every statement requires single elseif statement to run.
This one updates at 09:05 and 21:30.
if (t.matchesRule('at 09:05')) then
spirit.updateMode('Heat Eco')
elseif (t.matchesRule('at 21:30')) then
spirit.updateMode('Heat Eco')
end
print('Bad Sparmodus gesetzt')
end
While this one never update the mode, don't know if the line is malformed at all.
if heizpause == 'Heizen' then
print('Modus Kueche aktualisieren')
if (t.matchesRule('at 04:50 on mon, tue, wed, thu, fri') or ('at 15:15 on mon, tue, wed, thu, fri') or ('at 07:30 on sat, sun')) then
spirit.updateMode('Heat')
print('Küche Heizmodus gesetzt')
end
Conclusion: Never use Or statements?
This one updates at 09:05 and 21:30.
if (t.matchesRule('at 09:05')) then
spirit.updateMode('Heat Eco')
elseif (t.matchesRule('at 21:30')) then
spirit.updateMode('Heat Eco')
end
print('Bad Sparmodus gesetzt')
end
While this one never update the mode, don't know if the line is malformed at all.
if heizpause == 'Heizen' then
print('Modus Kueche aktualisieren')
if (t.matchesRule('at 04:50 on mon, tue, wed, thu, fri') or ('at 15:15 on mon, tue, wed, thu, fri') or ('at 07:30 on sat, sun')) then
spirit.updateMode('Heat')
print('Küche Heizmodus gesetzt')
end
Conclusion: Never use Or statements?
Raspi 3B+RTC, SSD 128GB, Aeotec Gen5, Eurotronic SpiritZ, Fibaro FRGBW, Zipato PIR, Everspring AN180, Neo Coolcam Plug, Fibaro FGMS, Neo Coolcam Doorsensor, Popp Z-Weather
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Or Or Or optimized?
or... if you like short code:
Code: Select all
t.matchesRule = tm
if tm('at 04:50 on mon, tue, wed, thu, fri') or tm('at 15:15 on mon, tue, wed, thu, fri') or tm('at 07:30 on sat, sun') then
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Who is online
Users browsing this forum: Google [Bot] and 1 guest