This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Thermostat with auto disable function
#4
Here is a script, but please carefully test it and give the feedback.
I will make a changes if necessary.
It is a resident script, with sleep time 60 seconds.

Code:
if not motion_minute_counter then
  motion_minute_counter = 0
end

if not temp_minute_counter then
  temp_minute_counter = 0
end

motion_detected = grp.getvalue('motion_detected') -- boolean
current_temp = grp.getvalue('current_temp') -- float
window_opened = grp.getvalue('window_opened') -- boolean
heater_status = grp.getvalue('heater_status') -- boolean

--log(motion_detected)
--log(current_temp)
--log(window_opened)
--log(heater_status)

set_temperature = 25 -- Celsius degree
hysteresis = 1 -- Celsius degree

one_hour = 60 -- minutes

if not motion_detected then
  motion_minute_counter = motion_minute_counter + 1
else
  motion_minute_counter = 0 -- motion was detected unset counter
end

if current_temp > set_temperature then
  temp_minute_counter = temp_minute_counter + 1
else
  temp_minute_counter = 0
end

if current_temp < set_temperature and
      not window_opened and
      motion_minute_counter < one_hour and
      not heater_status then -- heater is off
 
  grp.write('heater_control', true)
 
end


if (current_temp + hysteresis > set_temperature or window_opened) and heater_status then
  grp.write('heater_control', false)
end
 
if (motion_minute_counter > one_hour or temp_minute_counter > one_hour) and heater_status then
  grp.write('heater_control', false)
end

--log(motion_minute_counter)
--log(temp_minute_counter)
Reply


Messages In This Thread
RE: Thermostat with auto disable function - by RomansP - 23.10.2024, 11:11

Forum Jump: