On FOR variable possible?

Moderator: leecollings

Post Reply
SiSu82
Posts: 5
Joined: Monday 18 January 2016 14:55
Target OS: Linux
Domoticz version:
Contact:

On FOR variable possible?

Post by SiSu82 »

Im doing some simple math in a lua and trying to set a switch ON for the calculated time

commandArray['Lamptest'] = 'On FOR testtime'

testtime is in this case a local variable in the lua script, whitch aint working, is it even possible?
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: On FOR variable possible?

Post by jvdz »

Assuming testtime is a variable in LUA this should work fine:

Code: Select all

commandArray['Lamptest'] = 'On FOR ' .. tostring(testtime)
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
SiSu82
Posts: 5
Joined: Monday 18 January 2016 14:55
Target OS: Linux
Domoticz version:
Contact:

Re: On FOR variable possible?

Post by SiSu82 »

jvdz wrote:Assuming testtime is a variable in LUA this should work fine:

Code: Select all

commandArray['Lamptest'] = 'On FOR ' .. tostring(testtime)
Jos
Thx alot Jos
User avatar
havnegata
Posts: 114
Joined: Wednesday 10 September 2014 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10162
Location: Norway
Contact:

Re: On FOR variable possible?

Post by havnegata »

Trying to understand the concept of variable. Why is it an advantage to use a variable in your script instead of just f.ex 'On FOR 5' ?
SiSu82
Posts: 5
Joined: Monday 18 January 2016 14:55
Target OS: Linux
Domoticz version:
Contact:

Re: On FOR variable possible?

Post by SiSu82 »

havnegata wrote:Trying to understand the concept of variable. Why is it an advantage to use a variable in your script instead of just f.ex 'On FOR 5' ?
Because im doing some math in the LUA script depending on how cold it is outside, whitch makes me wanna put a switch on for X min.

On FOR xxx Minutes would ofc work but better to use the calculated value instead.
User avatar
havnegata
Posts: 114
Joined: Wednesday 10 September 2014 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10162
Location: Norway
Contact:

Re: On FOR variable possible?

Post by havnegata »

Thanks for the reply, I'm beginning to understand, but can you please post the code, that way it's possible to get a greater understanding :-)
SiSu82
Posts: 5
Joined: Monday 18 January 2016 14:55
Target OS: Linux
Domoticz version:
Contact:

Re: On FOR variable possible?

Post by SiSu82 »

havnegata wrote:Thanks for the reply, I'm beginning to understand, but can you please post the code, that way it's possible to get a greater understanding :-)
Will post it later this weekend, atm im doing some small changes to the code =)
User avatar
havnegata
Posts: 114
Joined: Wednesday 10 September 2014 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10162
Location: Norway
Contact:

Re: On FOR variable possible?

Post by havnegata »

Thanks, awaiting :-)

Sent fra min Nexus 7 via Tapatalk
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest