About these ads
Archive | Open Source RSS for this section

Raspberry Pi : Home Control Center Part 1

In this series i’ll document how I put together a lot of people’s hard work into a home control center that is based off the raspberry pi, both for my future reference and for anyone out there who needs to build something similar. By the end of it, we should be able to have the following features:

  • Monitor temperature and humidity across various points in the house – wirelessly
  • Connect to your network via wireless
  • Display essential info on an OLED screen
  • Have a “webcam” mode that will allow you to stream real-time video of a room in your house wherever a raspberry pi is installed
  • Have a “security mode” that will record about 30-60 seconds of video everytime movement is sensed wherever a raspberry pi is installed
  • Trigger alarms whenever movement is sensed or doors open/close – wirelessly
  • Have an easy to use WEB UI that also works on your mobile phone
  • Can control lights on sensing movement

That’s quite a list which I hope to eventually complete and document. In this 1st part, I’ll focus on:

  • Connect to the network via  wireless
  • Display IP address, local temperature and humidity on an OLED screen

Most of the heavy lifting has been done by the awesome folks over at www.adafruit.com , in most cases I was just gluing everything together…. This guide assumes a fresh raspbian install (preferably via NOOBS). Without further ado

  • Connect to the network via  wireless

Really simple and run of the mill – if you have the right hardware. This point is key… I’ve had other wireless cards and they involved compiling drivers, not working, rinse, repeat. Save yourself a lot of hassle and just get a wireless USB that works out of the box. The adafruit one is perfect:

http://www.adafruit.com/products/814

Simply switch off your raspberry pi, plug it in and wait for a bootup and run an ifconfig to make sure wlan0 is listed. Then it’s the usual connect-your-linux-to-wlan procedure… In my case, I am connecting to a WPA2, pre shared key wireless lan. First add the following to your /etc/network/interfaces file:

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface wlan0 inet static
    address 192.168.1.245
    netmask 255.255.255.0
    network 192.168.1.0
    gateway 192.168.1.1
The above will give a static IP to your Pi, amend as necessary. And also in your /etc/wpa_supplicant/wpa_supplicant.conf file:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
 ssid="YOUR_WLAN_SSID"
 proto=RSN
 key_mgmt=WPA-PSK
 pairwise=CCMP TKIP
 group=CCMP TKIP
 psk="YOUR_PASSWORD"
}

Once again amend as necessary. I also added the following to the /etc/rc.local file to make sure the wireless connected on bootup:

ifdown --force wlan0
ifup --force wlan0

That’s it for wireless.

  • Display IP address, local temperature and humidity on an OLED screen

The OLED screen purchase and setup were a breeze thanks to adafruit. Visit and follow the tutorial here: http://learn.adafruit.com/adafruit-oled-displays-for-raspberry-pi.

The author of this post already includes how to display IP addresses on the OLED screen in one of his python examples so you’re halfway there. Adding the temperature and humidity are equally easy, again due to adafruit’s amazing tutorials. In this case, follow the one here: http://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging/overview

I obviously did deviate here since I wanted to place the information on the OLED screen rather than google docs. So in my case, after performing this step:

$ git clone git://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git
$ cd Adafruit-Raspberry-Pi-Python-Code
$ cd Adafruit_DHT_Driver

I compiled and installed the python library for the DHT driver as follows:

cd ../Adafruit_DHT_Driver_Python
python setup.py build

This results in a dhtreader.so file in the build directory which we can now use directly in python. Next to code:

  • Create a directory for the project. In my case:
mkdir /home/pi/raspiCC
  • Create a new python file and copy/paste the following:

If you notice, in the above code I’ve placed the main logic in a for loop with specific sleep periods. This was done so the whole script executes for a total of just under 60 seconds. This way, we can schedule a cron job that runs every minute and will continuously cycle between IP and environment information. This is quite simply done via first entering

sudo su -
crontab -e


Then entering the following crontab entry:

* *  *   *   *     /home/pi/raspiCC/daveOLED.py

The above will run our script every minute and refresh our OLED display. Here are the results so far:

Raspi PI OLED screen showing temperature and humidity

Raspi PI OLED screen showing temperature and humidity

... and showing network information

… and showing network information

Note the camera and infrared sensor in the last photo, which is coming up next… connecting the raspi cam to record about 30-60 seconds of video everytime movement is sensed near your pi :)

About these ads

Connecting Ubuntu / Mint to exchange mail and calendar

Assumptions and pre-requisites.

