Home Auto with Raspberry Pi – update

Progress is slow and steady but I am getting there. Since the last post I have acquired a daughter card for the Pi. The COM Pi RS232 Serial and 1 Wire module purchased from AB Electronics provides an additional serial port while also providing I2C and 1-Wire capabilities.

I had a bit of a dilemma trying to determine how best to make use of the USB ports as I have also added and RFXCom RXTX433 USB module to provide some RF home automation capability and as the Pi only has 2 USB ports and I have 3 devices it also means the addition of a USB hub.

The problem with adding a USB hub is determining which device to put on the one remaining RPi USB port, this was easy in the end as the weather station needed direct access rather than via a hub, leaving the RFX device and the Current Cost meter connected via the 4 port USB hub.

Current hardware now comprises:

All powered by an Apple iPhone or iPad power supply, whichever was the handy one at the time 🙂

Software:

  • Raspbian OS image
  • Lighttpd web server
  • OWFS for 1-Wire
  • pywws for weather
  • Current Cost measurements via Perl scripting discussed in previous posts for the Mac, same script, similar OS, no problem migrating to Pi
  • testing Home Easy control via command line

Some issues to fix but generally all the interfaces are now working, in term of the issues it is mainly abut what happens as a result of power loss and the recovery. The problem is more about ensuring that the USB ports allocated to the RFXCom and the Current Cost meter being consistent and an issue with the weather software hanging after a few days of operation.

in order to test the RFXCom device I looked at installing one of the many home automation packages but had difficulties when trying to install the Domotiga packages due to the amount of space required (using an 8Gb SD Card) which caught me out so I removed all the packages and went for learning how to work with the interfaces at command line level to start with and at least proved they were working.

To talk to the Home Easy devices I had to install a utility called rfxcmd which enabled me to use command line commands to communicate with the RFXCom device. it had to be done using sudo at the start of each command e.g.

sudo /opt/rfxcmd/rfxcmd.py -d /dev/ttyUSB1 -a send -r 0B1100000032284201010F70

Options (ones above used highlighted in bold);

-d Serial device of the RFX device
-a Action: LISTEN, STATUS, SEND, BSEND
-o Optional path and file for the configuration file
-x Simulate
-r Message to be sent to RFX
-c Output data in CSV format, one line per device data
-m Insert data to a MySQL database
-s Insert data to a Sqlite database
-v Print version and date
-g Send data to graphite server
-z Start as an daemon
-p Pidfile

the output from the above command looks like this:

RFXCMD version 0.24

————————————————

Send = 0B 11 00 00 00 32 28 42 01 01 0F 70

Date/Time = 2013-07-02 17:57:58

Packet Length = 0B

Packettype = Lighting2

Subtype = AC

Seqnbr = 00

Id = 00322842

Unitcode = 1

Command = On

Dim level = 100%

Signal level = 7

————————————————

Received = 04 02 01 00 00

Date/Time = 2013-07-02 17:57:59

Packet Length = 04

Packettype = Receiver/Transmitter Message

Subtype = Transmitter response

Seqnbr = 00

Message = ACK, transmit OK

pi@raspberrypi ~ $ 

In order to identify the device you need its address, you need to know what the code is for ON and OFF for the device all of which is contained in the message string of the command. After some experimentation with the three Home Easy devices that I purchased I figured out the following breakdown for Home Easy devices:

Device Vendor ID                                             Unit/Group   State

1st device ON –  0B 11 00 00 00 32 28 42           01            01 0F    70

1st device OFF- 0B 11 00 00 00 32 28 42            01            00 00    70

2nd device ON – 0B 11 00 00 00 32 28 42           02            01 0F    60

2nd device OFF- 0B 11 00 00 00 32 28 42          02             00 00    50

3rd device ON – 0B 11 00 00 00 32 28 42           03              01 0F    60

3rd device OFF- 0B 11 00 00 00 32 28 42           03             00 00    60

Group ON – 0B 11 00 00 00 32 28 42                   01             04 0F    60

Group OFF- 0B 11 00 00 00 32 28 42                  01             03 00    60

Using the same approach for X10, the command used was:

sudo /opt/rfxcmd/rfxcmd.py -d /dev/ttyUSB1 -a send -r 0710000041030170

the output from this command was:

————————————————

Received = 07 10 00 00 41 03 01 70

Date/Time = 2013-07-03 09:55:41

Packet Length = 07

Packettype = Lighting1

Subtype = X10 Lightning

Seqnbr = 00

Housecode = A

Unitcode = 3

Command = On

Signal level = 7

using the same principle as for the Home Easy device approach the message breakdown worked out to be:

X10 ID             House code    Device       State

07 10 00 00           41(A)              03          01 (ON) 70

07 10 00 00           41(A)              03          00 (OFF) 70

07 10 00 00           42(B)              02           01 (ON) 70

07 10 00 00           42(B)              02           00 (OFF) 70

so now we can start maybe doing some automation via the command line and the use of cron and perl scripts without the heavy weight requirements of some of the ready made applications out there.

I am keen on keeping things simple and have been using a similar approach with Z-Wave on the mac Mini that is currently doing the X10 and Z-Wave based control with a combination of a program called Shion for the X10 control using a CM15pro and command line scripts for Z-Wave along with the Tricklestar widget for Mac and a little utility called Sunwait for getting sunrise/sunset timing resolved.

I need to resolve issues with the Pi arising out of

  • the instability of keeping the same assigned port with the same device following a reboot
  • problem with pywws appearing to hang after a period of time

If I can resolve these then the automation side can begin to progress with a little more confidence along with the environment monitoring aspects for weather and energy use which uses rrd based databases which are small in size and efficient for the purpose they are being used for and ideal for use on the Raspberry Pi. one thing to point out is that the Current Cost monitoring is rock steady and works like a charm without issue, apart from problem with maintaining the correct port assignment following a reboot.

Samples attached to show the Pi served web pages (internal use only at the moment) for a sample of weather data and energy data. The pywws software has now been configured also to provide a feed into the UK Met Office site too.

Weather info for last hour

Weather info for last hour

Sample of energy usage

Sample of energy usage

Hope this information helps others make use of what is a fantastic little computer for experimenting and some real serious uses too.

Regards

Paul

Advertisements
About

I like all things of a technical nature. More of a hardware specialist than a software one though. At a programming level I know enough to be dangerous but couldn't earn a living from it........yet I hold a full UK Amateur Radio Licence, have dabbled in computing for about 30 years starting with a Sinclair ZX81 and gradually progressed a bit and now working towards making the home a bit more intelligent through the use of home automation technologies, hence this blog as somewhere to keep my notes where I can find them

Tagged with: , , , , , , , , , , , , ,
Posted in Raspberry Pi, Uncategorized
One comment on “Home Auto with Raspberry Pi – update
  1. jose says:

    I think you dont need to use sudo with rfxcmd if your user is in the dialout group.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: