Setting a thermostat

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

Moderator: leecollings

Post Reply
Alain
Posts: 171
Joined: Sunday 26 April 2020 5:27
Target OS: Linux
Domoticz version: 2022.1
Location: Netherlands
Contact:

Setting a thermostat

Post by Alain »

I've been using Blockly for quite a while to run all sorts of scripts in our home and that has been quite successful. The problem I ran into with Blockly is that you can't automatically set a thermostat value, so I'm switching over to dzVents and trying to do it from there. My problem:

I have recently bought a new heat pump. I can set the water supply setpoint through Modbus. This works quite well. I have a dummy thermostat setup and when I change the value, it relays it through Modbus to the heat pump controller and it runs up to the requested temperature. What I want to do, however, is use the requested supply temperature from my Plugwise Anna thermostat and write that value into the dummy thermostat.

I have set up the following script:

Code: Select all

local MODE = 745 -- switch device
local SETPOINT_DEVICE = 744 -- Dummy thermostat 
local SUPPLY_TEMPERATURE = 216 -- Supply temperature
local LOGGING = true

return
{
	on =
	{
		devices =
		{
			SUPPLY_TEMPERATURE,
			MODE
		}
	},
	execute = function(domoticz, device)
	    if (device.name == SUPPLY_TEMPERATURE) then
	        domoticz.devices(744).updateSetPpoint = domoticz.devices.SUPPLY_TEMPERATURE

		end
	end
}
I'm not getting any errors, but the setpoint is not changing. Can someone point me in the right direction to change the code so that when idx 216 gets a new value, it will be copied to idx 744?
Hue | Zigbee2Mqtt | MQTT | P1 | Xiaomi | RFXCom | Modbus | TP-Link | Node-Red | Grafana |
plugge

Re: Setting a thermostat

Post by plugge »

Hi,

You've made typo and a programming error.

Replace: domoticz.devices(744).updateSetPpoint = domoticz.devices.SUPPLY_TEMPERATURE
With: domoticz.devices(744).updateSetPoint(domoticz.devices.SUPPLY_TEMPERATURE)
Alain
Posts: 171
Joined: Sunday 26 April 2020 5:27
Target OS: Linux
Domoticz version: 2022.1
Location: Netherlands
Contact:

Re: Setting a thermostat

Post by Alain »

plugge wrote: Friday 08 April 2022 11:17 Hi,

You've made typo and a programming error.

Replace: domoticz.devices(744).updateSetPpoint = domoticz.devices.SUPPLY_TEMPERATURE
With: domoticz.devices(744).updateSetPoint(domoticz.devices.SUPPLY_TEMPERATURE)
Thanks Plugge, however, it still isn't updating the thermostat device. I'm not getting any error. It says that device 216 has a new value and displays that but there is no updating of device 744 to have the same value as 216.
Hue | Zigbee2Mqtt | MQTT | P1 | Xiaomi | RFXCom | Modbus | TP-Link | Node-Red | Grafana |
plugge

Re: Setting a thermostat

Post by plugge »

Alain wrote: Friday 08 April 2022 19:51 I'm not getting any error. It says that device 216 has a new value and displays that but there is no updating of device 744 to have the same value as 216.
Your rule will not fire because the if statement compares a device name with a number. That doesn't match, so, no error.

Take a look at the manual: https://www.domoticz.com/wiki/DzVents:_ ... _scripting

(BTW: uppercase is used for dzVents constants. To avoid confusion you should lowercase for variables.)

Could you try this:

Code: Select all

local MODE = 745 -- switch device
local SETPOINT_DEVICE = 744 -- Dummy thermostat 
local SUPPLY_TEMPERATURE = 216 -- Supply temperature
local LOGGING = true

return
{
	on =
	{
		devices =
		{
			SUPPLY_TEMPERATURE,
			MODE
		}
	},
	execute = function(domoticz, device)
	    -- assuming SUPPLY_TEMPERATURE is the triggering device
	    -- if MODE is triggered, then your rule will not fire
	    -- see the log for the following print statements
	    print('==============your script==================')
	    print('  device.name: '..device.name)
	    print(' SUPPLY_TEMPERATURE name: '..domoticz.devices(SUPPLY_TEMPERATURE).name
	    if device.name == domoticz.devices(SUPPLY_TEMPERATURE).name  
	    then
	        print(' ==============> Rule fired!')
	        domoticz.devices(744).updateSetPoint(domoticz.devices(SUPPLY_TEMPERATURE).temperature)
	    end
	end
}
Alain
Posts: 171
Joined: Sunday 26 April 2020 5:27
Target OS: Linux
Domoticz version: 2022.1
Location: Netherlands
Contact:

Re: Setting a thermostat

Post by Alain »

plugge wrote: Friday 08 April 2022 20:23
Alain wrote: Friday 08 April 2022 19:51 I'm not getting any error. It says that device 216 has a new value and displays that but there is no updating of device 744 to have the same value as 216.
Your rule will not fire because the if statement compares a device name with a number. That doesn't match, so, no error.

Take a look at the manual: https://www.domoticz.com/wiki/DzVents:_ ... _scripting

(BTW: uppercase is used for dzVents constants. To avoid confusion you should lowercase for variables.)

Could you try this:

Code: Select all

local MODE = 745 -- switch device
local SETPOINT_DEVICE = 744 -- Dummy thermostat 
local SUPPLY_TEMPERATURE = 216 -- Supply temperature
local LOGGING = true

return
{
	on =
	{
		devices =
		{
			SUPPLY_TEMPERATURE,
			MODE
		}
	},
	execute = function(domoticz, device)
	    -- assuming SUPPLY_TEMPERATURE is the triggering device
	    -- if MODE is triggered, then your rule will not fire
	    -- see the log for the following print statements
	    print('==============your script==================')
	    print('  device.name: '..device.name)
	    print(' SUPPLY_TEMPERATURE name: '..domoticz.devices(SUPPLY_TEMPERATURE).name
	    if device.name == domoticz.devices(SUPPLY_TEMPERATURE).name  
	    then
	        print(' ==============> Rule fired!')
	        domoticz.devices(744).updateSetPoint(domoticz.devices(SUPPLY_TEMPERATURE).temperature)
	    end
	end
}
Your suggestion works! Now I'm going to look over it carefully (with the wiki on hand) to see where my train of thought when wrong. I want to master this code because I have many automations in my home that are now limited because I'm using Blockly.
Hue | Zigbee2Mqtt | MQTT | P1 | Xiaomi | RFXCom | Modbus | TP-Link | Node-Red | Grafana |
Alain
Posts: 171
Joined: Sunday 26 April 2020 5:27
Target OS: Linux
Domoticz version: 2022.1
Location: Netherlands
Contact:

Re: Setting a thermostat

Post by Alain »

I know that MODE won't fire it, but I thought it would be best to start as simple as possible to get a feel for dzVents first. Once I have figured out how this works, I'm going to try and include MODE in the "if" statement.
Hue | Zigbee2Mqtt | MQTT | P1 | Xiaomi | RFXCom | Modbus | TP-Link | Node-Red | Grafana |
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest