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

Is it possible to shrink my LUA-code and use variables(HC3)?


Question

Posted

This LUA-scen is what i can produce with my skills for now. I think sloppycode is the term for my LUA....
I converted one of many Block Scens (20 scens one for each setpoint) to LUA. With LUA-manual and reading forum i came to this solution.
I do not know if i provide needed information for getting help.

 

Problem 1: Is it possible to shrink the LUA?

Problem 2: I need a variable named local tempadjloc with a value that i can add to --fibaro.call(1792, 'setValue', 10+local tempadjloc)

Problem 3: I need a global variable named tempadjglo and qubinodimvalueglo to use in other scens.

 

PS! Before my funeral i hope to learn program QA, for now it seems that QA will be my funeral. At least a mental meltdown....

 

Declaration:

{
  conditions = { {
      id = 1828,
      isTrigger = false,
      operator = ">=",
      property = "heatingThermostatSetpoint",
      type = "device",
      value = 10
    }, {
      id = 1828,
      isTrigger = true,
      operator = "<=",
      property = "heatingThermostatSetpoint",
      type = "device",
      value = 30
    } },
  operator = "all"
}

 

Action:

----------------------testing-----------------
print("----Test variabel----")
print(fibaro.getGlobalVariable("sovter", value))
print("SOVTER", sovter) 
--tonumber(fibaro.setGlobalVariable('sovter', 20))
print("SOVTER", sovter) 
--tonumber(fibaro.setGlobalVariable("globtempqub1:"=r"))
local sovter = sovter 
local tempqub1 = (fibaro.getValue(1828, "heatingThermostatSetpoint")+10); 
print("tempqub1:", tempqub1)
----------------------all above testing-----------------
 
--LUA SCEN HC3
print("----Element with heatregulator 0-10v connected to qubino 0-10v dimmer----")
print("----Change value of dimmer with thermostat setpoint----")
print("----Dimmer also adjusted with variable not known for now and not working----")
--local adjustment = 50 working
--fibaro.call(1792, 'setValue', 10+local tempadjust) not working
print("ELEMENT: " , fibaro.getValue(1792, "value"));
print("SOVTHERMOSTAT: " , fibaro.getValue(1828, "heatingThermostatSetpoint"));
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 10 then;
fibaro.call(1792, 'setValue', 10)
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 11 then;
fibaro.call(1792, 'setValue', 11)
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 12 then;
fibaro.call(1792, 'setValue', 12)
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 13 then;
fibaro.call(1792, 'setValue', 13)
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 14 then;
fibaro.call(1792, 'setValue', 14)
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 15 then;
fibaro.call(1792, 'setValue', 15)
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 16 then;
fibaro.call(1792, 'setValue', 16);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 17 then;
fibaro.call(1792, 'setValue', 17);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 18 then;
fibaro.call(1792, 'setValue', 18);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 19 then;
fibaro.call(1792, 'setValue', 19);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 20 then;
fibaro.call(1792, 'setValue', 20);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 21 then;
fibaro.call(1792, 'setValue', 21);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 22 then;
fibaro.call(1792, 'setValue', 22);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 23 then;
fibaro.call(1792, 'setValue', 23);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 24 then;
fibaro.call(1792, 'setValue', 24);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 25 then;
fibaro.call(1792, 'setValue', 25);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 26 then;
fibaro.call(1792, 'setValue', 26);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 27 then;
fibaro.call(1792, 'setValue', 27);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 28 then;
fibaro.call(1792, 'setValue', 28);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 29 then;
fibaro.call(1792, 'setValue', 29);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 30 then;
fibaro.call(1792, 'setValue', 30);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) < 10 or
    tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) > 30 then
    print("Element not adjusted, thermostats setpoint is to low or to high <10 or >30")
    end
 
 

1 answer to this question

Recommended Posts

  • 0
Posted
25 minutes ago, EveWes said:

