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=server.service multi-user.target

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

[Install]
WantedBy=multi-user.target

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

sudo systemctl daemon-reload
sudo systemctl enable homeseer.service
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.

If you want to do the init.d method you will need to do this to get the screen command installed
sudo apt-get install screen

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. Update: this was a issue with the After line of homeseer.service which I corrected above.
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. I tried this which is a newer version but it did not seem to work for me. Though I'm not getting any sounds from other stuff either like youtube videos so the issue is probably the Pi4. Tried this to fix the sounds but did not help.

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


2 comments:

  1. Fixed the not starting on boot issue and added some sound/speech stuff though that is still not working.

    ReplyDelete