Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,


as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.


As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!



Smart Home Forum by FIBARO Team

Multi-room Call for Heat 1.1.0

   (1 review)

About This File

I have a number of Danfoss LC-13 valves around the house, together with a Secure SSR302 to turn the boiler on and off.  The Danfoss valves are controlled by the Heating Panels, and I also have a Fibaro multi-sensor in each room.  I've noticed from a number of posts on the forum that there are other people with the same or similar setup, and need a scene to control the boiler switch.  The idea being that if any room needs heat, then the boiler will be turned on, and once all the rooms have reached the required temperature, then the boiler will be turned off.


Setup required:


Modify the device id for the Secure SSR302 (or whatever device is used to control the boiler) here:

local boilerSwitch = 84

You might also want to tweak this value:

local threshold = 0.3

This is used to build in some hysteresis into the system to prevent the boiler from being switched on and off too frequently.  The boiler won't switch on until the temperature has dropped below the target temperature by this value or more.


The scene is triggered by a global 'timer' variable to run every 5 minutes.  There are a number of timer scenes on the forum, but this is the scene that I use.


You should also change your Danfoss valves so that the Wake Up Interval is 300 seconds.  I find that this doesn't have a detrimental effect on the battery but allows the devices to respond more quickly to the temperature change requests.


The scene works off the temperature sensor and thermostat that have been defined in your Room settings, so ensure that these are correct:




Note that this method of controlling the boiler assumes that your temperature sensors are working to the same temperatures as your Danfoss valves - ie: the Danfoss valves turn off once they've reached the target temperature, and that the temperature sensors are also reading this same value.  You may need to tweak the temperature offset for the temperature sensors so that the two devices are in sync with each other.  If in doubt then set the temperature offset so that the sensors read a slightly higher temperature.  That way, the scene will think that the room has reached the desired temperature and turn off the boiler.  Otherwise you may find that the boiler is not switching off because the room has reached the target temperature, but the Danfoss valve has already turned itself off.


Other types of boiler switch might not use the 'mode' property to determine whether they are on or off.  Consequently, the following line may need to be changed, for example to use the 'value' property instead of 'mode':

local boilerOn = (fibaro:getValue(boilerSwitch, "mode") == "1")


Side topic:


Note that there is a school of thought that boilers should be left on all the time even if there aren't any rooms that require the heat, and that the boiler's control logic will detect this and modulate the water temperature accordingly.  I don't necessarily uphold this view, but then I'm not a heating engineer either, so I'm happy to be persuaded either way.  In my case, I believe that my condensing boiler operates most efficiently when there is a 20C difference between the output and input water temperatures, and as a result it needs the radiators to be drawing heat from the system.  I also have radiators that aren't controlled by Danfoss valves (bathrooms and other small rooms), and I don't want to be heating them all the time, wasting energy.  After all, the whole point of the Danfoss valves is to avoid having to heat rooms that you're not using, and thereby save some money.  Maybe the more intelligent boilers that can regulate the water temperature according to the system's needs and outside temperature operate differently, and as a result more efficiently, and can be left on all the time.  The general opinion, in the UK at least, appears to be that the heating should be turned off if not needed.  Just my tuppence worth, but I know that views like this can be contentious so please don't shoot me down in flames. ;-)


As another side topic, it looks as though the new Fibaro TRVs are far superior to the Danfoss TRVs with the built in algorithms and the ability to cooperate with another sensor in the room.  They should certainly avoid a lot of the problems that we get with the Danfoss valves.  Pity I can't justify replacing them.



What's New in Version 1.1.0   See changelog


The scene can fail if a non-thermostat or non-thermometer device is selected in the room properties.  Additional checks have been added to ensure that the device has the correct properties.

  • Like 1

Other Files from Dave_H

User Feedback

Recommended Comments

Hi Dave, 