This article assumes the Linux user has the following installed:

  • An Ubuntu derived distribution such as Ubuntu itself, Linux Mint, and so on
  • The email client used is evolution, installed via the following packages and their dependencies:
  • evolution
  • evolution-common
  • evolution-data-server-common
  • evolution-mapi
  • evolution-ews
  • evolution-data-server-goa
  • evolution-plugins
  • gnome-online-accounts
  • gnome-control-center

Setup Details

  • Open the system menu and search / type for ‘online accounts‘. Note: you may see multiple entries for this. The correct entry is the one which allows you to select an account of type ‘Microsoft Exchange’ (see below)
  • Open online accounts and click on the “+” sign on the lower left to add an account. Make sure to select the type “Microsoft Exchange”

email_linux_1

  • Type in your email and password
  • Expand the “custom” settings and enter:
  • Username: [email protected] (note the following format has also been reported to work: your-domain\your-username)
  • Server: webmail.example.com (note that this is actually the domain of your outlook web access URL. For example, if your webmail URL is webmail.something.com/owa, then this server would be webmail.something.owa)
  • Click on connect, and very that the account is being used for mail, calendar and contacts as shown below

email_linux_2

  • close the online accounts settings box
  • Open evolution (close and re-open if evolution was previously open)
  • Verify that the account has been successfully added in evolution by:
  • Edit > Preferences
  • Under Mail Accounts, make sure a corresponding entry to the above is visible in the window. In the below example, you see two such accounts of type ‘EWS” (also distinguishable from their icon looking like a plug, whereas other accounts do not have the icon and have the tickbox)

email_linux_3

  • Your mail should now be visible under the evolution ‘mail’ tab, and an equivalent calendar should have been automatically added under the ‘calendar’ tab

Additional Notes

If you do not use gnome-online accounts, it is still possible to set this up (though without calendar), the one extra piece of information needed is that along with an account type of ‘EWS’, the host URL should be: https://webmail.example.com/EWS/Exchange.asmx. Also, during troubleshooting, it is useful to see if that URL is reachable.

Python system tray notifications in Linux

As a follow up to my previous post, here’s how to accomplish system tray notifications in ubuntu linux and family. I must say, compared to windows, this is child’s play… under ten lines of code!

#!/usr/bin/python
import sys
import pynotify

if __name__ == ‘__main__’:
if not pynotify.init (“summary-body”):
sys.exit (1)

# try the summary-body case
n = pynotify.Notification (“Cloudlink”,
“Hello Brian :) “)
n.show ()

 

This results in something like this (under linux mint – top right corner):

Screenshot from 2013-10-19 12:49:46

A full, more involved example can be found here

OTRS custom fields revisited : Dynamic Fields

In a previous blog post titled ‘OTRS custom “Additional ITSM Fields”’ I wrote on how to extend OTRS to better suit an organisations particular needs. Michiel Beijen from the OTRS team pointed out that the method presented there is outdated in v3.1, and suggested the use of Dynamic Fields. I’ve finally had the opportunity to follow up on Michiel’s advise in a recent project I was involved with. This article will explore the configuration process for using Dynamic Fields as well as some tips and tricks learnt along the way. Throughout the article, I will give examples from my particular OTRS use case scenario.

In this use case scenario OTRS was already installed as your typical helpdesk system. We now wanted to extend OTRS to also work as a bug tracker. Since OTRS was already installed and used, we wanted to converge on this system as much as possible. OTRS has all the capabilities of a software bug tracker, with queues for each dev team, time accounted fields for tracking time and effort spent, and each ticket representing a bug that needed solving. However, out of the box we need extra fields describing “categories” – where each ticket/bug can be categorized according to field such as security, usability, and so on. This is where dynamic fields come into play. Using OTRS it is possible to create a custom field – text, multiple choice, etc – that is also nonviolently searchable.

The procedure to define a new dynamic field is:

  • Login to the admin interface (using root@localhost by default)
  • Follow the documentation located here: http://doc.otrs.org/3.1/en/html/dynamicfields-configuration.html#dynamicfields-configuration-add. For example, in my case, creating a new “category” dynamic field involved:
    • Admin > Ticket Settings > Dynamic Fields
    • Since I want this new dynamic field to apply to the whole ticket, I selected “dropdown” from under “Ticket” on the left hand menu, rather than from “article”, which would have applied the dynamic field to a particular entry within the ticket
    • Modify the field to your needs. Make a special note of the “name” since you will be referencing it later. In my example, I chose the name arbitrarily to be “CloudLinkCategories”
  • That’s about it, however there are a few tips. Add the dynamic field to the following:
      • sysconfig > tickets > Frontend::Agent::ViewSearch

The above will allow you to have dynamic field as searchable attribute in the agent search function (update: apparently in v3.2 this is included by default)

