How to link two thermostats ?

[quote=“jeppi, post:19, topic:180301”]Thanks for the code… It seems that this will work if you have a “master” thermostat where you always adjust the setting to the “slave” thermostat… Is there a way to “detect” which thermostat had the latest set point change and transfer the setting to the other thermostat?..

To explain what I try to achieve : I have several heating zones but only one cooling zone. I want to control the cooling from any thermostat… If the house is already in cooling mode but I want to change the cool setpoint of the house temperature from any thermostat without changing the mode (cooling, heating, off)… How can I do that?

What I am missing to use your code is a trigger that will detect a setpoint change on any thermostat… And then I could use the code on 2 scenes, one per thermostat… But I don’t see such trigger in vera…

Thanks.[/quote]

I mentioned “…attached to a scene…”

you have to create a scene that detects the set point change, and run that code for that thermostat’s change in temperature.

So if you have three cooling thermostats, you will need three scenes and attach an edited version of the above code that will modify the other two thermostats. I hope that is clear.

Richard’s point regarding the PLEG solution is a lot more elegant, FYI but either will work.

To my best knowledge, UI5 scene triggers do not provide an option for detecting setpoint changes unfortunately :frowning:

I had been looking into a very similar scenario, where I needed to sync Secure SRT321 to a Smart Thermostat device (Smart Virtual Thermostat by Antor) for some days now. I finally achieved this and I believe the code can very well work for you too. It goes into the Startup Lua (do not forget to change the device numbers accordingly)

------------------------------------------------------
--- Get device name for device number
--
function get_dev_name(dev_id)
	if (luup.devices[dev_id] ~= nil) then
	  return luup.devices[dev_id].description
	else
	  return "no_such_dev"
	end
end


------------------------------------------------------
--- Sync two thermostats' heat setpoints
--

-- Global variables
REALTHERM = 62 -- Real thermostat dev no
SMARTHERM = 48 -- Smart thermostat dev no
HVACH_SID = "urn:upnp-org:serviceId:TemperatureSetpoint1_Heat" -- Service ID for thermostat devices

-- Register callback for variable changes
luup.variable_watch("device_heat_setpoint_change", HVACH_SID, "CurrentSetpoint", REALTHERM)
luup.variable_watch("device_heat_setpoint_change", HVACH_SID, "CurrentSetpoint", SMARTHERM)

-- Callback handler
function device_heat_setpoint_change(dev_id, service, variable, old_val, new_val)
   	luup.log(string.format("--OSC_SYNC_THERM-- heat setpoint changed for device #%s (%s) from %s to %s", dev_id, get_dev_name(dev_id), old_val, new_val))
	-- which device's set point changed, which one will be synchronised?
	local srcdev = dev_id
	local tgtdev = srcdev -- initialize with srcdev temporarily	
	if (srcdev == REALTHERM) then
		tgtdev = SMARTHERM
	else
		tgtdev = REALTHERM
   	end
   	
   	-- get tgtdev current setpoint
   	local tgtdev_current = luup.variable_get(HVACH_SID, "CurrentSetpoint", tgtdev)
   	
   	-- sync if necessary
   	if (tgtdev_current ~= new_val) then
   		luup.log(string.format("--OSC_SYNC_THERM-- attempting to set device #%s (%s) heat setpoint from %s to %s", tgtdev, get_dev_name(tgtdev), tgtdev_current, new_val))
   		luup.call_action(HVACH_SID, "SetCurrentSetpoint", {NewCurrentSetpoint=tonumber(new_val) }, tgtdev)
   	else
   		luup.log(string.format("--OSC_SYNC_THERM-- device #%s (%s) current heat setpoint is already %s. Aren't we lucky!", tgtdev, get_dev_name(tgtdev), new_val))
	end
end
To my best knowledge, UI5 scene triggers do not provide an option for detecting setpoint changes unfortunately

PLEG can trigger on any device trigger OR device property change … So you can easily add logic to trigger when the setpoint changes.
In PLEG it’s easy to setup so that there is no MASTER/SLAVE … if you change one the other changes.

Hi Richard,

How do I catch/determine device property change in PLEG?

Regards,