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!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0
Sign in to follow this  
sahan.jenny

How to use Lua to add/remove removes to a heating/cooling zone

Question

Hi,

 

I have a heatpum that i can use to both cool and heat my house. I've got a floor heating system that i control with fibaro switches. I've got the switched set u via linked devices and use the heating / cooling panel to setup heating / cooling schedules / set points for my house.

 

What i have noticed however is that if my rooms are both mapped to heating and cooling zones it doesn't work. this is because the heating will try to close a valve, while the cooling will try to turn it on (or vice versa) and the valve goes flipping back and forth.

 

it is unfortunate that Fibaro built the heating/cooling independently like this, but doubt they will change it.

 

The easiest way i can think of circumventing this is by creating lua code that adds the rooms to heating or cooling zones depending on whether the system is in heating or cooling mode. 

 

But i can't figure out how to do that. Anyone know?

 

Regards,

 

Sahan

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0
  • Inquirer
  • managed to patch together some code based on partial answers i found online. for those facing the same problem this is what i've built

     

    --[[
    %% properties
    %% events
    %% globals
    %% weather
    --]]

    --====================================================
    -------------------- Declaration: Local Variables
    --====================================================
    local debug = true

    local HeatingCoolingZones = {"Living/Kitchen", "Office", "Playroom", "Hallway", "Guest Bedroom", "Front Bedroom", "Back Bedroom", "Master Bedroom"}
    local HeatingPanel_Identifiers = {10, 19, 20, 18, 16, 14, 13, 11}
    local CoolingPanel_Identifiers = {13, 14, 15, 16, 17, 18, 19, 20}

    local MappedRooms_Identifiers = {{23,24},{20},{19},{12,13},{16},{14},{15},{10}}

    local HeatPump_Mode = "Cooling" -- or Heating

    -- HomeTable --
    local jT = json.decode(fibaro:getGlobalValue("HomeTable"));

    --====================================================
    -------------------- Functions
    --====================================================
    local function log(str) if debug then fibaro:debug(str); end; end
    local function errorlog(str) fibaro:debug("<font color='red'>"..str.."</font>"); end

    --====================================================
    -------------------- Main
    --====================================================

    for i = 1, #HeatingCoolingZones do 
      
    --        log("DeviceID: " .. devices .. "; DeviceName: " .. fibaro:getName(devices) .. "; DeviceRoom: " .. fibaro:getRoomName(fibaro:getRoomID(devices)))

        local HeatingPanel = api.get("/panels/heating/" .. HeatingPanel_Identifiers)
        local CoolingPanel = api.get("/panels/cooling/" .. CoolingPanel_Identifiers)

          log(json.encode (HeatingPanel))
          log(json.encode (CoolingPanel))

        HeatingPanelRooms = HeatingPanel.properties.rooms
          CoolingPanelRooms = CoolingPanel.properties.rooms

          log("Old Heating Panel Rooms: " .. json.encode (HeatingPanelRooms))
        log("Old Cooling Panel Rooms: " .. json.encode (CoolingPanelRooms))
        log("Mapped Rooms: " .. json.encode (MappedRooms_Identifiers))

        if next(HeatingPanelRooms) == nil then
           log("heating table is empty")
        
            temp = HeatingPanelRooms
            HeatingPanelRooms = CoolingPanelRooms
            CoolingPanelRooms = temp

        elseif next(CoolingPanelRooms) == nil then
           log("cooling table is empty")

              temp = CoolingPanelRooms
            CoolingPanelRooms = HeatingPanelRooms
            HeatingPanelRooms = temp

          end

          log("New Heating Panel Rooms: " .. json.encode (HeatingPanelRooms))
          log("New Cooling Panel Rooms: " .. json.encode (CoolingPanelRooms))
      
        HeatingPanel.properties.rooms = HeatingPanelRooms
          CoolingPanel.properties.rooms = CoolingPanelRooms

        log(json.encode (HeatingPanel))
          log(json.encode (CoolingPanel))

        api.put("/panels/heating/" ..HeatingPanel_Identifiers, HeatingPanel)
          api.put("/panels/cooling/" ..CoolingPanel_Identifiers, CoolingPanel)

        local HeatingPanel = api.get("/panels/heating/" .. HeatingPanel_Identifiers)
        local CoolingPanel = api.get("/panels/cooling/" .. CoolingPanel_Identifiers)

          log(json.encode (HeatingPanel))
          log(json.encode (CoolingPanel))
      
    end

    Share this post


    Link to post
    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.

    Guest
    Answer this question...

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

    Sign in to follow this  

    ×
    ×
    • Create New...