Hey guys Matt here from MKSmartHouse.com and in this video we are going to be setting up
the software for the home automation server using a MAC.
[Intro]
As you may have noticed I did say using a Mac because in this video we are going to
be setting up the software of the server using a Mac if you are using a Windows computer
then look in the description for the video using a windows computer.
Please also go ahead and press the like button because if all five videos in the Home Automation
Server Series hit 200 likes then I will release the videos on how to actually use OpenHAB
2.0 sooner then it is scheduled.
First thing we are going to do is put the os onto the microsd card, so go ahead and
grab the microsd card which like I mentioned in the hardware video it should be at least
16gb and class 10.
Anyway take the microsd card and connect it to your computer either directly or like me
and get a sd card reader.
Next we are going to download the openhabian image.
The link will be over in the guide on the mksmarthouse.com website.
Speaking of, this entire guide is available on the website in written for which I recommend
having open alongside this video so that way you can go to links and type in commands faster.
Moving on, go to the link then scroll down to downloads, download the raspberry pi image
by clicking on the file called “openhabianpi-ua……..img”, it should download.
Next go to the next link to download ApplePi Baker, on the website scroll down to most
recent version (recomended) and click download now.
Once it downloads open finder and then go to your downloads folder.
Double click to unzip the ApplePi-Baker.zip, Then double click on ApplePi-Baker to open
the program.
You might get a warning saying unidetified developer, if so go to system preferences
and then Security and Privacy then click the button open anyway a box will pop up click
open.
Now we are in apple pi baker and it will ask for admin password for your computer, so type
it in and press ok.
Next in the left side click and select your micro sd card.
Then in the IMG file field click the 3 dots to browse for the image, Head over to your
downloads folder and select the openhabian img file and click open.
Then click Restore Backup.
When the box pops up that says Your ApplePi is ready!
Click ok and remove the micro sd card from your computer.
You can now quit apple pi baker.
Now that the OS is written to the micro sd card, Take the micro sd card and put it into
the raspberry pi, the logo on the SD card should be facing down.
Then take the other end of the power adapter and plug it in.
The raspberry pi is now booting and setting up for the first time, Please be patient and
set a timer for 45 minutes because it has to expand.
Once 45 minutes have passed the pi is now booted and ready for us to configure it, but
before we access it we should give it a static IP address so we can access it easy at all
times.
First thing we have to do is open up a web browser and go to main router’s ip address,
mine is 192.168.0.1 and then log in.
Then go to DHCP and DHCP client list.
Look through the list and find openHABianPi, copy its MAC address and head over to address
reservation.
Click add new and in the MAC address field paste the pi’s MAC address.
There is one more field to fill out and that is the IP address, I put 192.168.0.4 because
that is the next available static IP adress I have.
Click save and in the pop up box click OK.
There will be a littile warning saying that it needs to reboot so click on the thing that
says “click here” and press the reboot button.When the box pops up click ok.
Let the router restart and when it finishes, unplug the raspberry pi, wait 10 seconds and
then plug it back in, wait one minute for the raspberry pi to boot back up.
Great now the raspberry pi is ready for configuration so, the first thing we are going to do is
configure the web part of OpenHAB so open up the web browser and go to your pi’s ip
address with colon 8080 on the end.
You should now see a webpage asking which setup you like, we are obviously going to
press expert.
Now it should be installing our user interfaces, this could take a couple minutes so be patient.
Once it is does done open up terminal either through launchpad or using spotlight.
For this part I recommend having my website up so you can just copy paste commands.
Any way type in ssh openhabian@your pi’s ip adress obviously replace the your pi’s
ip address I replaced mine with 192.168.0.4 and then press enter then type yes and press
enter again.
It will ask you for a password which the default is openhabian.
Awesome now we are in our raspberry pi, the first command we are going to issue is sudo
openhabian-config and press enter.
It will ask you for a password so enter the default one openhabian.
Next use the arrow keys and go to update and press enter.
Once it finished running the update script and your back at the selection screen use
the arrow keys and go to upgrade system and press enter.
Once the script is complete use the arrow keys and go down to Mosquitto and press enter.
Then on the screen while continue is highlighted press enter.
We will not be using mqtt authentication so use the arrow keys and go over OK and press
enter.
It should now be installing our mqtt server.
When it is done installing press enter over OK and then back on the selection screen use
the arrow keys and go to exit and press enter.
It should give you a warning that we didn't change the password so we are going to change
some passwords I recommend using the same new password for the next two things.
The first thing is the sudo / ssh password so Type passwd and press enter, we are now
going to change the password, so enter the default password openhabian and press enter
then enter a new password and press enter then confirm that password by typing it in
again and enter it should say updated successfully.
We are now going to change the samba password I will explain what this is later, anyway
type in sudo smbpasswd openhabian and press enter.
Now type in a new password I recommend using the same password as the sudo password so
type it in and press enter then type it in again and press enter.
Next we are going to change the timezone and locale so the raspberry pi can set its date
and time.
Type in timedatectl list-timezones and press enter Then use the arrow keys to scroll down
through the list to find your time zone, once you find it highlight it and then copy or
remember it then press control z on your keyboard to exit.
Type in sudo timedatectl set-timezone Europe/Berlin but replace the Europe/Berlin part with your
time zone then press enter.
Then type timedatectl and press enter to check the timezone.
So now type in sudo reboot and press enter, you might have to type in the sudo password
and press enter.
Your raspberry pi should reboot.
Next we are going to test out the MQTT server we just set up so, once it is done rebooting
go to mqttfx.org or click the link on the website guide.
Once on the website Press Download MQTT.fx then click on the one below Latest version.
It will take you to a new page click on the file that has the ending macos.dmg.
It will start downloading.
Once it downloads open up finder and go to your downloads folder.
Double click on mqttfx……...macos.dmg.
Box should pop up double click on MQTT.fx installer.
It Should give a warning of unidentified developer so go to system preferences > security and
privacy and then click open anyway.
Another box will pop up click open.
Then go through the setup by click next two times and then finish.
It is now installed so go to launchpad and click on MQTT.fx.
This is now a good time to explain what this is, this is a program that tests mqtt stuff
so you can debug it and see if it is working.
Click on the gear at the top.
Change broker address to the ip address of the raspberry pi mine is 192.168.0.4 and make
sure the port is 1883.
Then at the bottom click apply then click cancel.
Now click connect.
If it connects successfully and there is a green circle in the top right then you are
good.
Go over to the subscribe tab and type in the # symbol and press subscribe.
Then in the publish tab type in hi in the field and then in the big box type in hello
world!
Then hit publish.
Then go back to the subscribe tab and if you see hello world then we are very good.
We successfully set up the mqtt server!
Now lets connect the mqtt server to openhab, so go to open up your web browser and go to
yourpiipadress:8080 replace the yourpiipadress with your pi’s ip address, mine is 192.168.0.4:8080
Then click paper ui, paper ui is the web administration pannel for the automation server.
In the left column go to Add ons.
In the search box type in MQTT.
Next to where it says MQTT Binding click install wait for it to install.
When it finished Go back to terminal and ssh into raspberry pi, type in ssh openhabian@192.168.0.4
replace 192.168.0.4 with your pi's IP and press enter, then type in your sudo password
and press enter.
Type in sudo nano /etc/openhab2/services/mqtt.cfg and press enter.
The only thing we are going to change is the server or url to our broker so delete the
line #.url=tcp://:1883 and replace it with broker.url=tcp://192.168.0.4:1883
but change the IP address to match your raspberry pi.
Press Control x on your keyboard and then press y then press enter to save.
Congratulations we have now setup the OpenHAB 2 home automation server with mqtt.
What we did is set the groundwork and the structure for the rest of OpenHAB 2 and our
MQTT devices.
In the next videos after the final installation of this server we will talk about creating
the interface for our smart home system in openHAB as well as the rules for automation.
Alright thank you for watching and If you have any questions leave them in the comments
section below or head over to mksmarthouse.com/forum where you have a better chance of it getting
answered.
Good Bye!