[How-To] Control an Elk M1 via External Perl Scripting

Ok, my arm was twisted, so I did it. A new github repository was created for HomeGraph, the "rails app to display graphs and stats that are accumulated by the elkm1--control perl script".

Word of Caution :)
If you don't have a bit of Rails experience, ruby experience, and MySQL experience, there is a good change you will not get this to work for you. It is not intended for the novice or casual user. You will lose considerable hair trying to get it to run for you.

That said, I'm more than willing to help any hacks out there who want to give it a try.

If I didn't frighten you, you can clone the project from github.
 
Thanks! Now I just have to get around to setting up the perl script to log to a database. I've been too busy running wire and installing sensors and cross-connects. 1500 feet of wire in the last week.
 
For those of you wanting a way to access your ElkM1 via the Serial port here's another option. <snip>
I don't need this for the ElkM1 perl script, but I sure can use this on another project. A big THANKS for the info.

No prob. Just some detail on those commands. The first pipes the serial port via UDP packets to a raw socket on the linux computer. The second connects that raw socket to a TCP port.

That's the key to getting the simultaneous connections to work. Also the b115200 sets the baud rate and there are options for several other baud rates, bits, and parity that you may need to adjust.

If you were making just a single connection you could use a command like

socat /dev/ttyS0,raw,b115200 tcl-l:9750

And that'd get you connected to TCP port 9750.

Good luck with your other project! I think next I'm thinking about porting ElkM1::Control to PHP. Mostly just because I'm so much more comfortable with PHP and I want to create a web interface for the ElkM1.

OH! Using these same commands one could probably connect to an Insteon PLM. That might be handy for many of you folks here. I haven't tried it yet but I plan to get that figured out too. Then if I could find a small linux capable device with duel serial ports and 2 NIC ports I could replace the functionality of a ISY-99i and the ELK M!XEP.
 
Hi floks-

Been playing with the script for a few days, but I seem to be missing where I configure the Access Code. I have two devices configured with the RP Access Code and am not able to get any data out of them with the std test script...

Any ideas?

Thanks

Elmars
 
Hi floks-

Been playing with the script for a few days, but I seem to be missing where I configure the Access Code. I have two devices configured with the RP Access Code and am not able to get any data out of them with the std test script...

Any ideas?

Thanks

Elmars


I don't know anything about a rp access code but the script requires your alarm disarm code aka PIN.
 
With this module is there anyway to see which user disarmed the alarm, looking though the documentation it looks like you might be able to pull up event details? Has anyone ever tried this?
 
I recently tried to use the PLC functionality in this module and discovered some problems. Below is what I had to do to fix them

The lines and modules I changed on my installation were

/usr/local/share/perl/5.10.1/ElkM1/Control/Message/PLCStatusReply.pm
line 68
Code:
<       'PLCStatusReply: bank='.$self->getBank.', status='.join ',', map { $self->getStatus($i)} (0..63);
to
>       'PLCStatusReply: bank='.$self->getBank.', status='.join ',', map { $self->getStatus($_)} (0..63);

/usr/local/share/perl/5.10.1/ElkM1/Control.pm
lines 906-910 (note the first }, is removed and a } appears at the end )
Code:
<         },
<         'index' => {
<             allow => sub { ( $_[0] >= 1 and $_[0] <= 256 ) },
<             var         => \$index,
<             description => 'an device index from 1..256'
to
>             'index' => {
>               allow => sub { ( $_[0] >= 1 and $_[0] <= 256 ) },
>               var         => \$index,
>               description => 'an device index from 1..256'
>            }

line 1020
Code:
<     $self->sendCommand( sprintf( 'pf%c%02d', $house, $unit ) );
to
>     $self->sendCommand( sprintf( 'pt%s%02d', $house, $unit ) );
line 1390
Code:
<     $self->sendCommand( sprintf( 'ua%05d', $code ) );
to
>     $self->sendCommand( sprintf( 'ua%06d', $code ) );

line 1569
Code:
<           . ". Adding to queue.\n";
to
>           . ". Adding to queue.\n" if ( $self->{debug}) ;
 
Hey. I'm trying to access the github and make some minor typo fixes to the 'man' page contents.

I'm really confused by 'git' - I think I'm doing everything per the documentation.

Is this thread still alive and/or of interest? I'd like to tinker with some files and make them available for inclusion in the mainline.

Thanks.
 
Not much has changed with the M1, so this is still a very useful script. That said, between the many migrations, some of the 'subscriptions' might have gotten lost, so the author of this thread might not have gotten notified that you posted. You might want to send him a PM directly if you don't get a response soon.
 
So this topic seems pretty old.  I assume this type of direct control and integration to the M1 is not used by many people these days.  The Elk::Control is a nice API.  The author did a nice job with it.  It is however incomplete and has a number of bugs.  But it is a good framework.  I have so far added support for authenticated SSL connections and fixed a few bug as well as added the missing ElkM1::Control::Message::CustomValueReply module.  I see there are more modules that need to be implemented as well.  I also found that this project is on GitHub with some bug fixes as well.  I will see if I can join GitHub and apply my changes and additions.  If you are interested in what I have so far send me a message or check GitHub in the future.
 
Does anyone know of any existing Web based M1 control interfaces (besides the deprecated XEP Java interface)?
 
crossbar said:
Does anyone know of any existing Web based M1 control interfaces (besides the deprecated XEP Java interface)?
 
I use a Vera.  They are like $99 on Amazon, and there's a plugin that connects to the Elk.  The Elk didn't have the flexibility I needed for home automation on its own, so I put in the Vera and moved all of the HA logic over to it.  A side effect of this is that it has a passable web UI (and you can install Alt_UI which you may like better), and you can use any of the many Vera control apps out for iOS/Android.  It connects to the cloud, so you don't need to poke holes in your firewall to control remotely either.
 
Thanks for the suggestion.  Can the Vera control the alarm functions as well.  Arm/Disarm/ etc?  If so that may be a good solution.
 
I'm not a fan of cloud based services since they have the potential to introduce additional security issues and it is very easy to do the necessary port forwarding or VPN.  Do you know if the Vera can work without the cloud connection?  I seem to recall there are issues with the Vera running stand alone?
 
I wanted the automation that the M1 can do for things that are more critical, as the M1 should be fairly stable.  But the Vera for remote control and additional Automation controls may not  be a bad idea.  Especially since the M1 Z-wave integration is incomplete.
 
 
 
Yes, it can control pretty much everything on the Elk, including arming/disarming, firing off Tasks, operating outputs, etc.  Not only that, but the sensors connected to the Elk are all seen in the Vera and can be used to trigger automation tasks and such.  Control of the chime directly doesn't seem to work, but I just created an automation rule on the the Elk that watched an output, and then I use this phantom output as a switch to turn the chime on and off with the vera.
 
Also, the 500 word vocabulary on the Elk wasn't cutting it for me.  I use Vera Alerts and have full TTS with a sexy British voice going over my whole house audio system. I don't even have the Elk speaker output hooked up anymore.
 
For $99, it's totally worth buying.  
 
Like I mentioned above, the limitations of the automation logic on the Elk were something that I wasn't very happy with at all.  You can do SO much more on the vera with just the built in functionality.  Adding the program logic plugin gives you the ability to do some really complex logic pretty easily, or you can write straight LUA code as well and associate it with scenes or triggers.
 
Back
Top