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

Help with LUA


Lauri

Question

Hello, can you help me to find a problem here.

What is should do: It shold calculate

target2 - outTemp > hysteresis and then decide wether it needs to rise temperature or lower it. If rise, then it has to add to valve (roller shutter module) position 1% and wait for 10sec, if needed then open more 1% and so on.

What it actually does:

Everything is OK, but opening and closing the valve is not 1% and 10sec interval instead it opens valve 10-20% in one sec and this is not good.

What is wrong with LUA here?

--[[

%% autostart

%% properties

163 value

203 value

23 value

%% globals

targetTemp1

--]]

local extTemp=tonumber(fibaro:getValue(23, "value"))

local outTemp=tonumber(fibaro:getValue(163, "value"))

local ventiil=tonumber(fibaro:getValue(203, "value"))

local target2=tonumber(fibaro:getGlobalValue("targetTemp2"))

local hysteresis=tonumber(fibaro:getGlobalValue("hysterees"))

--local outtemp=tonumber(fibaro:getValue(36, "value"))

fibaro:debug(tonumber(target2))

fibaro:debug(tonumber(outTemp))

fibaro:call(202, "setProperty", "ui.lblTempout.value", outTemp)

fibaro:call(202, "setProperty", "ui.lblTarget.value", target2)

fibaro:call(202, "setProperty", "ui.lblTempExt.value", extTemp)

fibaro:call(202, "setProperty", "ui.lblVentiil.value", ventiil)

fibaro:call(202, "setProperty", "ui.lblHyst.value", hysteresis)

if target2 - outTemp > hysteresis then

--peab kütma

if ventiil<=99 then

fibaro:debug("kütame,erinevus: "..target2 - outTemp)

fibaro:debug("must HEAT")

fibaro:call(203, "setValue", ventiil+1)

fibaro:sleep(1000*10)

else

--fibaro:call(203, "open")

fibaro:debug("ventiil avatud :"..ventiil)

end

else

if ventiil>=1 then

fibaro:debug("jahutame,erinevus: "..target2 - outTemp)

fibaro:debug("must COOL")

fibaro:call(203, "setValue", ventiil-1)

fibaro:sleep(1000*10)

else

--fibaro:call(203, "close")

fibaro:debug("ventiil suletud: "..ventiil)

end

--fibaro:sleep(1000)

end

Lauri

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0
Guest GG
%% properties

203 value

I think the problem is that yopu have 203 value under %%properties.

This makes this scene trigger each time the value of that device changes.

In your case, when you

fibaro:call(203, "setValue", ventiil+1)

the scene will be triggered again.

Remove 203 value from %%properties and it sould work better.

Link to comment
Share on other sites

  • 0

Everything is OK, but opening and closing the valve is not 1% and 10sec interval instead it opens valve 10-20% in one sec and this is not good.

Hi,

put

Please login or register to see this code.

at the top or it will run many times and you will therefore change the settings in very quick time. The scenes can run multiple instances at a time. That is good in some instances but be careful not to allow this when you do not want it. You do not for this.

Nice bit of code though.

You could also consider using a version of

Please login or register to see this link.

dawn simulator but would need some changes.

Please login or register to see this code.

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Hello,

    Thanks alot guys, I did both and now it seems to be working really well

    Please login or register to see this image.

    /emoticons/default_icon_cool.gif" alt="8-)" />

    I use this to control 3way walve whichs is responsible for keeping underfloor heating water temperature according outside temp.

    Thanks again!

    Lauri

    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.

    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.

    ×
    ×
    • Create New...