HAH control via email (pop)

This applet allows you to SEND a command to an email account which the HAH monitors.

It works like this:
In the subject line you can specify one of the following

  • xap-raw
  • xap-short
  • xap-alias

These are all configured via a lookup table so feel free to make up your own commands if you wish.

Depending on what you have here the content has variant behaviour:

Member for

16 years 5 months

BoxingOrange

14 years 11 months ago

Can't seem to get this to work.  I can see that my e-mails have been opened but the script, but it doesn't action them.  I know you had some problems with the encoding early on, could this still be a problem, I've included the e-mail source below, any pointers greatly appreciated.

 

Return-Path: <myemail@domain.com>
X-Original-To: myhah@domain.com
Delivered-To: myhah@domain.com
Received: from mx03.one.com (mx03.one.com [195.47.247.74])
by mail86.b-one.net (Postfix) with ESMTP id 4275D1012B00
for <myhah@domain.com>; Wed, 30 Nov 2011 17:35:27 +0100 (CET)
X-Virus-Scanned: by one.com
Received-SPF: pass (mx03: domain of myemail@domain.com designates 209.85.210.169 as permitted sender)
X-Greylist: whitelisted by SQLgrey-1.8.0-rc2
Received: from mail-iy0-f169.google.com (mail-iy0-f169.google.com [209.85.210.169])
by mx03.one.com (Postfix) with ESMTP id B90BE20F3FF8
for <myhah@domain.com>; Wed, 30 Nov 2011 16:35:26 +0000 (UTC)
Received: by iaqq3 with SMTP id q3so1380377iaq.14
        for <myhah@domain.com>; Wed, 30 Nov 2011 08:35:26 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=mime-version:date:message-id:subject:from:to:content-type;
        bh=0HK7K2ijAhZXF22SamZPAZLZ+AJfXzEiaEGQNDjbcWM=;
        b=rFUKtWipFYyZVe5SvZuvSp2aEHGbgFlyGEwLSvoNoPULqzkcUtcjOo9UvjjdCgvDNz
         uR7TVrxQi2rhVQjAREXT9t0+D9yNXtPZHAvUvfaDEg19eKOo20hu/tHvemo2tzA+vCN3
         XllCOyCeZ/f9rHkNlVBvGDij01HPTd8fqKmFA=
MIME-Version: 1.0
Received: by 10.42.156.130 with SMTP id z2mr3980750icw.13.1322670926029; Wed,
 30 Nov 2011 08:35:26 -0800 (PST)
Received: by 10.50.10.165 with HTTP; Wed, 30 Nov 2011 08:35:26 -0800 (PST)
Date: Wed, 30 Nov 2011 16:35:26 +0000
Message-ID: <CAO4zjtTqCeSQunLgdyMyWZKicz+qHsr2r+_pHV4-Dr9qYF7dXw@mail.gmail.com>
Subject: xap-alias
From: Karl Cookson <myemail@domain.com>
To: myhah@domain.com
Content-Type: multipart/alternative; boundary=90e6ba6e819eb3649904b2f6528e

--90e6ba6e819eb3649904b2f6528e
Content-Type: text/plain; charset=ISO-8859-1

relay 1 on

--90e6ba6e819eb3649904b2f6528e
Content-Type: text/html; charset=ISO-8859-1

relay 1 on

--90e6ba6e819eb3649904b2f6528e--

 

 

Member for

16 years 10 months

brett

14 years 11 months ago

As your subject of the email is "xap-alias" this just sends out an ALIAS xap message, you need to have YET another script running that can pick these up and interpret what to do with them.

You should see this message being emitted when the email is processed.

xap-header
{
v=12
hop=1
uid=FF00D900
class=alias
source=dbzoo.livebox.plugboard
}
command
{
text=relay 1 on
}

There is an alias interpreter applet sample supplied on the HAH that can get you started with how to then action this message.

If you want to turn on a relay directly and not via an alias then you would need the subject to be "xap-raw" or "xap-short" and you would need to have as the body the corresponding xAP payload.

Brett

Member for

16 years 5 months

BoxingOrange

14 years 11 months ago

The aliasApplet is running, I use it with GoogleCal.  I can't see that xap message under dbzoo.livebox.plugboard, I'll do some more testing tomorrow, I'll also try xap-raw and xap-short.

Thanks.

Member for

15 years

Wannadont

14 years 9 months ago

I am trying to get the HAH control via e-mail.  I have setup the pop3Applet in etc/plugboard/ with correct host,user,pass [I am not opting to use the secure=true bit as indicated above and I have also managed to telnet ontothe pop server okay with the same details, so that shows the login works.  This is also mirrored in the debug logs for the xap-plugboard which shows the pop3Applet has been loaded and the logs show a few cycles of login to check the mails.  The plugboard then stops with this inbetween the last login to the pop3 server

POP3 RESPONSE : +OK 24 896
+OK 24lua: /etc/plugboard/pop3Applet.lua:54: attempt to index field 'pheader' (a nil value)
stack traceback:
/etc/plugboard/pop3Applet.lua:54: in function 'decodeBody'
/etc/plugboard/pop3Applet.lua:89: in function </etc/plugboard/pop3Applet.lua:88>
[C]: in function 'foreach'
/etc/plugboard/pop3Applet.lua:88: in function 'callback'
/usr/share/lua/5.1/xap/init.lua:172: in function 'dispatch'
/usr/share/lua/5.1/xap/init.lua:124: in function 'fun'
/usr/share/lua/5.1/pl/list.lua:360: in function 'foreach'
/usr/share/lua/5.1/xap/init.lua:122: in function 'process'
/etc_ro_fs/plugboard/plugboard.lua:77: in main chunk
[C]: ?
896
POP3 REQUEST RETR 24

The plugboard then stops.  It has never processed test mails as xap-short, xap-alias, and xap-raw message.  I presume it's something to do with the pop3Applet.lua and init.lua that resides in the plugboard/pop3 folder but not sure what.

Any help welcomed and much appreciated

Si

Member for

17 years

derek

14 years 9 months ago

Email is a big, complex, thing. This is why the O'Reilly Sendmail book has 1050 pages!

I reckon that the format of the email from your provider is subtly different from the ones that were used to test the script. As a workaround, perhaps try using another email provider.

Member for

15 years

Wannadont

14 years 9 months ago

But managed to get that going.  It's just the receive bit.  I will have a look for a different e-mail provider ta Derek

init.lua (7.42 KB)
message.lua (5.27 KB)
pop3Applet.lua (2.41 KB)