All development related posts
All development related posts
I finally got it to work and it is not so difficult with the right packages (Net::XMPP) and parameters …
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | #! /usr/bin/perl</code> use strict; use warnings; use Net::XMPP; ################# # Config params # ################# my $hostName = 'jaim.at'; my $portNumber = 5222; my $componentName = 'jaim.at'; my $userName = 'totosk1008'; my $passWord = 'totosk1008'; my $resource = 'NiceLittleBot'; my $tls = 0; my $connectionType = 'tcpip'; my $debugLevel = 0; # Create the client my $bot = new Net::XMPP::Client(debuglevel => $debugLevel); $bot->SetCallBacks( onconnect => &connectedCB, # gets called when connected onauth => &authedCB, # when authenticated ondisconnect => &disconnectedCB, # when disconnected ); $bot->SetMessageCallBacks( # callback for messages chat => &messageCB, # chat-type messages ); $bot->Execute( # entering the main loop hostname => $hostName, port => $portNumber, tls => $tls, username => $userName, password => $passWord, resource => $resource, register => 0, connectiontype => $connectionType, ); ############## # Callbacks # ############## sub messageCB { # call back implementing the echo my $sid = shift; my $msg = shift; my $from = $msg->GetFrom; my $to = $msg->GetTo; my $name; my $data; print "From : ", $from, "\n", "Subject : ", $msg->GetSubject, "\n", $msg->GetBody, "\n"; $name = $msg->GetBody; $data = $msg->GetBody; print ">>$name<<\n"; print $data, "\n"; $bot->MessageSend( to => $from, from => $to, resource => 'Gaim', type => $msg->GetType, subject => $msg->GetSubject, body => $data, ); } sub connectedCB { print "Connected\n"; } sub authedCB { print "Authed\n"; $bot->PresenceSend; } sub disconnectedCB { print "Disconnected\n"; } |
I finally finished it (though I expect to have to make some changes in the future …) :
Now I can setup my home automation events in MisterHouse throught my Mozilla Calendar ! The code has been submited and accepted for being integrated in MisterHouse and will be in the next release ![]()
Code is here.
I finally almost got it …
Here is a code snippet for parsing and showing pieces of an ICal file :
use strict;
use warnings;
use Data::ICal;
use Data::ICal::DateTime;
use DateTime;
my $cal = Data::ICal->new(filename => 'holidays.ics');
my @events = $cal->events();
foreach my $event (@events) {
print "summary:", $event->property('summary')->[0]->value, "n";
print "dtstart:", $event->start, "n";
print "dtend:", $event->end, "n";
}
print DateTime->now, "n";
What I want to do ? Drive my home automation events with my Mozilla Calendar !! I’ll soon be there, if I gather enough time to do it !
Some pointers :