a have made 2 micro switches in my mailbox.
one for when the mailman puts something in, and one if i open it to empty it.
i have a counter in the lua script that counts the times the mailman puts something in.
and when i open the mailbox it resets the counter.
i completely "stole" the lua script becouse i am a biginner and i can modify a little but cant create my own.
i created a uservariable that counts the amount of mail
i receive an email when the mailman puts something in but i want the number in the mail as well,but i cant get it to work.
i want something like this: you have (number) pieces of mail
this is the script:
commandArray = {}
x = uservariables["postteller"] + 1
if (otherdevices['brievenbus'] == 'On') then
commandArray['Variable:postteller'] = tostring(x)
print (x)
commandArray['SendEmail']='post#er is post bezorgd#[email protected]'
end
if (otherdevices['brievenbus leeg'] == 'On') then
commandArray['Variable:postteller'] = tostring(0)
print ('brievenbus is geleegd, teller naar 0')
commandArray['SendEmail']='post#de brievenbus is geleegd, teller is gereset#[email protected]'
end
return commandArray
lua user variable number in email
Moderator: leecollings
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: lua user variable number in email
Using dzVents it would be like this (no user variables needed):
Code: Select all
return {
active = true,
on = {
'brievenbus',
'brievenbus leeg'
},
data = {
postTeller = { initial = 0 }
},
execute = function(domoticz, device)
if (device.name == 'brievenbus' and device.state == 'On') then
-- brievenbus was triggered
domoticz.data.postTeller = domoticz.data.postTeller + 1
domoticz.email('Post', 'Er is post bezorgd. Teller: ' .. tostring(domoticz.data.postTeller), '[email protected]')
elseif (device.state == 'On') then
-- brievenbus leeg was triggered
domoticz.data.postTeller = 0
domoticz.email('Post', 'De brievenbus is geleegd. Teller is gereset', '[email protected]')
end
end
}
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 159
- Joined: Friday 27 May 2016 20:15
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: nederland
- Contact:
Re: lua user variable number in email
thanks for your effort but cant i just use my lua script??
a have a second problem.i want to send an email to 2 emailadresses.i do it like this:
commandArray = {}
x = uservariables["postteller"] + 1
if (otherdevices['brievenbus'] == 'On') then
commandArray['Variable:postteller'] = tostring(x)
print (x)
commandArray['SendEmail']='post#er is post bezorgd#[email protected]'
commandArray['SendEmail']='post#er is post bezorgd#[email protected]'
end
what am i doing wrong becouse only the 2nd email adres is getting the email.i tryed to switch the adresses or use an other one but only the 2nd in line gets the email.
a have a second problem.i want to send an email to 2 emailadresses.i do it like this:
commandArray = {}
x = uservariables["postteller"] + 1
if (otherdevices['brievenbus'] == 'On') then
commandArray['Variable:postteller'] = tostring(x)
print (x)
commandArray['SendEmail']='post#er is post bezorgd#[email protected]'
commandArray['SendEmail']='post#er is post bezorgd#[email protected]'
end
what am i doing wrong becouse only the 2nd email adres is getting the email.i tryed to switch the adresses or use an other one but only the 2nd in line gets the email.
- jvdz
- Posts: 2333
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: lua user variable number in email
Try:
Jos
Code: Select all
commandArray[1]={['SendEmail']='post#er is post bezorgd#[email protected]' }
commandArray[2]={['SendEmail']='post#er is post bezorgd#[email protected]' }
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: lua user variable number in email
Of course you can use your own Lua script. Just showing you that things can be done a lot easier. Easier to learn, easier to read.tiga wrote:thanks for your effort but cant i just use my lua script??
a have a second problem.i want to send an email to 2 emailadresses.i do it like this:
commandArray = {}
x = uservariables["postteller"] + 1
if (otherdevices['brievenbus'] == 'On') then
commandArray['Variable:postteller'] = tostring(x)
print (x)
commandArray['SendEmail']='post#er is post bezorgd#[email protected]'
commandArray['SendEmail']='post#er is post bezorgd#[email protected]'
end
what am i doing wrong becouse only the 2nd email adres is getting the email.i tryed to switch the adresses or use an other one but only the 2nd in line gets the email.
Anyway, you can concatenate strings in Lua like this:
Code: Select all
commandArray['SendEmail']='post#er is post bezorgd.Teller:' .. tostring(x) .. '#[email protected]'
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 159
- Joined: Friday 27 May 2016 20:15
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: nederland
- Contact:
Re: lua user variable number in email
ok thank you verry much for all your effort!
i will take a look at dcvents maybe that is better for a new person like me
i will take a look at dcvents maybe that is better for a new person like me

Who is online
Users browsing this forum: No registered users and 1 guest