Logic Machine Forum
Scripting - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Scripting (/showthread.php?tid=5848)

Pages: 1 2


Scripting - mariosp - 16.01.2025

Hello guys i made a script and i need you help 
I have underfloor heating and i want to make zones o pwm vavles . what i mean that if the setpoint bigger than the actual temperature by 1C then the valves must be open 100% , if the setpoint bigger than the actual temperature by 0.7 C then the valves must be open 75% and so on.
here is the scrpict that i made but doest work and i dont get any error 

-- zone* = value of the valve
zone0 = 0
  zone1 = 25
  zone2 = 50
  zone3 = 75
  zone4 = 100
-- 3/1/1 set point
-- 12/0/5 actual temperature
  if grp.getvalue('3/1/1') > grp.getvalue('12/0/5') - 1
    then grp.write('4/1/1',zone4)
      elseif
          grp.getvalue('3/1/1') > grp.getvalue('12/0/5') - 0.7
            then grp.write('4/1/1',zone3)
              elseif
                  grp.getvalue('3/1/1') > grp.getvalue('12/0/5') - 0.5
                  then grp.write('4/1/1',zone2)
                    elseif
                  grp.getvalue('3/1/1') > grp.getvalue('12/0/5') - 0.3
                then grp.write('4/1/1',zone1)             
            elseif
          (grp.getvalue'3/1/1') == grp.getvalue('12/0/5')
      then grp.write('4/1/1',zone0)
 
   
end
thank you in advance


RE: Scripting - RomansP - 16.01.2025

Hello mariosp

You should create event script with tag, and this tag should be for two group addresses
for actual temperature object and for temperature set point

Code:
local actual_temp = grp.getvalue('12/0/5')
local setpoint = grp.getvalue('3/1/1')
local pwm_addr = '4/1/1'

local zone0 = 0
local zone1 = 25
local zone2 = 50
local zone3 = 75
local zone4 = 100

local temp_diff = setpoint - actual_temp

--log(temp_diff)

if temp_diff >= 1 then
  grp.write(pwm_addr, zone4)
elseif temp_diff >= 0.7 then
  grp.write(pwm_addr, zone3)
elseif temp_diff >= 0.5 then
  grp.write(pwm_addr, zone2)
elseif temp_diff >= 0.3 then
  grp.write(pwm_addr, zone1)
else
  grp.write(pwm_addr, zone0)
end



RE: Scripting - mariosp - 16.01.2025

(16.01.2025, 10:05)RomansP Wrote: Hello mariosp

You should create event script with tag, and this tag should be for two group addresses
for actual temperature object and for temperature set point

Code:
local actual_temp = grp.getvalue('12/0/5')
local setpoint = grp.getvalue('3/1/1')
local pwm_addr = '4/1/1'

local zone0 = 0
local zone1 = 25
local zone2 = 50
local zone3 = 75
local zone4 = 100

local temp_diff = setpoint - actual_temp

--log(temp_diff)

if temp_diff >= 1 then
  grp.write(pwm_addr, zone4)
elseif temp_diff >= 0.7 then
  grp.write(pwm_addr, zone3)
elseif temp_diff >= 0.5 then
  grp.write(pwm_addr, zone2)
elseif temp_diff >= 0.3 then
  grp.write(pwm_addr, zone1)
else
  grp.write(pwm_addr, zone0)
end
To many telegreams with result bus and cpu/io overload


RE: Scripting - Daniel - 16.01.2025

Make sure you only tag the '12/0/5' and '3/1/1' but not '4/1/1'


RE: Scripting - mariosp - 16.01.2025

(16.01.2025, 11:02)Daniel Wrote: Make sure you only tag the '12/0/5' and '3/1/1' but not '4/1/1'
yes that was for oveload but even when the actual temperature > setpoint open the valve


RE: Scripting - Daniel - 16.01.2025

What is 1.1.50 Dummy?


RE: Scripting - mariosp - 16.01.2025

(16.01.2025, 11:29)Daniel Wrote: What is 1.1.50 Dummy?