This LUA-scen is what i can produce with my skills for now. I think sloppycode is the term for my LUA....
I converted one of many Block Scens (20 scens one for each setpoint) to LUA. With LUA-manual and reading forum i came to this solution.
I do not know if i provide needed information for getting help.

 

Problem 1: Is it possible to shrink the LUA?

Problem 2: I need a variable named local tempadjloc with a value that i can add to --fibaro.call(1792, 'setValue', 10+local tempadjloc)

Problem 3: I need a global variable named tempadjglo and qubinodimvalueglo to use in other scens.

 

PS! Before my funeral i hope to learn program QA, for now it seems that QA will be my funeral. At least a mental meltdown....

 

Declaration:

{
  conditions = { {
      id = 1828,
      isTrigger = false,
      operator = ">=",
      property = "heatingThermostatSetpoint",
      type = "device",
      value = 10
    }, {
      id = 1828,
      isTrigger = true,
      operator = "<=",
      property = "heatingThermostatSetpoint",
      type = "device",
      value = 30
    } },
  operator = "all"
}

 

Action:

----------------------testing-----------------
print("----Test variabel----")
print(fibaro.getGlobalVariable("sovter", value))
print("SOVTER", sovter) 
--tonumber(fibaro.setGlobalVariable('sovter', 20))
print("SOVTER", sovter) 
--tonumber(fibaro.setGlobalVariable("globtempqub1:"=r"))
local sovter = sovter 
local tempqub1 = (fibaro.getValue(1828, "heatingThermostatSetpoint")+10); 
print("tempqub1:", tempqub1)
----------------------all above testing-----------------
 
--LUA SCEN HC3
print("----Element with heatregulator 0-10v connected to qubino 0-10v dimmer----")
print("----Change value of dimmer with thermostat setpoint----")
print("----Dimmer also adjusted with variable not known for now and not working----")
--local adjustment = 50 working
--fibaro.call(1792, 'setValue', 10+local tempadjust) not working
print("ELEMENT: " , fibaro.getValue(1792, "value"));
print("SOVTHERMOSTAT: " , fibaro.getValue(1828, "heatingThermostatSetpoint"));
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 10 then;
fibaro.call(1792, 'setValue', 10)
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 11 then;
fibaro.call(1792, 'setValue', 11)
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 12 then;
fibaro.call(1792, 'setValue', 12)
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 13 then;
fibaro.call(1792, 'setValue', 13)
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 14 then;
fibaro.call(1792, 'setValue', 14)
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 15 then;
fibaro.call(1792, 'setValue', 15)
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 16 then;
fibaro.call(1792, 'setValue', 16);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 17 then;
fibaro.call(1792, 'setValue', 17);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 18 then;
fibaro.call(1792, 'setValue', 18);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 19 then;
fibaro.call(1792, 'setValue', 19);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 20 then;
fibaro.call(1792, 'setValue', 20);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 21 then;
fibaro.call(1792, 'setValue', 21);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 22 then;
fibaro.call(1792, 'setValue', 22);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 23 then;
fibaro.call(1792, 'setValue', 23);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 24 then;
fibaro.call(1792, 'setValue', 24);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 25 then;
fibaro.call(1792, 'setValue', 25);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 26 then;
fibaro.call(1792, 'setValue', 26);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 27 then;
fibaro.call(1792, 'setValue', 27);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 28 then;
fibaro.call(1792, 'setValue', 28);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 29 then;
fibaro.call(1792, 'setValue', 29);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) == 30 then;
fibaro.call(1792, 'setValue', 30);
    print("New element temp: " , fibaro.getValue(1792, "value"));
end
if tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) < 10 or
    tonumber(fibaro.getValue(1828, "heatingThermostatSetpoint")) > 30 then
    print("Element not adjusted, thermostats setpoint is to low or to high <10 or >30")
    end
 
 

You can start with this simplification

Please login or register to see this code.

 

Something like 

fibaro.call(1792, 'setValue', 10+tempadjust)

should work, but I'm a bit unsure about what you want to accomplish

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