If you're bored with a smart home that just has to download a specific app to control a light, here's the good news: Openhab can give you the most flexible control of smart home, Openhab is a mature, open source home automation platform that can run a lot of software, There is no agreement, which means it can now be connected to almost all of the home automation hardware on the market.
Here we will show you how to install and launch the free smart home system.
We first use Raspberry Pi 2 to build Openhab, this article covers a few 5 topics:
1 , install Openhab on Raspberry Pi 2 and run it, then install the demo House configuration to check the core system for normal operation. 2, how to add bindings and configuration files for the device. This article will demonstrate with Philips Hue. 3. Enable remote access and connect to IFTTT. 4. Add a DIY sensor using Bluetooth and introduce the rest interface. 5. Configure the Openhab mobile application.
Pre-preparation
At the very least, you need a Raspberry Pi, as well as an Ethernet or wireless adapter (Ethernet preferred). It is important to note that Openhab also runs on older Raspberry Pi, but there is a problem with slow processing and the use of z-wave devices. You need to upgrade to the latest version of the Raspberry Pi and add z-wave. However, without the need for z-wave, you can safely ignore the problem and use Raspberry Pi B or C + to make it, as they can also work.
The latest stable version of Openhab is the 1.71 release. Version 1.8 is expected to be updated shortly, although more features may appear, but this article is not affected. This article is not compatible with version 2
Installing Openhab
First we install an old-fashioned method such as the command line.
Start with the latest Raspbian SD image. Plug in your network cable, then turn it on and run it through SSH:
sudo raspi-config
Expand FileSystem, and then split the memory from the Advanced menu to 16. When you are finished, restart, and then run the update completely
sudo apt-get updatesudo apt-get Upgrade
The simpler way to install Openhab is through Apt-get, but first we need to add a security key and a new repository:
Wget-qo-039; https://Bintray.com/user/downloadsubjectpublickey?username=openhab & #039 |sudo apt-key Add-"deb Http://dl.bintray.com/openhab/apt-repo stable main" | sudo tee/etc/apt/sources.list.d/openhab.listsudo apt-get updatesudo apt-get Install openhab-runtimesudo update-rc.d openhab defaults
Strangely, the "root" was installed. We need to solve this problem with the following command:
sudo chown-hr openhab:openhab/etc/-hr Openhab:openhab/usr/share/openhab
Next, we'll install samba and shared configuration and user folders, which makes it easier to install add-ons and remotely change the sitemap.
sudo apt-get Install samba samba-common-/etc/samba/smb.conf
You can change the workgroup name if you need to, but the others require WINS support Yes: (You need to remove the comment and change No to Yes)
WINS support = yes
Then add it to the Share definition section (scroll to the bottom of the file):
[Openhab Home] Comment=Openhab Home Path=/usr/share/Openhab browseable=Yes writeable=Yes only Guest=No Create Mask=0777Directory Mask=0777 Public=No[openhab Config] Comment=Openhab Site Config Path=/etc/Openhab browseable=Yes writeable=Yes only Guest=No Create Mask=0777Directory Mask=0777 Public=no
Save and exit. Finally, we need to set a samba password
sudo smbpasswd-a Openhab
Openhab "is not important as a password just for ease of use.
After restarting Samba (restart with sudo), test to see if you can access the shared drive. It may not automatically appear on your Mac, but you can use finder–> go–> Connect to Server and address.
SMB://[email protected]
User name Openhab Verify and your password, then open your two share to see. You can also open http://raspberrypi.local:8080/in your browser, but you will encounter an error because we have not built a sitemap yet.
Now keep track of the Openhab logs in order to keep an eye out for errors.
Tail-f/var/log/openhab/openhab.log
Install Demo House
Before we dive into the configuration file, add devices and bindings, and then we check the demo content to see if everything works. You can find "Demo Setup" in the openhab.org download.
After extracting it, two folders appear: Plugins and configurations.
Using a network share, copy the configuration share configured to Openhab and overwrite the existing folder. Copy the plugin to the other Openhab Home share and overwrite the existing folder again. If you are not prompted to cover things, then you are wrong. Open Raspberry.local:8080/openhab.app?sitemap=demo to view the demo.
This is the basic view, and Openhab's open source means we can install a cute theme or a completely different interface. Now, we just need to know all the work it does. It's important to note that we want a sitemap. It is not a network or sensor device. It is custom. If you want to learn how to create, open the Openhab configuration shared Deedsitemaps/demo.sitemap file.
This is difficult, but in most cases you can copy and paste a code snippet from another example to create your own custom interface. Here are some possible technical overviews of Sitemap elements that are enough to start thinking about what kind of interface you want to build and what information you want to display.
Open Items/demo.items, which is the path you create to control and define the sensor project.
Play the Raspberry Pi: A Primer for Openhab (i)