search

      • sysconfig > tickets > Frontend::Agent::ViewZoom

The above will allow the dynamic field to have it appear in ticket details on right hand side of the agent view, along with all the other default ticket properties

zoom

      • sysconfig > tickets > Frontend::Agent::ViewFreeFields

The above will allow an agent to edit the dynamic field by clicking on the “Free Fields” entry in the menu bar

freefield

      • sysconfig > tickets > Frontend::Agent::TicketOverview

The above will make the dynamic field appear in ticket table overview

In each of the above sections, you will see an entry containing “DynamicField”, where under “Key” you can enter the “name” of the Dynamic Field you created earlier

As a final note, you can use the dynamic fields in the OTRS statistics module, which is handy for graphing the amount of time spent on each category over a given time period.

Web MeetMe : Conferencing in FreePBX

The company I work for currently uses TrixBox as their VoIP server. It’s an excellent piece of software but being no longer supported, the decision was taken to upgrade to the later and more active FreePBX. Since they are both built around the asterisk core, I figured this upgrade wouldn’t be too much of a problem. In fact it wasnt, most of the features in TrixBox I got working in FreePBX with no effort.

There was one stumbling block: conferencing. In TrixBox, users used to dynamically create conferences on the fly using WebMeetMe. In TrixBox, installation and activation of WebMeetMe was as simple as downloading and activating the appropriate module. Alas, in FreePBX the excellent WebMeetMe is not pre-installed (why??). So the installation is a bit more involving though ultimately works just as well :)

I am taking the opportunity to document exactly what I’ve done to get this working:

1. Download latest version of FreePBX

2. Install FreePBX as per usual procedures. Create a couple of SIP extensions and make sure they work before proceeding. Pleny of documentation on the ‘net if you get stuck here

3. Download the latest version of WebMeetMe

Note: For any of the below to work you need to ensure that FreePBX is setup to use the meetme module rather than the newer “confbridge”. This is done via:

FreePBX > Settings > Advanced Setting and ensure that Conference Room App is set to “app_meetme

3

4. The README within the tarball downloaded from 3 has some good install notes, however I found Mark In the Dark’s install notes to be much clearer and helpful. So, I followed the steps outlined here:

http://www.markinthedark.nl/news/ubuntu-linux-unix/75-install-web-meetme-402-for-freeppbx-28-with-asterisk-18-on-centos-55.html

5. Once the above procedure was done, visiting the page http://%5Bmy-ip-address%5D/web-meetme/meetme_control.php returned a HTTP 500 error. Checking the /var/log/httpd/error logs I saw a corresponding entry similar to:

PHP Parse error:  syntax error, unexpected $end in /var/www/html/web-meetme/lib/defines.php on line 145

To resolve the above, open the file defines.php, scroll to the bottom, and change the last three lines from this:

<?
}

?>

To this:

<?php
}

?>

6. If, like me, you decided on using MYSQL for authentication rather than LDAP, I again ran into an HTTP 500 error when attempting to logon. The error was:

PHP Fatal error:  Call to undefined function authsql() in /var/www/html/web-meetme/lib/functions.php on line 73

To resolve this, copy the contents of:

/var/www/html/web-meetme/lib/sqldb.php 

into:

/var/www/html/web-meetme/lib/functions.php

The above should allow you to login and schedule calls using web meet me. That said, I found documentation on how to setup an extension which callers could use to dial into WebMeetMe woefully lacking. Here’s what I did:

1. Add a custom extension

> SSH into the box, and edit the file: /etc/asterisk/extensions_custom.conf

> Add the following to the file:

[conferences]
include => ext-meetme; in [ext-meetme] contest are stored all the conferences created in FreePBX
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Playback(welcome); Insert your welcome recording
exten => s,n,Goto(STARTMEETME,1)

2. Add custom destination
This step is needed to make the FreePBX GUI aware of the custom extension we define above, and make it available as a choice within the GUI. Within FreePBX: [admin > custom destination] and use:

Custom Destination: conferences,s,1
Description: conftest

1

At this stage, you have an extension you can use. In our case we needed the webmeetme to be dialed into from both an external number and an internal one.

For external callers

  • FreePBX > Connectivity > Inbound Routes. Select the appropriate DID, ex 21123456, and set the destination as a custom destination and select conftest from the pull-down menu (or whatever you entered in step 2 above)

For Internal callers

  • FreePBX > Applications> Misc Applications. Enter in a description, a “feature code” (which is the number internal users will dial, example *789, and select the destination to be a custom destination and select conftest from the pull-down menu (or whatever you entered in step 2 above)

2

Follow

Get every new post delivered to your Inbox.

Join 138 other followers

%d bloggers like this: