Page 1 of 1

String operationen

Posted: Wednesday 15 July 2020 16:54
by Opus
I have a lump in my head. how can I translate this from LUA to dzvents ?:

z = otherdevices_svalues['PoolZulauf']
k = string.find(z," ")
z = string.sub(z,1,k-1)
TZulauf = tonumber(z)

Re: String operationen

Posted: Wednesday 15 July 2020 17:47
by waaren
Opus wrote: Wednesday 15 July 2020 16:54 I have a lump in my head. how can I translate this from LUA to dzvents ?:

Code: Select all

        z = otherdevices_svalues['PoolZulauf']
        k = string.find(z," ")
        z = string.sub(z,1,k-1)
        TZulauf = tonumber(z)
This should do it

Code: Select all

local z = domoticz.devices('PoolZulauf').sValue
local k = string.find(z," ")
z = string.sub(z,1,k-1)
local TZulauf = tonumber(z)

Re: String operationen

Posted: Wednesday 15 July 2020 17:58
by jake

Opus wrote:I have a lump in my head. how can I translate this from LUA to dzvents ?:

z = otherdevices_svalues['PoolZulauf']
k = string.find(z," ")
z = string.sub(z,1,k-1)
TZulauf = tonumber(z)
z = domoticz.devices('PoolZulauf').sValue
k = string.find(z," ")
z = string.sub(z,1,k-1)
TZulauf = tonumber(z)

You can keep using the existing lua functions.
Please check the dzvents wiki for a function like stringSplit(string, [separator ])


Re: String operationen

Posted: Wednesday 15 July 2020 18:59
by Opus
Thank you!
I will try it tomorrow.

Thumps up!

Re: String operationen

Posted: Wednesday 15 July 2020 23:43
by Opus
It works fine!

Nice community!