String operationen

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
Opus
Posts: 21
Joined: Monday 05 October 2015 9:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

String operationen

Post 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)
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: String operationen

Post 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)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: String operationen

Post 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 ])

Opus
Posts: 21
Joined: Monday 05 October 2015 9:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: String operationen

Post by Opus »

Thank you!
I will try it tomorrow.

Thumps up!
Opus
Posts: 21
Joined: Monday 05 October 2015 9:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: String operationen

Post by Opus »

It works fine!

Nice community!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest