combine strings

Moderator: leecollings

Post Reply
jandirkv
Posts: 27
Joined: Monday 19 February 2018 6:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9117
Contact:

combine strings

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

Re: combine strings

Post by waaren »

Combine strings in dzVents ( dzVents = LUA)

resultString = string1 .. string2
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
jandirkv
Posts: 27
Joined: Monday 19 February 2018 6:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9117
Contact:

Re: combine strings

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

Re: combine strings

Post 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 )
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
jandirkv
Posts: 27
Joined: Monday 19 February 2018 6:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9117
Contact:

Re: combine strings

Post by jandirkv »

thanks
the following did work for me.

Code: Select all

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

Who is online

Users browsing this forum: No registered users and 1 guest