-
Notifications
You must be signed in to change notification settings - Fork 130
Raspberry Pi
This page will describe how to set up a Raspberry Pi mini computer to run MisterHouse including the Insteon PLM.
- About the raspberry Pi
- Step 1, Getting the Pi to boot
- Step 2, Configure the Operating System
- Step 3, MisterHouse installation
- Step 4, MisterHouse Configuration
- Things to avoid on the Pi
The Raspberry Pi is a credit-card sized computer originally designed for educational purposes in the UK, but it's taken off as a platform for low cost, low power hobby computing projects. It works wonderfully as a full MisterHouse server. There are now 4 generations of Raspberry Pi from the Model A to the Pi 4, the original Raspberry Pi (Model A) had 256mb memory and one USB port and sold for less than $25, for todays like up, please see The Raspberry Pi Web site. Pis have GPIO pins that can be used for advanced projects. We have seen MisterHouse running on all models of Pi, except the Pi Zero which may be a little underpowered (can anyone confirm/deny this?)
MisterHouse setup is actually easier than installing unix on an old spare machine because the operating system comes as an image already setup with all the drivers for the hardware and it even includes all the software you need for a typical MisterHouse installation. More about the raspberry Pi can be found here
There is a number of ways to get you Pi to boot from your chosen media with excellent guides on the internet and in these pages, they mostly rely on booting from a Micro Sd card, then migrating to a USB disk later;
- The simplest way is to use the raspberry Pi Imager
- You can use an image as described here
These instructions assume you have your Pi connected to a screen via HDMI and a USB keyboard and mouse.
Next you need to make changes to enable remote log in by SSH, static IP address etc. Note that if you used the Pi Imager, some of these steps may have already been done during the initial boot.
Open a terminal window on the Pi and run sudo raspi-config
and set the following;
- change the pi password from raspberry
- set timezone and locale,
- set hostname
- enable GPIO access(if needed)
You will need to reboot for these to take effect.
Next (if you skipped this during the initial boot up) you need to make sure your Pi has the latest updates. Open a terminal window and run;
sudo -s
apt-get update
apt-get upgrade
If you need to change the password again, use the passwd
command
If you want to boot from a USB device, the mechanism is different for different models of Pi, see here for details.
Edit /etc/dhcpcd.conf' (e.g.
sudo nano /etc/dhcpcd.conf` to add the following at the end
/*
interface eth0
static ip_address=192.168.100.66
static routers=192.168.100.1
static domain_name_servers=192.168.100.1
In this example my ip address is 192.168.100.66
etc..
You need to sudo reboot
for these to take effect
To check if the IP address is correct
ifconfig -a
Some installs did not include nslookup
, if this command fails, you need to sudo apt-get install dnsutils
See here for how to set up the hardware watchdog.
First you need to set up the pi to use your chose sound output see here
The alsa-utils
package comes ready installed on the default Pi distribution. This page has good instructions on the sound options for Raspberry Pi
- check the hostname (this will allow you to
ssh hostname.local
instead of remembering the IP address) by enteringhostname
, if its wrong, change it using sudoraspi-config
- check the date and time is correct by typing
date
, some installs had errors see here for advice.
Follow instructions in the wiki for initial MisterHouse setup.
You should not encounter any errors running the standard MisterHouse with Insteon support enabled as the Perl frameworks and modules it needs should come pre-installed on the Pi's OS.
That being said, if you get an error like Can't locate foo/bar.pm in @INC
it means that the perl module foo:bar
has not been installed. To fix this run;
sudo perl -MCPAN -e shell
install foo:bar
exit
Using the MCPAN shell like this allows you to do many installs in one session.
If this fails to install your chosen module, e.g. vsLock try;
sudo -s
apt-get install cpanminus
cpanm install vsLock
There is a number of mechanisms for this;
- The simplest mechanism is SFTP - this will work with the same userid and password as you use for SSH
- Samba share the Pi's Disk
- NFS mount a drive onto your Pi
-
winscp on Windows but if you're running Unix or Mac, you should have the scp command already built in. With WinSCP, make sure to choose
SCP
from the pulldown menu instead ofSFTP
. Usepi
as the user name and whatever password you set.
If you are using a SD disk it is good practice to increase the SD card life by minimising the number of times MisterHouse writes to it. See here for details.
two techniques for auto-starting MisterHouse are described here
HouseLinc is Windows-only software made by SmartHome. It used to cost money but they made it free sometime in 2012. It can be used to do a few things that MH can't do, like change the brightness of the LED on newer Insteon devices or control every setting on an Insteon Thermostat or other new/less common devices for which MH doesn't have complete support. You could unplug your PLM from the Pi and plug it in to your computer before you start HouseLinc, but the process described below will let HouseLinc use your PLM as if it were a "Hub".
-
Install socat by running apt-get install socat
-
Stop MisterHouse.
-
sudo socat tcp-l:9761,reuseaddr,fork file:/dev/ttyUSB0,nonblock,waitlock=/var/run/ttyUSB0.lock
- Replace ttyUSB0 with ttyUSB1 if your PLM ends up connected to USB1.
-
Edit
mh.private.ini
and add this line:debug=insteon:4
- Comment out any other
debug=<whatever>
lines by adding # to the front of the line.
-
Start MH and look for this:
- 04/28/2013 12:13:40 AM [Insteon_PLM] DEBUG4: Milliseconds 792.62
PLM Command: (0260) plm_info PLM Device ID: 12:34:56 Device Category: 03:15 Firmware: 9b PLM Response: (06) ACK
- Note the Device Category and Firmware values.
- Stop MisterHouse.
- Unfortunately, HouseLinc will refuse to use a PLM over the network if it doesn't report itself as a network PLM, so we have to trick HouseLinc into thinking your PLM is actually a "Hub" (SmartHome's latest network PLM as of 2013).
- Open in a text editor: C:\Users\Public\SmartLabs\HouseLinc\Devices.xml or Devices_Beta.xml, whichever one exists in the directory. ** Find your PLM in the file. If your Device Category was 03:15, search for category="0x03" subcategory="0x15". In my case, the entry looks like this: ***
PowerLinc USB Modem (Dual-Band) [2413U] ** Change subcategory to "0x37" (the category for a Hub). ** Find this section: *** <device displayName="Hub" category="0x03" subcategory="0x37" productKey="0x000000" flags="0x0008"> Hub ** Change subcategory to whatever the subcategory of your PLM was. In my case, that's 0x15. ** Now HouseLinc will think your PLM is a Hub and a Hub is your PLM.
- Run HouseLinc
- The first time you run it, it will most likely say "No computer interface found". ** Click Let me manually configure my computer interface ** Click Next ** Choose Hub (just "Hub", not "Hub, US" or any of the similar options). ** Type the IP address of your Pi in the box that appears. ** It should say the device was found. Click Next. ** It should say activation was successful. If it says "Ooops" then you most likely didn't edit your Devices.xml file correctly, or maybe you edited it while HouseLinc was running.
- If HouseLinc asks if you want to run a background synchronization or any kind of synchronization, answer no. Synchronizing will modify the ALDB on your insteon devices according to what HouseLinc thinks should be there, usually creating duplicate records or deleting records you created with MH.
One other completely optional thing you can do is get PLMTerminal.pl working on the Pi. PLMTerminal.pl is useful for sending raw Insteon commands to your network through your PLM and looking at the raw responses. This is probably something only a MH developer would need to do, but here's how to do it in case anyone needs it:
- Run sudo cpan from a command prompt.
- Answer yes to autoconfig and setting up mirrors.
- At the cpan1> prompt, type install Term::ReadKey
- When it's done installing, type quit
- cd /home/pi/MisterHouse/misterhouse/lib/Insteon
- ./PLMTerminal /dev/ttyUSB0
If you want to add support for a new Insteon device but you can't find its commands documented, try using HouseLinc to control the device. Set HouseLinc logging level to "Trace" and look at C:\Users\Public\SmartLabs\HouseLinc\Logs\HouseLinc.log to see what commands are being sent/received. If the log isn't working you can also run a network packet sniffer like Wireshark if you're connecting to the PLM over the network.
The Leafpad
text editor is far too simplistic for editing MisterHouse code. It doesn't even have a way to search upward for matches instead of downward. geany
is an excellent alternative (install using sudo apt-get install geany
) Note that geany
will use more memory and run slower than Leafpad
but even with geany
and MisterHouse running for six days a Pi model B is only at 35% CPU and 120mb free memory.
We suspect that LXTerminal
leaks memory because the longer you leave it running, the less memory you have, and closing it often frees a lot of memory.