Опробованный уже много месяцев сценарий работы бойлера, написанный на lua. Экспериментально выяснил, что достаточно работы в течении 1 часа 15 мин утром и столько же вечером. Время может быть изменени.
function IsWeekEnd()
local dayofweek = tonumber(os.date("%w"))
local weekend
if (dayofweek >= 1) and (dayofweek <= 5) then weekend = "Будний"
elseif (dayofweek == 6) or (dayofweek == 0) then weekend = "Выходной"
end
return weekend
end
commandArray = {}
time = os.date('%X');
date = os.date('%d.%m.%Y');
weekend = IsWeekEnd();
if time >= '20:30' and time <= '21:45' and otherdevices ['Heater'] == 'Off' and otherdevices ['Vacancy'] == 'Off' then
commandArray['Heater'] = 'On'
elseif time >= '21:46' and time <= '23:59' and otherdevices ['Heater'] == 'On' then
commandArray['Heater'] = 'Off'
elseif time >= '05:30' and time <= '06:45' and otherdevices ['Heater'] == 'Off' and otherdevices ['Vacancy'] == 'Off' and weekend == 'Будний' then
commandArray['Heater'] = 'On'
elseif time >= '06:46' and time <= '12:59' and otherdevices ['Heater'] == 'On' and weekend == 'Будний' then
commandArray['Heater'] = 'Off'
elseif time >= '07:30' and time <= '08:45' and otherdevices ['Heater'] == 'Off' and otherdevices ['Vacancy'] == 'Off' and weekend == 'Выходной' then
commandArray['Heater'] = 'On'
elseif time >= '08:46' and time <= '12:59' and otherdevices ['Heater'] == 'On' and weekend == 'Выходной' then
commandArray['Heater'] = 'Off'
end
return commandArray
Пояснения - в первой части функция определения дня недели - выходной - дни 0 и 6 (воскресенье и субботы) или будние - 1-5.
Heater - настенная розетка Aqara.
Vacancy - виртуальній переключатель, активируется если бойлер включать не надо - например все уехали
Собственно розетка включается по будням с 5:50 до 6:45, на выходных с 7:30 до 8:45, вечером с 20:30 до 21:45. Тип сценария - Time - он проверяется ежеминутно