The Vera Community forums have moved!

Advanced => Programming => Plugins & Plugin Development => Topic started by: Ap15e on May 27, 2011, 05:13:48 pm

Title: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: Ap15e on May 27, 2011, 05:13:48 pm
EOL, unsupported.

Installation:

Usage:

History:
V0.2   fix for DeviceType (thanks to oTi@), UPnP parameters: subject, body
V0.3   update for UI5
V0.3a removed isSingle from static json file for compatibility with UI4

Remarks:

Download:
https://docs.google.com/open?id=0Bz4omZm4gYcsNWM0MDc5MDQtMzI3OC00YjA3LThkMTUtYTlmNWVlMWY2YTg4
Title: Re: [_CODE_] SND - SMTP Notification Device
Post by: Henk on May 27, 2011, 05:17:56 pm
Ok, so a generic device to call upon for notifications instead of having to implement the code for every device one needs notifications from...

That should cut down in duplicate code and Lua load....

Thanks @Ap15e

Ill set it up and let you know how it works!

--- edit---
first remark, downloading now works without having to sign in! Thats 1 improvement!!!

---edit 2--
Where would the luup line mentioned under usage go? In the luup code tab/field of a created event?
That is how i created it and it doenst send messages on the trigger set

--edit 3--
In the original code i had to comment out the AUTH lines since my SMTP server doesnt require them.
Now i have two emtpy fields in SND and am of course unable to comment then out of the code.
I remember that email didnt work with the lines of code active without input....
Can this be the reason why no messages sent so far?
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge)
Post by: JOD on May 27, 2011, 11:13:52 pm
@Henk, did you change the device number of the code to match the SND device that was created?
(luup.call_action( "urn:upnp-ap15e-com:serviceId:SND1", "SendMail", { message = 'Message from Vera' }, 11 )

*(replace 11 with the SND device ID.)

@Ap15e, works great.
"Message from Vera" appears in the emails subject (which is easily changed for the event)
Each of the 12 test emails generated had a single random letter or number in the body of the email when they were received.
w,u,5,a,d,c,u,m,o,f,0,5

JOD.
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge)
Post by: oTi@ on May 28, 2011, 01:13:14 am
Yup, works!

Didn't get any random characters; body claimed empty by email reader.

F/R: customizable body (or perhaps switch to select whether message goes into subject or body).
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge)
Post by: Henk on May 28, 2011, 04:14:24 am
@Henk, did you change the device number of the code to match the SND device that was created?
(luup.call_action( "urn:upnp-ap15e-com:serviceId:SND1", "SendMail", { message = 'Message from Vera' }, 11 )

*(replace 11 with the SND device ID.)

JOD.

@JOD yes i did, i used the device ID of the light that i was switching (15) and yes i know that was not the idea
and yes i used the ID of SND (24). No messages on both settingchanges
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge)
Post by: Henk on May 28, 2011, 04:16:20 am
Got it to work!
Seemingly there are some spaces in the code when cutting and pasting it.
After removing the space after the SND device Id my messages started coming.

--edit--
Messages sent YES, messages received 0
Do i need to set the variables within quotes? (like "send.this@email.eu") and SMTPport "25"???

Strange thing is, ADD sends hearbeats perfectly with exactly the same settings as i used in SND

Q. Can the number of sent messages be purged?
A. Yes, by manually changing it back to 0 in the advanced tab

Q. Can ADD use this device too so that only one UpNP-SMTP bridge/code is needed in the system?

Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.2
Post by: Ap15e on May 28, 2011, 06:26:37 am
SND V0.2 is available. Syntax has changed, see topmost post.
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.2
Post by: oTi@ on May 28, 2011, 07:08:28 am
SND V0.2 is available. Syntax has changed, see topmost post.
Nice; thanks! Works.