Thank you for your nice lua script! I would like to use it in your described setup, I do however not have a BoilerSwitch, but a regular Fibaro Wall Switch, acting as my 'boiler switch'. I found our that this lua script is not working on my wall switch. Do you maybe know which lines of code I have to change in order to control my fibaro wall switch? I am a noob in scripting.


I hope you can help me out. Kind regards,



Link to comment
Share on other sites

You have to change the line which is sending command to switch - use the green or the blue line (the one which works for you):


if (boilerOn and not turnBoilerOff) then
  fibaro:debug("*** Keep heating on")
  fibaro:call(boilerSwitch, "setMode", "1")
  fibaro:call(boilerSwitch, "turnOn")



-- Turn the boiler off?
if (boilerOn and turnBoilerOff) then
  fibaro:debug("*** Turning off heating")
  fibaro:call(boilerSwitch, "setMode", "0")
  fibaro:call(boilerSwitch, "turnOff")

  • Thanks 1
Link to comment
Share on other sites

Hi All!

I have a heat pump switched by Fibaro Relay

and in several rooms I have fan coils so I cannot use thermostats. I should switch on the fan coils with Fibaro Relays too each room separately.

The task is the same as in this case I think, I have to switch on Heat Pump whenever any of the rooms need heating and switch on the

appropriate room's fan coil relay and preserve this state until every room is heated enough then switch off.


I saw this Call For Heat Scene and I think that I could use it with some modification like changing the room thermostats to Fibaro relays.

Does anybody has some modification advises for this scene?

Thx in advance


Link to comment
Share on other sites



Any idea what code must be added in order to work in rooms where there is a virtual thermostat implemented with linked devices (temp sensor & a switch that control a valve)? 

Thanks for support 

Link to comment
Share on other sites

Hi @gusti67


On 12/25/2019 at 7:16 PM, gusti67 said:

Any idea what code must be added in order to work in rooms where there is a virtual thermostat implemented with linked devices (temp sensor & a switch that control a valve)? 


I haven't played around much with linked devices.  I assume that the linked device doesn't appear as the room thermostat in the room settings as a normal thermostat would, so this scene would need to be modified to pick up the Target Temperature or roomSetpoint (as it's described in the scene) directly from the Heating Panel Zone.  Here is some code which would allow you to do this:





To get the target temperature for each Heating Panel Zone, then you can use the following function:

-- getZoneTemperature
-- Return the temperature for the selected Heating Panel Zone

function getZoneTemperature(zoneID)

  local zoneTemp = nil
  -- Get the selected Heating Panel Zone
  if (zoneID ~= 0 and zoneID ~= nil) then
    -- Get the zone details
    local zone, status = api.get("/panels/heating/" .. zoneID)
    if (zone ~= nil and status == 200) then
      zoneTemp = zone.properties.currentTemperature
  zoneTemp = tonumber(zoneTemp)
  return zoneTemp


However, then you'll first need to find out what the zoneID is for each room, so you can use this bit of code:

-- getZoneForRoomID
-- Return the Heating Panel Zone for specified room
function getZoneForRoomID(roomID)

  local zoneID = nil

  -- Get the Heating Panels
  local zones, status = api.get("/panels/heating")
  if (zones ~= nil and status == 200) then
    -- For each panel/zone, get the zone details, and check if the selected room is
    -- controlled by the heating panel zone. If so, then return the details.
    for zoneKey, zoneValue in pairs(zones) do
      local panel, status = api.get("/panels/heating/" .. zoneValue.id)
      if (panel ~= nil and status == 200) then
        local rooms = panel.properties.rooms
        -- Check to see if the current room is one of the values controlled
        -- by this heating panel
        if (rooms ~= nil and type(rooms) == 'table') then
          for roomKey, roomValue in pairs(rooms) do
            if (roomValue == roomID) then
              zoneID = panel.id
  return zoneID




However, I'm wondering whether a simpler option for you would be to create a scene which monitors the valve switches.  When the switches turn on and off, then they will activate a 'value' property trigger.  This property trigger could be used to run a scene which could check whether any of your valve switches are turned on, and if so, then turn on the boiler.  Maybe you could try something like this:

%% properties
192 value
194 value
196 value
259 value

local boilerSwitch = 361
local valveSwitches = 
				lounge = 192,
				kitchen = 194,
				bedroom1 = 196,
				bedroom2 = 259

local sourceTrigger = fibaro:getSourceTrigger()
if (sourceTrigger.deviceID ~= nil) then
  fibaro:debug(">> Triggered by device: " .. sourceTrigger.deviceID .. " Name: " .. fibaro:getName(sourceTrigger.deviceID))

-- Check whether any of the switches is on
local anySwitchOn = false

for room, switch in pairs(valveSwitches) do

	local switchValue = fibaro:getValue(switch, "value")
	if (switchValue ~= nil and tonumber(switchValue) > 0) then
		anySwitchOn = true

-- If there is at least one switch on, then turn on the boiler, otherwise turn it off
local boilerSwitchValue = fibaro:getValue(boilerSwitch, "value")
local isBoilerOn = (boilerSwitchValue ~= nil and tonumber(boilerSwitchValue) > 0)

if (anySwitchOn and not isBoilerOn) then
	fibaro:call(boilerSwitch, "turnOn")
	fibaro:debug("Boiler Turned On")

if (not anySwitchOn and isBoilerOn) then
	fibaro:call(boilerSwitch, "turnOff")
	fibaro:debug("Boiler Turned Off")

if (anySwitchOn and isBoilerOn or not anySwitchOn and not isBoilerOn) then
	fibaro:debug("No action required")



Link to comment
Share on other sites



Thanks a lot for suggested code.I'm not an experienced LUA coder but I think will work.

I tested with a small code and seems to work. If the room where the virtual thermostat (made from linked device)

it's included in the heating panel than the setpoint it can be read from there , compared with the sensor temperature used in linked device

and than take a decision.

Thanks again

Link to comment
Share on other sites

@Dave Harrison


Hi again, I'm not a LUA programmer so I'm probably doing something very silly. I've tried two of the LUA scenes you created and I'm afraid I'm still having problems. The setup is a fibaro relay switching the boiler on and off and 6 Danfoss TRVs, 1 in each room. Each room has a Fibaro multi sensor which lets the heating panel know the temperature of that room. The problem is that if I link the boiler relay to the temperature in one room it turns off the boiler when that room reaches its set temperature but this stops sending heat to other rooms which are still cold. If I link the boiler relay to all rooms it turns the boiler on and off every minute or so which is damaging the boiler. I've tried two of the LUA scenes and unlinked the boiler from all rooms which is great until all the rooms reach their set temperature and are not switching off the boiler.  Here's your code (from one of the scenes as modified by me for the setup) and a grab of the debug messages. Many Thanks in advance, Help me Obi Wan, you're my only hope.


%% properties
%% events
%% globals

-- Scene         : Call For Heat Scene
-- Version       : 1.1
-- Date Created  : 28 February 2016
-- Last Changed  : 01 April 2018
-- Created By    : Dave Harrison

-- Purpose       : To turn on the boiler whenever a room needs heat
-- Trigger       : Triggered by the Timer Scene updating the fiveMinuteTimer global variable

-- Revision History
-- ----------------

-- 1.1 01-Apr-18  Additional checks for valid devices

-------------------- Declaration: Local Variables
local boilerSwitch = 47

-- Amount by which temperature needs to fall below setpoint before turning heating on
local threshold = 0.3

local sourceTrigger = fibaro:getSourceTrigger()
local currentDate = os.date("%d/%m/%Y %X")
local currentDateTime = os.date("*t") 

-------------------- Functions

-- getRoomsAndDevices
-- Get the list of rooms and devices to monitor
-- Only rooms with both a thermostat and thermometer will be selected
function getRoomsAndDevices()

  local rooms = {}

  local allRooms = api.get("/rooms")
  for k, room in pairs(allRooms) do
    local thermostat = room.defaultThermostat
    local thermometer = room.defaultSensors.temperature
    if (thermostat ~= nil and thermometer ~= nil) then
      if (thermostat ~= 0 and thermometer ~= 0) then
        -- Ignore any rooms where the thermometer or thermostat doesn't have a value or a setpoint level
        local roomTemp = tonumber(fibaro:getValue(thermometer, "value"))
        local roomSetpoint = tonumber(fibaro:getValue(thermostat, "targetLevel"))
        if (roomTemp ~= nil and roomSetpoint ~= nil and roomSetpoint > 0) then
          local newRoom = {id = room.id, name = room.name, thermostat = thermostat, thermometer = thermometer, roomTemp = roomTemp, roomSetpoint = roomSetpoint}
          table.insert(rooms, newRoom)

  return rooms

-- asterisk
-- Output an asterisk if true
function asterisk(condition)
  local asterisk = ""
  if (condition) then
    asterisk = " *"
  return asterisk

-------------------- Main
-- fibaro:debug(">> Trigger Type: " .. sourceTrigger.type)

if (sourceTrigger.name ~= nil) then
  -- fibaro:debug(">> Trigger Name: " .. sourceTrigger.name)

-- Get the rooms and devices that we want to monitor
local rooms = getRoomsAndDevices()

-- Is the heating already on?
local boilerOn = (fibaro:getValue(boilerSwitch, "mode") == "1")
fibaro:debug(currentDate .. "  Boiler on: " .. tostring(boilerOn))

local turnBoilerOn = false
local turnBoilerOff = true

-- Check each room
for i , room in pairs(rooms) do
  -- Has the temperature fallen below setpoint by more than the threshold?
  local belowThreshold = room.roomTemp <= (room.roomSetpoint - threshold)
  fibaro:debug(">> Room: " .. room.name .. "   Temperature: " .. room.roomTemp .. "   Set Point: " .. room.roomSetpoint .. asterisk(belowThreshold))
  -- If the boiler is not on, then check if any rooms need heat
  if (not boilerOn) then
    -- Need to turn the boiler on?
    if (belowThreshold) then
      turnBoilerOn = true
  -- If the boiler is on, then check whether any rooms still need heat
  if (boilerOn) then
    -- Is the temperature still below the setpoint?
    if (room.roomTemp < room.roomSetpoint) then
      turnBoilerOff = false

-- Turn the boiler on?
if (not boilerOn and turnBoilerOn) then
    fibaro:debug("*** Turning on heating")
    fibaro:call(boilerSwitch, "turnOn")

if (not boilerOn and not turnBoilerOn) then
  fibaro:debug("*** Keep heating off")

-- Turn the boiler off?
if (boilerOn and turnBoilerOff) then
  fibaro:debug("*** Turning off heating")
  fibaro:call(boilerSwitch, "turnOff")

-- The SSR302 boiler controller has a fail safe mode.  If there has been no communication and the boiler channel is turned on
-- then it will go into fail safe mode after 60 minutes.  Therefore, during the on-period, we need to resend the on message periodically.
if (boilerOn and not turnBoilerOff) then
  fibaro:debug("*** Keep heating on")
  fibaro:call(boilerSwitch, "turnOn")


Link to comment
Share on other sites

5 hours ago, mikeshep said:

Is it something to do with the "mode" see attached tiff


Hi @mikeshep


Yes, most probably.  See my notes in the file description, ie:





Other types of boiler switch might not use the 'mode' property to determine whether they are on or off.  Consequently, the following line may need to be changed, for example to use the 'value' property instead of 'mode':

local boilerOn = (fibaro:getValue(boilerSwitch, "mode") == "1")



Therefore, trying change "mode" to "value" and see if that works.



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...