thermostat  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
Cdzn
Posts: 18
Joined: Monday 02 March 2020 10:09
Target OS: -
Domoticz version:
Contact:

thermostat

Post by Cdzn »

Hello there. I have thermostat and would like to heat and cool in time. I wrote these script but can`t change setpoint from it.

Code: Select all

local timer1 = 'every minute' --'at 06:00'
return {
    	on = {
		timer = { timer1}
			 },
			  logging = { level = domoticz.LOG_DEBUG },
			  
		   execute = function(domoticz,item,devices)
		     
		    if (item.isTimer) then domoticz.devices(3).SetPoint= 26
		  
	 end
 end
}
Setpoint just don`t setting at thermostat
besix
Posts: 99
Joined: Friday 25 January 2019 11:33
Target OS: Linux
Domoticz version: beta
Location: Poland
Contact:

Re: thermostat  [Solved]

Post by besix »

Change

Code: Select all

if (item.isTimer) then domoticz.devices(3).SetPoint= 26
to

Code: Select all

if (item.isTimer) then domoticz.devices(3).updateSetPoint(26)
Cdzn
Posts: 18
Joined: Monday 02 March 2020 10:09
Target OS: -
Domoticz version:
Contact:

Re: thermostat

Post by Cdzn »

besix wrote: Saturday 02 October 2021 8:29 Change

Code: Select all

if (item.isTimer) then domoticz.devices(3).SetPoint= 26
to

Code: Select all