dummy is Lm you simple put it ets for filter table


RE: Scripting - Daniel - 16.01.2025

Reboot LM and if still the same then drop some screenshots how you created the script.


RE: Scripting - mariosp - 16.01.2025

(16.01.2025, 11:43)Daniel Wrote: Reboot LM and if still the same then drop some screenshots how you created the script.
Thanks its ok now !! 
can you describe when we must you use loac?


RE: Scripting - RomansP - 16.01.2025

Do you mean local variables?


RE: Scripting - mariosp - 16.01.2025

(16.01.2025, 11:59)RomansP Wrote: Do you mean local variables?
yes im trying to understand the difference between local and global


RE: Scripting - RomansP - 16.01.2025

local - is used when variable should not be global (by default variables in lua are global)

here is a good resource for a start (to understand really basics of lua language)

https://learnxinyminutes.com/lua/


RE: Scripting - mariosp - 16.01.2025

(16.01.2025, 12:09)RomansP Wrote: local - is used when variable should not be global (by default variables in lua are global)

here is a good resource for a start (to understand really basics of lua language)

https://learnxinyminutes.com/lua/

thank you !!!


RE: Scripting - Daniel - 16.01.2025

For you, you can ignore the Local declaration as variables in a script are only in this script. You cannot use them anywhere else. For this script it makes no difference but it is a good programing practice.


RE: Scripting - RomansP - 16.01.2025

But in this type of script variables are only in this one script.
In LogicMachine it only make sense to use local declaration if you use
loops or functions. But for me putting local in this script is just like a
good practice, to do not use global variables.


RE: Scripting - mariosp - 17.01.2025

(16.01.2025, 12:26)RomansP Wrote: But in this type of script variables are only in this one script.
In LogicMachine it only make sense to use local declaration if you use
loops or functions. But for me putting local in this script is just like a
good practice, to do not use global variables.
Hello again unfortunately this doesnt work for me the script works fine but the heating actuator doesnt chages the actual value but only the status!
can you you help me write a script that i will write the value of the actual temperature to another group address but with -1C temperature lower i made this but doesnt work! thank you in advance!
Code:
local actual_temp = ('12/0/1')
local fake_temp_adr = ('32/1/68')
local value = ('12/0/1')-(1)
if grp.getvalue('32/1/66',1)
  then
  grp.write('32/1/68',value)
  else log()
 
  end



RE: Scripting - RomansP - 17.01.2025

Hi

If I understood you correctly, each time when will be new temperature value,
then this value will be subtracted by 1, and sent to another group address.
Then just create an event script for temperature object '12/0/1'

Code:
local value_temp = event.getvalue()
local fake_temp_addr = '32/1/68'

grp.write(fake_temp_addr, value_temp - 1)



RE: Scripting - mariosp - 18.01.2025

thank you for your help! I will heed your you help once again 
I ended up with the below script that is a event based on the setpoint to change the offset but only if the actual temperature is higher than the setpoint here is the script that i made that doesnt work.
Code:
local setpoint = event.getvalue()
local actual_temp = '12/0/5'
local zone1 = grp.getvalue('3/3/1') - (0.1)
local temp_diff = setpoint - actual_temp


   if temp_diff <= 0.1
  then grp.write('3/3/1',zone1)

end


thank you advance


RE: Scripting - baggins - 18.01.2025

(18.01.2025, 08:14)mariosp Wrote: thank you for your help! I will heed your you help once again 
I ended up with the below script that is a event based on the setpoint to change the offset but only if the actual temperature is higher than the setpoint here is the script that i made that doesnt work.
Code:
local setpoint = event.getvalue()
local actual_temp = '12/0/5'
local zone1 = grp.getvalue('3/3/1') - (0.1)
local temp_diff = setpoint - actual_temp


   if temp_diff <= 0.1
  then grp.write('3/3/1',zone1)

end


thank you advance
local actual_temp = grp.getvalue('12/0/5')


RE: Scripting - mariosp - 18.01.2025

I already try that is not the issue.