combine strings

Post Reply
jandirkv
Posts: 22
Joined: Monday 19 February 2018 7:20
Target OS: Raspberry Pi
Domoticz version: 3.9117
Contact:

combine strings

Post by jandirkv » Thursday 29 March 2018 22:49

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: 796
Joined: Tuesday 03 January 2017 15:18
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: combine strings

Post by waaren » Thursday 29 March 2018 23:02

Combine strings in dzVents ( dzVents = LUA)

resultString = string1 .. string2
Raspberry (debian stretch via berryboot on Synology DS916+) , Domoticz (almost) latest Beta, , dzVents 2.6, RFLink, RFXtrx433e, P1, Youless, Harmony, Hue, Yeelight, Xiaomi, HomeWizard, Zwave, Amazon echo

jandirkv
Posts: 22
Joined: Monday 19 February 2018 7:20
Target OS: Raspberry Pi
Domoticz version: 3.9117
Contact:

Re: combine strings

Post by jandirkv » Friday 30 March 2018 8:31

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: 796
Joined: Tuesday 03 January 2017 15:18
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: combine strings

Post by waaren » Friday 30 March 2018 14:26

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 )
Raspberry (debian stretch via berryboot on Synology DS916+) , Domoticz (almost) latest Beta, , dzVents 2.6, RFLink, RFXtrx433e, P1, Youless, Harmony, Hue, Yeelight, Xiaomi, HomeWizard, Zwave, Amazon echo

jandirkv
Posts: 22
Joined: Monday 19 February 2018 7:20
Target OS: Raspberry Pi
Domoticz version: 3.9117
Contact:

Re: combine strings

Post by jandirkv » Friday 30 March 2018 18:14

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