Friday, August 16, 2019

Homeseer on a Raspberry Pi 4

I maind got a this as a second instance so I could test MyMonitor without risking corrupting my main instance monitoring and controlling my house, shop and barn.

I started with a CanaKit Raspberry Pi 4 Starter Kit - 4GB RAM The assembly instructions are non existent though. So here is a pic with the heat sinks and fan installed.

You might also want to get Cable Matters 2-Pack Micro HDMI to HDMI Adapter (HDMI to Micro HDMI Adapter) 6 Inches

It is a bit hard to see in the picture but the red wire of the fan to pin 4 and the black to 6. See chart next to board. The main HDMI port is the one next to the USB C (connected in pic). Once all assembled you can start with the instructions.

The HomeSeer HS3-Pi Install Guide has instructions for older versions so let me add changes. The image file will not even boot in the Raspberry Pi 4 so you need to start with the option 2 instructions. So use the SD card in the kit and do the basic install of Raspbian and basic config. You probably will want to enable ssh. I also pulled info from Correct Installation of HS3 Standard on Raspberry Pi 3

ssh to hostname
As in
ssh pi@HS3-pi4
sudo apt update
sudo apt install mono-complete
sudo apt install mono-vbnc
sudo apt install mono-xsp4

After installation, make sure you update the builds. Repeat this pair of commands several times to update all of the dependencies.
sudo apt update
sudo apt upgrade

Look at the install guide for the tar URL and get it with curl. For me its was
curl -O https://homeseer.com/updates3/hs3pi3_070319.tar.gz
Install HomeSeer: sudo tar xvf hs3_linux_<version>.tar.gz
As in
tar xvf hs3pi3_070319.tar.gz

The tar script creates the /home/pi/HomeSeer directory.

Instead of the way he did it in the post above, run (method 4 from Five Ways To Run a Program On Your Raspberry Pi At Startup)

Create a service config to start Homeseer on boot and stop it during shutdown. (Adapted from Autostart Homeseer on Linux)
Create the file /lib/systemd/system/homeseer.service and put the following in it.
[Unit]
Description=Homeseer Service
ConditionPathExists=/home/pi/HomeSeer/Logs
After=auditd.target

[Service]
Type=simple
WorkingDirectory=/home/pi/HomeSeer
ExecStart=/home/pi/HomeSeer/autostart_hs

[Install]
WantedBy=multi-user.target

sudo chmod 644 /lib/systemd/system/homeseer.service

sudo systemctl daemon-reload
sudo systemctl start homeseer.service

sudo systemctl status homeseer.service

If no typos you should see something like this
root@HS3-pi4:/home/pi/HomeSeer# systemctl status homeseer.service
● homeseer.service - Homeseer Service
   Loaded: loaded (/lib/systemd/system/homeseer.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2019-08-16 08:35:51 CDT; 6min ago
 Main PID: 2210 (autostart_hs)
    Tasks: 31 (limit: 4915)
   Memory: 32.0M
   CGroup: /system.slice/homeseer.service
           ├─2210 /bin/sh /home/pi/HomeSeer/autostart_hs
           └─2211 mono HSConsole.exe

Aug 16 08:35:51 HS3-pi4 systemd[1]: Started Homeseer Service.

Homeseer should now start when the system boots.

Open a browser and go to the hosts IP. For example mine is on 10.10.1.245 so the URL is
http://10.10.1.245/
The login and password were both default instead of homeseer/hsthsths3 the guide mentions.
That gets us to this screen


This is where I hit an issue. check_passwd called by this screen gets a Segmentation fault.

This appears to be a known issue. On page 4 I found a link to download the ARM version mentioned in the thread. Note you have to log in to download it.   That was not the issue though. Turns out the actual problem it looks for an linux user named homeseer with the hsthsths3 password. If the user is not found it gets a Segmentation fault. So adding a user with
sudo useradd -d /home/homeseer homeseer
sudo passwd homeseer

Once that is sorted, you should now see this

Clicking the link took me to the registration page

Note the number is your License and the other is the password.
Next fill in the user info form

Note you can ignore this and start adding your devices or restoring from a previous setup if you want.




Note found another issue. 

Lastly go to setup, check for updates and install if found.


Seems when updates try and run the system goes down and you have to manually restart it.
sudo systemctl start homeseer.service
Also it seems to want me to change the System password again and shows the update did not happen.

To help debug this I ended up changing updatehs.sh to this
sudo rm hslinux_zees2_3_0_0_$1.tar.gz
sudo wget -o install.log http://homeseer.com/updates3/hslinux_zees2_3_0_0_$1.tar.gz
sudo tar xavf hslinux_zees2_3_0_0_$1.tar.gz 2>&1 >> install.log
sudo chmod +x install.sh
sudo ./install.sh 2>&1 2>&1 >> install.log

and ran it from the command line. This time the update seemed to take. I'm thinking the issue is it starts the update before the system has fully shutdown. From the first few tries I can see it is running updatehs.sh and is extracting the tar like it should. So failing to overwrite a file in use would seem the only explanation. Status shows it appears to be calling systemd to shut it down but not to start it back up. But then when I ran from the command line Homeseer was already down. The other scripts start with a 20 second wait. So I created a reports folder
mkdir /home/pi/HomeSeer/html/reports
(So you can then get the latest update log at http://HOST_IP/reports/install.log)
and changed updatehs.sh to this
#!/bin/bash

counter=20
while [ $counter -gt 0 ]
do
 sleep 1
 counter=$(($counter - 1))
done
sudo rm hslinux_zees2_3_0_0_$1.tar.gz
sudo wget -o /home/pi/HomeSeer/html/reports/install.log http://homeseer.com/updates3/hslinux_zees2_3_0_0_$1.tar.gz
sudo tar xavf hslinux_zees2_3_0_0_$1.tar.gz 2>&1 >> /home/pi/HomeSeer/html/reports/install.log
sudo chmod +x install.sh
sudo ./install.sh 2>&1 >> /home/pi/HomeSeer/html/reports/install.log
systemctl start homeseer.service 2>&1 >> /home/pi/HomeSeer/html/reports/install.log
systemctl status homeseer.service -l 2>&1 >> /home/pi/HomeSeer/html/reports/install.log
This seems to work OK but I can't test it form the web interface till the next update comes through.
Note the update you get says it is for the Zee.

To finally sort the System password issue I went and changed the homeseer password back to the default hsthsths3 from the command line
sudo passwd homeseer
Then submitted the change password form with hsthsths3 in the first field and my selected new password in the others.

Other info

Speech

You will see these error in status
Aug 17 13:22:51 HS3-pi4 autostart_hs[6101]: /home/pi/HomeSeer/./speak.sh: 2: /home/pi/HomeSeer/./speak.sh: flite: not found
I'm not using speech on mine but if you want to, you might want to start here.

Samba

If you want to mount to or from a Windows PC. Good for copying over images and scripts for example. Based on this post.
sudo apt-get update
sudo apt-get install samba samba-common-bin smbclient cifs-utils
mount my main Homeseer on 10.10.1.45 on my test instance with user dea's permissions.
sudo mkdir /HS3
sudo mount.cifs "//10.10.1.45/HomeSeer HS3" /HS3 -o user=dea
copy over missing image files
cd /HS3/html/
find ./images/ -type f -print | cpio -pvmd /home/pi/HomeSeer/html
Copy over missing scripts
cd /HS3
find ./scripts/ -type f -print | cpio -pvmd /home/pi/HomeSeer


Sunday, August 11, 2019

My first home automation system.

Technically my first home automation hub was a CP-290 clear back in 1980 but my first real hub that supported both programmed events and more than just X10 was the TimeCommander Plus. In Aug of 2016 I finally took it off line and post the following to Facebook. It popped up in my memory feed today so I thought I should add it here. I never did retask it. Instead I've used door sensors with dry contacts and an alarm panel linked into my Homeseer system. Links and photo caption added.

Retired a bit of history the other day. This is my old TimeCommander Plus which was my home control at the old house for a decade and was later retasked as an alarm system in the new house. I finally let it go and replaced it with several Z-wave devices when the last Windows XP PC gave out since it was going to be a major rewrite to get it going on Windows 10 or Linux. It was almost state of the art in the late 1990s when I bought it and still works. Though these days there is just too much interference from other devices for X10 stuff to be usable. I might still make the effort to retask this yet again seeing as how current home controllers do not seem to see the point of wired inputs and outputs. I have not found anything that has close to the 16 digital inputs, 8 analog inputs and 8 digital outputs this has.
TimeCommander Plus with addons.
TimeCommander Plus with addons. The relay was for a delay system to slow hold output from the rain fall monitor it was connected to long enough so polling would not miss triggers. The extra terminals made wiring up power to all the alarm sensors form a central power source easier.