if (item.isTimer) then domoticz.devices(3).updateSetPoint(26)
What I just didn’t do. Thanks. Why setpoint does`t work?
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: thermostat

Post by EddyG »

besix
Posts: 99
Joined: Friday 25 January 2019 11:33
Target OS: Linux
Domoticz version: beta
Location: Poland
Contact:

Re: thermostat

Post by besix »

Code: Select all

return {
	on = {
		timer = {'every minute'},				-- causes the script to be called every minute
				 },
			  logging = { level = domoticz.LOG_DEBUG },
			  
		   execute = function(domoticz,item)
		     
		    if (item.isTimer) then 
		        domoticz.devices('SetPoint').updateSetPoint(26)
	   end
 end
}
Rename SetPoint to your thermostat and check
Cdzn
Posts: 18
Joined: Monday 02 March 2020 10:09
Target OS: -
Domoticz version:
Contact:

Re: thermostat

Post by Cdzn »

besix wrote: Saturday 02 October 2021 9:47

Code: Select all

return {
	on = {
		timer = {'every minute'},				-- causes the script to be called every minute
				 },
			  logging = { level = domoticz.LOG_DEBUG },
			  
		   execute = function(domoticz,item)
		     
		    if (item.isTimer) then 
		        domoticz.devices('SetPoint').updateSetPoint(26)
	   end
 end
}
Rename SetPoint to your thermostat and check
Your 1st answer working. Thank You! every minure just for testing.
Cdzn
Posts: 18
Joined: Monday 02 March 2020 10:09
Target OS: -
Domoticz version:
Contact:

Re: thermostat

Post by Cdzn »

One more question. How to make this work with 2 different timers
Spoiler: show

Code: Select all

local Timer1 = 'at 19:43'
local Timer2 = 'at 19:44'
return {
    	on = {
    	    timer = {Timer1, Timer2}
			 },
			  logging = { level = domoticz.LOG_DEBUG },
			  
		   execute = function(domoticz,item,devices)
		     
		    if (item.isTimer) then domoticz.devices(3).updateSetPoint(26)
		        return
		            end
		    if (item.isTimer) then domoticz.devices(3).updateSetPoint(24.5)
		        return
		        	end
		    
 end
}
besix
Posts: 99
Joined: Friday 25 January 2019 11:33
Target OS: Linux
Domoticz version: beta
Location: Poland
Contact:

Re: thermostat

Post by besix »

I think it will help

Code: Select all

return 
{
	on = 
	   {timer = 
		   {'at 8:00',
		    'every 3 minutes between 9:30 and 23:00',
                    'at 23:01' }
        },
	logging = { level = domoticz.LOG_DEBUG },
		
	execute = function(dz, item)
    if item.isTimer then 
    if dz.time.matchesRule('at 8:00') then
        dz.devices('SetPoint').updateSetPoint(24)
		end
	if dz.time.matchesRule('every 3 minutes between 9:30 and 23:00') then
        dz.devices('SetPoint').updateSetPoint(23)	
            end
	if dz.time.matchesRule('at 23:01') then
        dz.devices('SetPoint').updateSetPoint(21)	
    end
  end
end
}
Cdzn
Posts: 18
Joined: Monday 02 March 2020 10:09
Target OS: -
Domoticz version:
Contact:

Re: thermostat

Post by Cdzn »

besix wrote: Saturday 02 October 2021 17:47 I think it will help

Code: Select all

return 
{
	on = 
	   {timer = 
		   {'at 8:00',
		    'every 3 minutes between 9:30 and 23:00',
                    'at 23:01' }
        },
	logging = { level = domoticz.LOG_DEBUG },
		
	execute = function(dz, item)
    if item.isTimer then 
    if dz.time.matchesRule('at 8:00') then
        dz.devices('SetPoint').updateSetPoint(24)
		end
	if dz.time.matchesRule('every 3 minutes between 9:30 and 23:00') then
        dz.devices('SetPoint').updateSetPoint(23)	
            end
	if dz.time.matchesRule('at 23:01') then
        dz.devices('SetPoint').updateSetPoint(21)	
    end
  end
end
}
Thank You!!!
rrozema
Posts: 470
Joined: Thursday 26 October 2017 13:37
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Delft
Contact:

Re: thermostat

Post by rrozema »

Many thermostats have a 'mode' setting, switching between 'economy' and 'normal' modes. Both modes have their own setpoint, so you need to set the both temperatures only once, and you only switch the mode control from economy to normal and vice versa. This allows you to still adjust the 'normal' setpoint manually without having to re-code your script.

If your thermostat doesn't have such an economy mode, have a look at SVT, the Smart Virtual Thermostat plugin. If you can switch your heating on and off from domoticz using for example a simple esp relay, use this plugin to replace your normal thermostat and most likely you'll get better comfort plus on top of that use less energy for heating your house.
Cdzn
Posts: 18
Joined: Monday 02 March 2020 10:09
Target OS: -
Domoticz version:
Contact:

Re: thermostat

Post by Cdzn »

rrozema wrote: Monday 04 October 2021 20:50 Many thermostats have a 'mode' setting, switching between 'economy' and 'normal' modes. Both modes have their own setpoint, so you need to set the both temperatures only once, and you only switch the mode control from economy to normal and vice versa. This allows you to still adjust the 'normal' setpoint manually without having to re-code your script.

If your thermostat doesn't have such an economy mode, have a look at SVT, the Smart Virtual Thermostat plugin. If you can switch your heating on and off from domoticz using for example a simple esp relay, use this plugin to replace your normal thermostat and most likely you'll get better comfort plus on top of that use less energy for heating your house.
The problem is i using handmade thermostate with Nextion display and internal ESPeasy thermostat, not in domoticz, to have a possibility to change setpoint from Domoticz or from touchscreen.
NExt step i want to make script like this, which remember last setpoint, turn thermostate ON, after 30 minutes return setpoint to last value.

Code: Select all

return {
	on = {
		devices = {
			'Принудительный нагрев',
					}
	},
	logging = {
		level = domoticz.LOG_INFO,
		marker = 'template',
	},
	execute = function(domoticz, switch)
	  --local Lastsp = domoticz.devices(3).updateSetPoint(25)   
	    if (switch.state == 'On')
	    then domoticz.devices(3).updateSetPoint(27)
	         switch.switchOff().afterMin(30)
	      elseif (switch.state == 'Off')
            then domoticz.devices(3).updateSetPoint(24)
end
end
}
rrozema
Posts: 470
Joined: Thursday 26 October 2017 13:37
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Delft
Contact:

Re: thermostat

Post by rrozema »

If you are in control om the software inside the thermostat, why don't you rewrite it to be a device to show and enter a setpoint only. The setpoint set is sent into a setpoint device in Domoticz Then have your Domoticz do the actual work of regulating the heat source. For example by using svt.
Cdzn
Posts: 18
Joined: Monday 02 March 2020 10:09
Target OS: -
Domoticz version:
Contact:

Re: thermostat

Post by Cdzn »

rrozema wrote: Wednesday 13 October 2021 16:13 If you are in control om the software inside the thermostat, why don't you rewrite it to be a device to show and enter a setpoint only. The setpoint set is sent into a setpoint device in Domoticz Then have your Domoticz do the actual work of regulating the heat source. For example by using svt.
I have no idead how to make it works
rrozema
Posts: 470
Joined: Thursday 26 October 2017 13:37
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Delft
Contact:

Re: thermostat

Post by rrozema »

Cdzn wrote: Thursday 14 October 2021 11:45
rrozema wrote: Wednesday 13 October 2021 16:13 If you are in control om the software inside the thermostat, why don't you rewrite it to be a device to show and enter a setpoint only. The setpoint set is sent into a setpoint device in Domoticz Then have your Domoticz do the actual work of regulating the heat source. For example by using svt.
I have no idead how to make it works
Never mind. When you said
The problem is i using handmade thermostate with Nextion display and internal ESPeasy thermostat, not in domoticz, to have a possibility to change setpoint from Domoticz or from touchscreen.
I assumed you had written the software in the thermostat yourself.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest