Page 1 of 1

combine strings

Posted: Thursday 29 March 2018 22:49
by jandirkv
Hello,

I want to combine two textstrings in dzvents but I cant get it to work.

I want to combine a piece of a url (http://api.pilot.patrickferreira.com/w6PLXsg32Dy/') with a piece of text to create a url that I can open in dzvents to send a notification. is this possible in dzvents?

Re: combine strings

Posted: Thursday 29 March 2018 23:02
by waaren
Combine strings in dzVents ( dzVents = LUA)

resultString = string1 .. string2

Re: combine strings

Posted: Friday 30 March 2018 8:31
by jandirkv
Thanks the combining works so I'm 1 step closer.

What is try to do is add the time in my message. I tried it like this.

Code: Select all

local setURL
local Header
local Message
local MessageURL
local Now

	Now = domoticz.time
            setURL=('http://api.pilot.patrickferreira.com/w6PsfgLXh32Dy/')
            Header=('de lamp is niet meer/')
            Message=('aan sinds ')
            MessageURL= setURL .. Header .. Message .. Now
            domoticz.openURL(MessageURL)
This is working as long as I only use text. as soon as I try to incorperate the time from domoticz I get the following error.
attempt to concatenate upvalue 'Now'
or
Attempt to call Global time
So what I try to do is convert The time to a textstring so i can use it in my url variable

Re: combine strings

Posted: Friday 30 March 2018 14:26
by waaren
In dzVents, a time-like attribute is an object with properties and methods meaning you have to specify what you want from it.

Code: Select all

Now = domoticz.time
print("************* getISO(): " .. Now.getISO())
print("************* hour: " .. Now.hour)
print("************* seconds: " .. Now.seconds )
print("************* minutes: " .. Now.minutes )
print("************* combined: " .. Now.hour .. ":" .. Now.minutes .. ":" .. Now.seconds )

Re: combine strings

Posted: Friday 30 March 2018 18:14
by jandirkv
thanks
the following did work for me.

Code: Select all

now= (Now.hour .. ":" .. Now.minutes .. ":" .. Now.seconds )