We have moved at community.getvera.com

Author Topic: How to link two thermostats ?  (Read 8221 times)

Offline qwen3579

  • Full Member
  • ***
  • Posts: 245
  • Karma: +9/-4
Re: How to link two thermostats ?
« Reply #15 on: April 08, 2014, 04:02:12 pm »
Thanks Guys,

I will have a try as soon as I get my head around all the new parameters, variables & phrases you used OK? Is there anything that really explains what you are writing about?

does e.g. setpoint mean the temperature the thermostat is set to or the temperature that currently is ?

how do I find out what functens - despite the common template for the device in vera are actually working ?

what does each function ectually mean,? e.e. what does the cool button do on a thermostat ?

Thanks for your Help

Setpoint will probably be the target temperature (the desired temperature).

I found what variables were available by using PLEG > Inputs > Device Properties. You can even see what the value is.


Offline jeppi

  • Newbie
  • *
  • Posts: 17
  • Karma: +0/-0
Re: How to link two thermostats ?
« Reply #16 on: July 07, 2014, 08:23:27 pm »
Easily done with PLEG or with Lua.

Good thread... I see the solution using PLEG... Just wondering what the Lua cod would look like...

Offline BulldogLowell

  • Hero Member
  • *****
  • Posts: 1576
  • Karma: +191/-85
Re: How to link two thermostats ?
« Reply #17 on: July 07, 2014, 08:29:14 pm »
I used this until I converted to PLEG; attached to a scene when the thermostat set point was changed.

and another on the other thermostat.

Code: [Select]
-- get the house temperature in the Master Hallway
local lul_temp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSetpoint1_Cool","CurrentSetpoint", 22)

--test to see if it was set low 
--in this case less than 87F
  if (tonumber(lul_temp) < 87) then
--Set the other thermostat to match the temperature
  luup.call_action("urn:upnp-org:serviceId:TemperatureSetpoint1_Cool","SetCurrentSetpoint",{NewCurrentSetpoint=tonumber(lul_temp) },4)
end

Offline jeppi

  • Newbie
  • *
  • Posts: 17
  • Karma: +0/-0
Re: How to link two thermostats ?
« Reply #18 on: July 08, 2014, 10:25:48 am »
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.

Offline RichardTSchaefer

  • Community Beta
  • Master Member
  • ******
  • Posts: 10091
  • Karma: +764/-143
Re: How to link two thermostats ?
« Reply #19 on: July 08, 2014, 01:21:30 pm »
There are some PLEG examples where users have synchronized thermostats.

Offline BulldogLowell

  • Hero Member
  • *****
  • Posts: 1576
  • Karma: +191/-85
Re: How to link two thermostats ?
« Reply #20 on: July 09, 2014, 08:56:02 am »
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.

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.


Offline osc

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: How to link two thermostats ?
« Reply #21 on: October 17, 2014, 04:23:42 pm »
... you have to create a scene that detects the set point change, and run that code for that thermostat's change in temperature.

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


... 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?..

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)


Code: [Select]
------------------------------------------------------
--- 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

Offline RichardTSchaefer

  • Community Beta
  • Master Member
  • ******
  • Posts: 10091
  • Karma: +764/-143
Re: How to link two thermostats ?
« Reply #22 on: October 21, 2014, 02:30:26 pm »
Quote
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.



Offline hebron

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
Re: How to link two thermostats ?
« Reply #23 on: October 29, 2014, 10:42:03 am »
Hi Richard,

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

Regards,