F/R: Prowl integration, or the PND cousin of this. :)
(I guess @axill's earlier work (http://forum.micasaverde.com/index.php?topic=6169.msg40871#msg40871) may be a reference.)
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.2
Post by: Henk on May 28, 2011, 11:51:03 am
@Ap15e & @oTi@

I must look silly.... but i cant receive the email (ADD works...). I can only deduce that it isnt being sent by SND.
I SEE the SND device working (message counter stacks) so i know the luupcode in the event is working (with correct SND device ID)

I've tried everything from retyping all variables, stated the IP instead of name of my SMTP host
Set username/password to 0, tried "" in those fields... nothing!

I know for a fact this was the same issue i had with my ADD device, not mailing heartbeats.
I solved this by completly commenting out the AUTH_USER & SMTP_AUTH lines like shown below.

Code: [Select]
 local SMTP_SERVER = "my.smtp.host"
-- local SMTP_AUTH_USER = ""
-- local SMTP_AUTH_PW = ""        
  local SMTP_PORT = "25"
  local USER_SENDING = "sender@my.vera"
  local USER_RECEIVING = "receiver@gmail.com"

Only after actually commenting out the code, did my ADD device start to send heartbeats.
The only thing i can imagine now is that these fields are in the SND code and my SMTP host doesnt accept the empty request. Can i try and remove them from the apropriate xml to troubleshoot?
I know ill loose the variables then, but thats less bothersome than not receiving the notifications.

Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.2
Post by: Henk on May 28, 2011, 12:12:12 pm
YESSS!!!!

I edited the I_SND.xml and commented out these sections:

Code: [Select]
--- local SMTP_auth_user    
--- local SMTP_auth_password

---  SMTP_auth_user     = get_variable( SND_SERVICE, 'SMTPAuthUser'    , SND_DEVICE, ''   )
---  SMTP_auth_password = get_variable( SND_SERVICE, 'SMTPAuthPassword', SND_DEVICE, ''   )

---                               user     = SMTP_auth_user,
---                               password = SMTP_auth_password

And Bingo!!!! my mail notifications work.

Because i didnt need it after that i also edited the S_SND.xml and commented out this:
Code: [Select]
--  <stateVariable>
--    <name>SMTPAuthUser</name>
--    <sendEventsAttribute>no</sendEventsAttribute>
--    <dataType>string</dataType>
--    <defaultValue></defaultValue>
--    <shortCode>smtpauthuser</shortCode>
--  </stateVariable>

Whats left now is how to edit the json file... can i safely comment out stuff there?

@Ap15e
Is there another way to code this? or does it have to be hardcoded and users have to exclude the lines manually edit their xml files if they have the same issue i was having? Maybe you could code the variables in such a way that they only create output if there is actually data in the fields and not send the requests to the server emtpy?
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.2
Post by: Henk on May 28, 2011, 12:36:20 pm
Functionalitywise, is it possible to add variables to the textbody like timestamp, day of week etc?
If so, are there standard luup variables to use then? I took a look at the wiki and found something like "os time()"
/but how would i incorporate that into the body of the message?
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.2
Post by: oTi@ on May 28, 2011, 01:46:57 pm
YESSS!!!!
Excellent. For clarification, I use authentication on both my own server as well as my ISP's, so my situation is different. I do think this can be coded differently, although one could perhaps argue that the root problem is the robustness of the SMTP library.
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.2
Post by: JOD on May 29, 2011, 03:08:49 pm
SND V0.2

Email Subject: "Message from Vera #12XXX"
Email Body: "Front door unlocked"

Instant email notifications. Love it.

JOD.

Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.2
Post by: denix on June 01, 2011, 12:02:48 am
@Henk, you mentioned ADD, where I had the same issue:

http://forum.micasaverde.com/index.php?topic=5130.msg31677#msg31677
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.2
Post by: Henk on June 01, 2011, 03:32:25 am
@Henk, you mentioned ADD, where I had the same issue:

http://forum.micasaverde.com/index.php?topic=5130.msg31677#msg31677


@denix

Yes, and i solved it. In ADD comment out 2 lines using " --"
Here is the example:
Code: [Select]
 local SMTP_SERVER = "my.smtp.host"
-- local SMTP_AUTH_USER = ""
-- local SMTP_AUTH_PW = ""        
  local SMTP_PORT = "25"
  local USER_SENDING = "sender@my.vera"
  local USER_RECEIVING = "receiver@gmail.com"
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.2
Post by: cedriclocqueneux on June 01, 2011, 06:52:39 am
Does it work with Gmail smtp ?
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.2
Post by: Henk on June 01, 2011, 07:09:22 am
Does it work with Gmail smtp ?

I havent seen anyone post here that got Gmail to work on port 443 with SSL enabled.
Maybe i didnt look hard enough through the threads?

I got as far as
http://forum.micasaverde.com/index.php?PHPSESSID=3051091f7ca575ea0b5fa4154e82da97&topic=6309.msg40295#msg40295

Anyone found something that proves the contrary?
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.2
Post by: denix on June 01, 2011, 09:04:54 pm
@Henk, you mentioned ADD, where I had the same issue:

http://forum.micasaverde.com/index.php?topic=5130.msg31677#msg31677


@denix

Yes, and i solved it. In ADD comment out 2 lines using " --"
Here is the example:
Code: [Select]
 local SMTP_SERVER = "my.smtp.host"
-- local SMTP_AUTH_USER = ""
-- local SMTP_AUTH_PW = ""        
  local SMTP_PORT = "25"
  local USER_SENDING = "sender@my.vera"
  local USER_RECEIVING = "receiver@gmail.com"

I'm surprised it worked for you - I needed to patch the code (attached under provided link) for that to work...
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.2
Post by: oTi@ on June 01, 2011, 10:13:09 pm
I'm surprised it worked for you - I needed to patch the code (attached under provided link) for that to work...
@denix,
For SND @Henk did comment out the parts in the smtp.send() call (as well). And although not stated as such here, the same may be true for ADD, per @huogas' and @Henk's comments over there (http://forum.micasaverde.com/index.php?topic=5130.msg40005#msg40005) based on your findings.
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.2
Post by: gilles on December 28, 2011, 01:44:47 am
Hi,
it seems that SND isn't Ui5 compatible at all. The messages text on the device in the dashboard have dissapeared.

Same thing for home made plugins, normal ?

gilles

Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.2
Post by: Ap15e on December 28, 2011, 08:43:36 am
Quote
it seems that SND isn't Ui5 compatible at all.

SND and ADD work for me on Vera V2@1.5.255.

Quote
The messages text on the device in the dashboard have dissapeared.

Normal. MCV made changes to the layout manager for the dashboard (http://wiki.micasaverde.com/index.php/UI4_UI5_Migration#New_device_tags) that will break the dashboard presentation of most of the UI4 Luup plugins.
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.2
Post by: gilles on December 28, 2011, 01:10:16 pm
You're right it's functionnal.

So we have to rewrite UI4 plugins.

As I got you, I do a notification plugin with xmpp server called XFD (Xmpp Forwarder device). I use a base of your plugin and modify it. No problem with that?

Thank you for the link Iwill try to get my text working again in dashboard.

Envoyé depuis mon Flashback 7.1
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.2
Post by: Ap15e on December 28, 2011, 02:37:17 pm
Quote
As I got you, I do a notification plugin with xmpp server called XFD (Xmpp Forwarder device). I use a base of your plugin and modify it. No problem with that?

No problem with that - SND is based on original research by guessed, so you should ask guessed. :)

Quote
Thank you for the link Iwill try to get my text working again in dashboard.

Forget the wiki documentation, copy with pride from already ported Luup plugins -  and be prepared for a buggy implementation of the UI5 dashboard layout manager.
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.2
Post by: weissertigerxl on December 29, 2011, 09:02:33 am
Hi AP15e,

what is to be set at variable userSending, userReceiving?

Thanks
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.2
Post by: gilles on December 31, 2011, 12:14:14 pm
Hi Ap15e,

Unfortunatly,I try to implement my plugin or SND plugin in the layout with no success.

What I have to do exactly ? I've got a variable out of my plugin from my I_.....xml so I modify  my D_....json but not sure my syntax is ok.

From my experience the link in the wiki isn't too usefull.

Could you give me the way ...

an extract of my json:

Code: [Select]
"eventList2": [

        {

            "id": 1,

            "label": {

                "lang_tag": "NotificationsSent",

                "text": "Notifications: "

                     },

            "serviceId": "urn:upnp-gilles-com:serviceId:XFD1",

            "argumentList": [

                {

                    "id": 1,

                    "dataType": "string",

                    "name": "NotificationsSent",

                    "prefix": {},

                    "suffix": {},

                    "HumanFriendlyText": {

                        "lang_tag": "hft_Notifications_sent",

                        "text": "_DEVICE_NAME_ NotificationsSent _ARGUMENT_VALUE_"

                    }

                }

                           ]

        },

       

       

    ],



if my device is D_XFD the _DEVICE_NAME_ is ?????

Thank you

Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: Ap15e on January 28, 2012, 07:22:09 am
Please upgrade to SND V0.3a for compatibility with UI5.
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: ninux on February 08, 2012, 04:39:08 pm
Thank you for your plugin

How can I add a timestamp to the body of mail ?
I try this but il didn't work

Code: [Select]
local currentTime = os.date("*t")
luup.call_action( "urn:upnp-ap15e-com:serviceId:SND1", "SendMail", { subject = 'Message from Vera', body = 'Door open at '.. currentTime }, 29 )

What is the right syntax to add a variable ?

Thanks
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: ninux on February 09, 2012, 06:50:19 am
Hi found the solution
Code: [Select]
local currentTime = os.date("%c")
luup.call_action( "urn:upnp-ap15e-com:serviceId:SND1", "SendMail", { subject = 'Message from Vera', body = 'Door open at '.. currentTime }, 29 )
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: apt on February 15, 2012, 03:13:46 pm
Hi people,

I would like to use the plugin but I cannot get it to work at all. I've downloaded the 3a version. I'm installing it as described here: http://wiki.micasaverde.com/index.php/Install_LUUP_Plugins

I'm a little unsure about what to do at step 3:  Go to 'Create device' and create a new Luup device with UpnpDevFilename D_<your_plugin>.xml. I've used D_SND.xml and D_SND because the .xml extension wasn't used in the screenshot in http://forum.micasaverde.com/index.php?topic=6569.0

After step 4 of the install LUUP instruction I am a little unsure what to do: click the create device button below the fields or close with the x and click the reload  (curving arrows top right in your UI). I've tried both.

After rebooting and / or reloading and trying time and time again no device appear anywhere in the user interface.

I've gone through the procedure several times but I see no new device appearing. I'm on UI4 with the Vera2 with firmware 1.1.1245.

Could someone please be so kind as to see what I'm doing wrong here? Thanks, Arjan

Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: Ap15e on February 15, 2012, 04:43:43 pm
Uploading the files doesn't create the device, so you'll have to fill in an arbitrary device name and 'D_SND.xml' and press the 'Create device' button, then you'll have to restart the Lua engine several times. When the device is visible on the dashboard, press the tool icon to configure the SMTP variables, press SAVE and SND should be ready to use.
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: Otje on February 15, 2012, 04:58:21 pm
i have a question also.
i got this plugin to work very fine but this was also the first time for me to create a device

i entered D_SND.xml in the device file entrybox, but I also added i_SND.xml in the impl_file entrybox.

I did not read in the instructions that I had to enter the I_SND.xml in the device creation as well.
Is that really necessary or not?

(it is working anyway but i was just wondering...)
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: Ap15e on February 15, 2012, 05:18:52 pm
AFAIK, it isn't necessary to enter I_*.xml - as long as the implementation file is declared within the D_*.xml file (which holds true for all my plugins).
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: apt on February 16, 2012, 02:16:21 am
Uploading the files doesn't create the device, so you'll have to fill in an arbitrary device name and 'D_SND.xml' and press the 'Create device' button, then you'll have to restart the Lua engine several times. When the device is visible on the dashboard, press the tool icon to configure the SMTP variables, press SAVE and SND should be ready to use.

Hmm, that is exactly what I did, but I get no feedback from the 'Create device' button at all. It seems a dead button. Could the browser play a role here? I use Safari. I'll try FireFox tonight. Thanks for your answer.
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: apt on February 17, 2012, 04:07:06 am
I've retried it with a different browser but with no success. Also I've tried to add a different plugin, the weather plugin, but I'm having the same problem. I therefore conclude that my problem isn't related to this plugin and I've started a new thread here: http://forum.micasaverde.com/index.php/topic,9519.0.html
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: lolodomo on February 18, 2012, 08:28:19 am
I installed and set up the plugin, then created a basic scene to test it.
First try => I received the mail immediately 8)
Then, I changed the SMTP user in plugin settings.
Second try => no mail received => ok, probably normal
Then, I restored the initial SMTP user.
Several tries => no mail received :(

Finally, I suppressed the device and created it again. I did several tries and I received mails everytime as expected.

Something strange with settings change ?
Of course, I have done lua reload at all steps.

PS: VeraLite UI5 1.5.254
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: ninux on February 21, 2012, 03:59:15 am
Hello

Could it be possible to use this plugin with smtp who as no authentification ?

Thank you
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: apt on February 21, 2012, 04:10:31 am
Regarding my post above: the issue has been fixed. Plugin creation in general doesn't work for me in general under Safari and FireFox under OS X 10.7.3. Using another macbook with OS X 10.7.2 the problem was solved. The plugin works fine now.

Ap15e: Thanks for your work.

@ninux: did you try to use it without username and password? What happened?
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: therealabdo on February 21, 2012, 04:29:40 am
Hello guys, I have succesfuly added the device and done everything, but unfortunately i couldn;t find where i have to add the variables!
the SMTP server and password. In the device i have created i am unable to fill the variables

as shown in the picture

Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: apt on February 21, 2012, 04:47:14 am
On the other tab "advanced" scroll way down.
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: ninux on February 21, 2012, 06:01:08 am
@ninux: did you try to use it without username and password? What happened?
I try without username and password and nothing happened, no mail and no error on LuaUPnP.log
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: apt on February 21, 2012, 03:47:09 pm
I can't test for you whether it works, all my SMTP servers have user/passwd.

An SMTP server without username and password is probably a private server on a local network isn't it? Couldn't you add a username and password to your server?
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: ninux on February 23, 2012, 07:41:51 am
It not my mail server, I use my ISP mail server.
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: apt on February 23, 2012, 07:53:45 am
Did you notice the discussion at the first page of this thread?

http://forum.micasaverde.com/index.php/topic,6656.msg41758.html#msg41758
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: Kyle on March 03, 2012, 12:20:14 pm
I've installed the plugin and have even setup my own SMTP server and can not get this to work. I've noticed in vera logs that I keep getting 550 invalid recipient any idea what i'm doing wrong?
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: Johan on June 18, 2012, 01:15:44 pm
EOL, unsupported.

Installation:
  • http://wiki.micasaverde.com/index.php/Install_LUUP_Plugins
  • Set the variables SMTPServer, SMTPAuthUser, SMTPAuthPassword, SMTPPort, UserSending, UserReceiving and restart the Lua engine.

Usage:
  • luup.call_action( "urn:upnp-ap15e-com:serviceId:SND1", "SendMail", { subject = 'Message from Vera', body = 'How are you today?' }, 11 )
    replace 11 with the SND device ID.

History:
V0.2   fix for DeviceType (thanks to oTi@), UPnP parameters: subject, body
V0.3   update for UI5
V0.3a removed isSingle from static json file for compatibility with UI4

Remarks:
  • RFC 2821 requires all lines of the message body to end with CRLF.

Download:
https://docs.google.com/open?id=0Bz4omZm4gYcsNWM0MDc5MDQtMzI3OC00YjA3LThkMTUtYTlmNWVlMWY2YTg4

Where can I find the file to download? The download link doesn't work.

Thanks.
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: garrettwp on June 18, 2012, 01:23:57 pm
Ap15e is not on the forums anymore and has removed all of his plugins.

- Garrett
Title: Re: [_CODE_] SND - SMTP Notification Device (UPnP to SMTP bridge) V0.3a
Post by: drag0n on June 18, 2012, 01:34:39 pm
You can try this as an alternative:
http://forum.micasaverde.com/index.php/topic,9991.0.html