|
Post by papa on Feb 5, 2016 15:03:00 GMT
This is an adaptation of my Linux Laptop: How to Install OpenHAB-Mosquitto thread Applied to a Raspberry Pi (hereafter called "Pi") running the Raspian version of Linux, how to install OpenHAB & Mosquitto for DIY Home Automation. Important preliminary caution: Avoid shutting down the Pi by turning off its power or doing anything else except by Menu / Shutdown / Shutdown. Avoid restarting the Pi by turning its power off & on or doing anything else except by Menu / Shutdown / Reboot. Otherwise you can corrupt its SD card & you'll have to start from scratch. As soon as you get your PI set up with OpenHAB / Mosquitto, see this post where I explain how to make a backup image of your SD card that you can quickly install on a new or corrupted card. This install assumes that you will have a programmed ESP82xx device ( see threads on this board) or an Ethernet Node ( see this thread) or an assembled RFM69 Gateway & End Node to use with the installed OpenHAB. If needed, you can see this thread for detailed documentation on building & programming the Gateway & End Node. It also assumes: a Raspberry Pi (if buying new, probably get the latest version, currently 2B 3B, & maybe a kit with keyboard/touch pad) with the Raspian version of Linux available on an SD card of at least 8GB & in the Pi's preferences, SSH is enabled. The Pi is powered & connected to your local network. This post below comments on getting a successful Raspbian/ OpenHAB / Mosquitto install via OpenHABian.
Given the convenience of OpenHABian, almost all the following posts need a serious revision or a new thread. Some of the following posts might give some useful Linux commands, but my strong recommendation is to install OpenHABian with help of the link in this post.
===================================== If a keyboard & monitor are connected to the PI, you can follow the Notes just below in Terminal on the Pi, but it's easier if you use SSH from another computer on your network. You'll probably need to log in to the Pi from the other computer with user (pi by default) & password (raspberry by default). Follow SSH instructions beginning here.Notes: When you see a line starting with $, type it on Terminal & followed it with [Enter]. Text below the $ line shows what the command generated. When you see $ sudo, you may need to blind type the Linux password chosen when you installed Linux. If a command squawks "Permission denied," re-enter the command with sudo[space] in front of it. Starting after $[space], you may select & copy commands below. Then you may paste them into Terminal & [enter].
Using a Terminal or SSH command from this helpful document, I show below the Pi's Linux version where I installed OpenHAB-Mosquitto: $ cat /etc/*release pi@raspberrypi:/ $ cat /etc/*release PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)" NAME="Raspbian GNU/Linux" VERSION_ID="8" VERSION="8 (jessie)" ID=raspbian ID_LIKE=debian Seems good practice to update your Pi first. Use Terminal commands: $ sudo apt-get update $ sudo apt-get upgrade $ sudo rpi-update PS If one needs from the beginning to set up a Pi that has no monitor, keyboard, or mouse, do an internet search for "Raspberry Pi headless"
|
|
|
Post by papa on Feb 5, 2016 15:36:29 GMT
If your Pi does not already have a static or fixed IP address, give it one by logging into & changing your router's settings. Give the Pi the same address as the one you use for mqtt_server in the Gateway programming sketch. If these don't match, the Gateway will not connect to MQTT server on the Linux computer. Install openHAB using the apt-get method in this document & copying simple config files to the proper folders /etc/openhab & /usr/share/openhab Added comments about the above... I did not need Steps 6 or 11. You might. For Step 9, I did the following ( Updated, Oct. 12, 2016) $ sudo apt-get install openhab-addon-action-mail $ sudo apt-get install openhab-addon-binding-http $ sudo apt-get install openhab-addon-binding-mqtt $ sudo apt-get install openhab-addon-binding-ntp $ sudo apt-get install openhab-addon-binding-weather $ sudo apt-get install openhab-addon-io-myopenhab << Updated 2/6/2017, because obsolete$ sudo apt-get install openhab-addon-persistence-logging $ sudo apt-get install openhab-addon-persistence-rrd4j To see more add-on & binding packages, use: $ sudo apt-cache search openhab Note OpenHAB File locations: service configuration /etc/default/openhab site configuration /etc/openhab log files /var/log/openhab userdata like rrd4j databases /var/lib/openhab openHAB engine, addons and /webapps folder /usr/share/openhab
|
|
|
Post by papa on Feb 5, 2016 15:41:29 GMT
For Step 10 (OpenHAB Configuration) of the above document ...
Caution: On 10/12/2016, the following instructions were changed ...
On 10/11/2016, the .zip of sample config files was updated & renamed to openhab-papa4.zip. I believe they are correct if edited as shown below.(On a Pi with a keyboard & monitor, you can do the the following with the Pi's web browser & File Manager & Terminal).
------------------------------------------------------------- Two ways to Download & extract openhab-papa4.zip (See a third way at the end of this post): Here you can download openhab-papa4.zip, some simple OpenHAB config files I packaged to work with a Gateway, DHT End Node 2, & OpenHAB. On the OpenHAB User Interface, they display some weather data via the OpenHAB Weather Binding. Using these should save time getting started with OpenHAB & will give something relatively simple to learn from & build on. Sometimes, we get an attachment ID error. If so, just try again until it works. Click on the above zip file link. Downloaded to a Pi, it should end up in /home/[user]/Downloads. ( Again, for the default Pi set up, replace [user] with pi. For example, /home/pi/Downloads) You can do the rest of this post on the Pi's Terminal OR via SSH from another computer on your network.
If you don't already have it on the Pi, install unzip: $ sudo apt-get install unzip Extract the openhab-papa.zip files: $ unzip /home/[user]/Downloads/openhab-papa4.zip OR An alternative: With another computer, download & extract openhab-papa4.zip. Copy the files to a thumb drive's folders /configurations & /webapps Unmount & move the thumb drive from the other computer to the Pi. When the Pi gives you the opportunity to open the drive in File Manager, do so. For the copying you'll do below, note the path to the .zip file, something like /media/pi/USB Disk. ---------------------------------------------------------------------------------
Now copy the downloaded & extracted files to the OpenHAB configurations folders...
Note: I don't believe we can drag & drop files between two File Manager windows in these cases, apparently because the files' destinations are "special folders" that require our permission via sudo.
If you use a thumb drive to get the openhab-papa4.zip files to the Pi ...
In the sudo commands below, change the path from /home/[user]... to the equivalent of /media/pi/USB Disk. Note: if you end up with something like "USB Disk," enclose the whole path with quote marks or it will fail. For example, $ sudo cp "/media/pi/USB Disk/configurations/rules/My.rules" /etc/openhab/configurations/rules/My.rules
One by one, you can select & copy the sudo commands below & paste them into Linux's Terminal (or SSH from another computer on your network) & hit [enter]:
The following copies in the simple customized version from openhab-papa4.zip (You may need to give permission.): $ sudo cp /home/[user]/configurations/openhab.cfg /etc/openhab/configurations/openhab.cfg $ sudo cp /home/[user]/openhab-papa4/configurations/items/My.items /etc/openhab/configurations/items/My.items $ sudo cp /home/[user]/openhab-papa4/configurations/rules/My.rules /etc/openhab/configurations/rules/My.rules $ sudo cp /home/[user]/openhab-papa4/configurations/sitemaps/My.sitemap /etc/openhab/configurations/sitemaps/My.sitemap $ sudo cp /home/[user]/openhab-papa4/configurations/persistence/logging.persist /etc/openhab/configurations/persistence/logging.persist $ sudo cp /home/[user]/openhab-papa4/configurations/persistence/rrd4j.persist /etc/openhab/configurations/persistence/rrd4j.persist $ sudo cp /home/[user]/openhab-papa4/webapps/images/battery.png /usr/share/openhab/webapps/images/battery.png $ sudo cp /home/[user]/openhab-papa4/webapps/images/calendar.png /usr/share/openhab/webapps/images/calendar.png $ sudo cp /home/[user]/openhab-papa4/webapps/images/comfort-level.png /usr/share/openhab/webapps/images/comfort-level.png $ sudo cp /home/[user]/openhab-papa4/webapps/images/garagedoor-closed.png /usr/share/openhab/webapps/images/garagedoor-closed.png $ sudo cp /home/[user]/openhab-papa4/webapps/images/garagedoor-open.png /usr/share/openhab/webapps/images/garagedoor-open.png $ sudo cp /home/[user]/openhab-papa4/webapps/images/humidity.png /usr/share/openhab/webapps/images/humidity.png $ sudo cp /home/[user]/openhab-papa4/webapps/images/network.png /usr/share/openhab/webapps/images/network.png $ sudo cp /home/[user]/openhab-papa4/webapps/images/nodes.png /usr/share/openhab/webapps/images/nodes.png $ sudo cp /home/[user]/openhab-papa4/webapps/images/PushBtn.png /usr/share/openhab/webapps/images/PushBtn.png $ sudo cp /home/[user]/openhab-papa4/webapps/images/secure-closed.png /usr/share/openhab/webapps/images/secure-closed.png $ sudo cp /home/[user]/openhab-papa4/webapps/images/secure-open.png /usr/share/openhab/webapps/images/secure-open.png $ sudo cp /home/[user]/openhab-papa4/webapps/images/sun_clouds.png /usr/share/openhab/webapps/images/sun_clouds.png $ sudo cp /home/[user]/openhab-papa4/webapps/images/switch-on.png /usr/share/openhab/webapps/images/switch-on.png $ sudo cp /home/[user]/openhab-papa4/webapps/images/switch-off.png /usr/share/openhab/webapps/images/switch-off.png $ sudo cp /home/[user]/openhab-papa4/webapps/images/temperature.png /usr/share/openhab/webapps/images/temperature.png ----------------------------------------------------------------------
Another alternative (added 3/2/2016):
To copy files to a Pi without a thumbdrive: SSH instructions include downloading / installing Putty. Along with Putty comes another useful program, PSCP which one can use to copy files to a Pi from a Windows or Linux computer. Follow these instructions to do so. Besides the paths to the downloaded & extracted files, you'll need the Pi paths above, the last part of the sudo lines after the [space] like: /usr/share/openhab/webapps/images/temperature.png Adapt your use of the paths to PSCP's needed format.
|
|
|
Post by lewishollow on Feb 5, 2016 16:30:51 GMT
papa - what version of openhab do you get using these steps? I honestly don't remember what steps I used to install openhab initially, but I do remember that I ended up with an older version and was having problems until I updated to latest.
|
|
|
Post by papa on Feb 5, 2016 16:51:10 GMT
lewishollow, I believe if you follow how I did it, you get the latest version. I certainly just got version 1.8.1, the latest. Likewise, this way puts OpenHAB in line for the usual Linux updates.
|
|
|
Post by lewishollow on Feb 5, 2016 17:02:02 GMT
OK great. Thanks!
|
|
|
Post by papa on Feb 6, 2016 1:26:14 GMT
For a Raspberry Pi running the Raspian version of Linux, how to install OpenHAB & Mosquitto for DIY Home Automation (continued from above):
In the unzipped location, the config files are editable. However, in the OpenHAB configurations folders where you copy them (see above), they lack the permissions so they can be edited. To be able to edit these config files (soon or later), change their permissions. In the Pi's Terminal window or via SSH from another computer on the network, enter these commands: $ sudo chmod a=rwx /etc/openhab /configurations/openhab.cfg $ sudo chmod a=rwx /etc/openhab /configurations/items/My.items $ sudo chmod a=rwx /etc/openhab /configurations/rules/My.rules $ sudo chmod a=rwx /etc/openhab /configurations/sitemaps/My.sitemap [ To Be Continued ]
|
|
|
Post by papa on Feb 6, 2016 19:07:47 GMT
If you want to edit config files now on the Pi with nano via an SSH window on another computer in your network, skip to the next post. (Updated Oct. 12, 2016)
To edit config files now on the Pi, you also may use Pi's Leafpad text editor.
This should work now if you followed an earlier post to change permissions on config files. Using Leafpad may give you a more familiar interface than nano, but may also mean using a more awkward keyboard & touchpad / mouse. I believe openhab-papa4.zip already provides most of the openhab.cfg edits that you will need in so far, except do the following edits with Pi Leafpad. 0) Near the top right of Pi's screen are two overlapping computers. Hover the mouse pointer over them & make note of the Pi's IP address there in the form 192.168.x.y. OR use $ sudo ip addr show In the output toward the bottom see "inet 192.168.x.y"
1) Via Pi's File Manager, go to /etc/openhab/configurations/ select openhab.cfg & double left click or hit [Enter] to open the file in Leafpad. Find ( [Ctrl] F ) security:netmask In the decimaled number (192.168.x.0/24), change the “x” to the 3rd number of your Pi's IP address which you noted just above.
2) Get your location's latitude & longitude here. In openhab.cfg, find weather:location & replace the nearby ##.######'s with your location’s latitude & longitude. 3) Register at Weather Underground (Wunderground) & get an api key: Follow the helpful instructions here. 4) In openhab.cfg, find the line weather:apikey.Wunderground= Put your Wunderground api key following the “=” sign at the end of the line. 5) Save the changed openhab.cfg file ( hold [Ctrl] key & tap "s" key ) Continuing to edit openhab.cfg: 1) Find Mail Action configuration. 2) a) If you use gmail, at mail:username= & mail:from=, replace yourEmailaddress with your address & at mail:password=, replace yourPassword with yours. 2b) If you don't use gmail, for your email service, you'll need to get the right values for: mail:hostname, mail:port, mail:username, mail:password, mail:from, mail:tls, & mail:popbeforesmtp. [To make lines active, be sure they are UNcommented (no # at the line's start) “#” before a line means its “commented” (not active & relying on the default value shown nearby.] Caution added 3/9/2017: In any openhab file that ends in .cfg (like openhab.cfg), to "comment" (to deactivate a code line or to provide an explanatory note), be sure you start each line with the # character. In a .cfg file, do NOT start a commented line with "//" (how we start a commented line in .item, rules, etc files & Arduino sketches) because the .cfg file will become unreadable & throw errors ("openhab.cfg' cannot be read").Later, you can imitate config file entries to add additional nodes to your setup. Still needed is the install of the MQTT (Mosquitto) server which will be addressed below.
|
|
|
Post by papa on Feb 6, 2016 20:38:06 GMT
If you edited OpenHAB config files with Pi's Leafpad text editor (post just above), SKIP THIS POST. (Though you might use some of it's info later to edit protected files.] (Updated Oct. 12, 2016)
Another option: Edit OpenHAB config files with nano via a SSH window on another computer in your network...
That way you can maybe use a better keyboard than the Pi's. However ... Be careful. It seems easy to make mistakes with nano editor. You might review a nano tutorial AND practice first on a non-essential file.
This lets nano open openhab.cfg for editing: $ sudo nano -w /etc/openhab/configurations/openhab.cfg Use appropriate file paths for other config files that need editing Nano's bottom lists Special commands using [Ctrl] + some other key. Use these key combinations carefully because they have different functions in other settings. See the tutorial for more explanation. Some quick nano hints: The colored rectangle indicates the cursor location & it only moves with typing or the cursor arrow keys. Text entry is Insert mode, pushing existing text ahead of it. The mouse cursor works for selecting text which can be copied (safely) with [Ctrl] [Insert] & then pasted (safely) at the cursor location with [Shift] [Insert]. [Shift] [Insert] will also paste text copied from other applications into nano's document at the rectangular cursor. To find text, use [Ctrl] w plus the text then [Enter]. For nano to save your changes & keep the same file name, use [Ctrl] o (for output) & [Enter]. To save your changes to a different file name or path, use [Ctrl] o (for output) then edit the name or path with [backspace] or cursor left/right & finally hit [Enter]. To exit nano & return to the SSH screen & prompt, use [Ctrl] x. If you have not saved document changes, at the bottom, nano asks if you want to. I believe openhab-papa.zip already provides most of the openhab.cfg edits that you will need in so far,
except do the following edits if you are using SSH / nano.
0) Near the top right of Pi's screen are two overlapping computers. Hover the mouse pointer over them & make note of the Pi's IP address there in the form 192.168.x.y. OR in the SSH window, use $ sudo ip addr show In the output toward the bottom see "inet 192.168.x.y" 1) Use $ sudo nano -w /etc/openhab/configurations/ openhab.cfg [Enter] to open the file in Leafpad. Find ( [Ctrl] w ) security:netmask In the decimaled number (192.168.x.0/24), change the “x” to the 3rd number of your Pi's IP address which you noted just above. 2) Get your location's latitude & longitude here. In openhab.cfg, find ([Ctrl] w ) weather:location & replace the nearby ##.######'s with your location’s latitude & longitude. 3) Register at Weather Underground (Wunderground) & get an api key: Follow the helpful instructions here. 4) In openhab.cfg, find the line weather:apikey.Wunderground= Put your Wunderground api key following the “=” sign at the end of the line. 5) Save the changed openhab.cfg file ( hold [Ctrl] key & tap "o" key ) Continuing to edit openhab.cfg: 1) Find Mail Action configuration. 2) a) If you use gmail, at mail:username= & mail:from=, replace yourEmailaddress with your address & at mail:password=, replace yourPassword with yours. 2b) If you don't use gmail, for your email service, you'll need to get the right values for: mail:hostname, mail:port, mail:username, mail:password, mail:from, mail:tls, & mail:popbeforesmtp. [To make lines active, be sure they are UNcommented (no # at the line's start) “#” before a line means its “commented” (not active & relying on the default value shown nearby.] Later, you can imitate config file entries to add additional nodes to your setup.
Still needed is the install of the MQTT (Mosquitto) server which will be addressed below.
|
|
|
Post by papa on Feb 6, 2016 23:40:47 GMT
Installing the needed MQTT service (latest version) on a Raspberry Pi (or 2)...
Now having a Raspberry Pi 2 B, I verified this install. Using a Terminal or SSH command, display your Pi's Linux version ... $ cat /etc/*release
The results from my Pi (relevant info bold faced) pi@raspberrypi:/ $ cat /etc/*release PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)" NAME="Raspbian GNU/Linux" VERSION_ID="8" VERSION="8 (jessie)" ID=raspbian ID_LIKE=debian In his Newbie... thread in his Oct 14, 2015, 12:53pm post, lhw455 reports the following worked for him: & it also worked for me Follow this guide at jpmens.net/2013/09/01/installing-mosquitto-on-a-raspberry-pi/ Except, near the start with this part: curl -O repo.mosquitto.org/debian/mosquitto-repo.gpg.key sudo apt-key add mosquitto-repo.gpg.key rm mosquitto-repo.gpg.key cd /etc/apt/sources.list.d/ sudo curl -O repo.mosquitto.org/debian/mosquitto-repo.list sudo apt-get update ... follow this instead: [ Papa bold-faced the one change] For Debian Wheezy (earlier version of Debian) ... curl -O repo.mosquitto.org/debian/mosquitto-repo.gpg.key sudo apt-key add mosquitto-repo.gpg.key rm mosquitto-repo.gpg.key cd /etc/apt/sources.list.d/ sudo curl -O repo.mosquitto.org/debian/ mosquitto-wheezy.listsudo apt-get update Or for Jessie ... follow this instead: [ Papa bold-faced the one change] Papa: Since my version displayed above as jessie, I used this version: curl -O repo.mosquitto.org/debian/mosquitto-repo.gpg.key sudo apt-key add mosquitto-repo.gpg.key rm mosquitto-repo.gpg.key cd /etc/apt/sources.list.d/ sudo curl -O repo.mosquitto.org/debian/ mosquitto-jessie.listsudo apt-get update Continuing with jpmens.net/2013/09/01/installing-mosquitto-on-a-raspberry-pi/ ... Install the 3 packages for Mosquitto proper: On Pi's Terminal or SSH connected to Pi, $ sudo apt-get install mosquitto mosquitto-clients python-mosquitto
FYI: mosquitto is the MQTT broker (i.e. server) mosquitto-clients are the command-line clients, also recommended python-mosquitto has the Python bindings, also recommended Since the Mosquitto broker immediately starts, stop it: $ sudo /etc/init.d/mosquitto stop
The jpmens guide continues with more, but I don't believe I used it. Still to do (See below): Start OpenHAB & set it to run when the system restarts. Also start Mosquitto (MQTT) broker.
|
|
|
Post by papa on Feb 7, 2016 0:23:45 GMT
Start Mosquitto (MQTT) broker & Start OpenHAB Server & Configure OpenHAB to run with system restart
Start Mosquitto (MQTT):$ sudo service mosquitto startBTW, Mosquitto will restart with system restart. Also, you might sometimes use these commands $ sudo service mosquitto status ----------------------------------------
Two Ways to Start openHAB - manually
Init based on sysVinit (e.g. Debian 7 / Ubuntu 14.x and earlier)
$ sudo /etc/init.d/openhab start
$ sudo /etc/init.d/openhab status ^^ I've used these & BTW, to stop, use $ sudo /etc/init.d/openhab stop OR
Init based on systemd (e.g. Debian 8 / Ubuntu 15.x and higher): $ sudo systemctl start openhab ^^ Seems like this works sometimes when the other one does not ----------------------------------------------------------------
Two Ways to Start OpenHAB - at system startup ... Init based on sysVinit: $ sudo update-rc.d openhab defaults ^^ This one worked for me on another Linux computer after I restarted it. Init based on systemd: $ sudo systemctl daemon-reload$ sudo systemctl enable openhab ^^ This one worked for me on my Pi after I restarted it. IF your MQTT server is adequately installed & your Gateway is set up properly & powered & connected to your network, the Gateway's MQTT LED should light. In a new Pi's Terminal window, you can use $ mosquitto_sub -v -t '#' That subscribes to ANY topic you publish & report the topic name & the payload. It should display messages from OpenHAB & from the Gateway & end nodes if they are set up properly, powered, & connected to your network.
Your OpenHAB & Mosquitto should update via the Pi's regular Linux update process...
In a Pi Terminal window or SSH from another computer on your network, use the commands: $ sudo apt-get update $ sudo apt-get upgrade $ sudo rpi-update ============================== If you upgrade to OpenHAB 2, stop OpenHAB 1 with: sudo systemctl stop openhab.service & disable OH 1 from starting when the Pi starts: sudo systemctl disable openhab.service
|
|
|
Post by papa on Feb 7, 2016 0:47:50 GMT
Launch An OpenHAB User Interface on Your Pi
In a Web Browser on your Pi running OpenHAB, enter this address http://localhost:8080/openhab.app?sitemap=My The OpenHAB user interface should appear in the browser showing data & virtual controls. In the user interface, you should see a virtual switch for Node02’s relay, & Node02’s temp & humidity. If you click on the Outside Temp (from Yahoo weather for your location), you get more weather info including a representation of comfort level. To return to the main user interface window, at the top, click on My House or the browser back button. At the bottom is date & time info, current to the last minute. Default was 15 minutes, I’m not sure why. In openhab.cfg, you can change this at ntp:refresh= (divide the number by 1,000 to get how long between refreshes) At the top left of the interface, see a link for Node Health. When clicked, it shows you Node02’s radio signal strength (RSSI) & voltage. This data make take a while to show up. Whatever RSSI is good enough if you get data. Hurrah, you have a simple, but working DIY Home Automation Network to build on. Awesome, eh? But It Gets Better ...
Using the OpenHAB User Interface on Another Computer in Your Local Network
Here's another good reason to assign a fixed IP address to the computer hosting the OpenHAB server program. In your local network, say OpenHAB server is running on a computer with the fixed address 192.168.1.12 & in your /etc/openhab/configurations/sitemaps folder, you have the config file My.sitemap. In a browser address box on another computer in your local network, enter 192.168.1.12:8080/openhab.app?sitemap=My [enter key] Your sitemap user interface should appear within that browser so you can view & control your openHAB network from there. You might put that [192.168... ] address in your bookmarks so you don't need to type it again. Following the above paragraph, your Pi could run alone without keyboard, touchpad / mouse or monitor. You could view & control OpenHAB from the other computer in your network. Again this works on another computer within your local network where your OpenHAB computer has an ip address. To use another computer in ANOTHER local network, you must work through the internet as described below.
|
|
|
Post by papa on Feb 7, 2016 1:10:04 GMT
Next Awesome step ... Getting Internet Access to your OpenHAB network via My.OpenHAB ( my.openhab.org/ ) The openHAB Cloud Service has moved so this post was updated on 1/30/2017
Control your OpenHAB user interface on ANY computer with internet connection & an internet browser.
Stop the OpenHAB server: $ sudo /etc/init.d/openhab stop If like me you used the OLD openHAB Cloud site (my.openhab.org) ... In openhab.cfg, I did not see any old my.openhab.org stuff to disable. I removed org.openhab.io.myopenhab-1.8.3.jar from addons folder & parked it elsewhere. Documentation for OpenHAB 2 is here. Since I use OpenHAB 1 ... Documentation for OpenHAB 1 is here. Below I summarize that plus other things I learned: Download org.openhab.io.openhabcloud_1.9.0.201612192331.jar to your /usr/share/openhab/addons folder ^^ Link added on 2/6/2017 It's part of an upcoming 1.9.x version, but supposed to work with 1.8.x In openhab.cfg file, just before Binding Configurations, I added the following At first, I left them as is & did not edit them. ############################## openHAB Cloud Connector #############################
# The URL of the openHAB Cloud service to connect to. # Optional, default is set to the service offered by the openHAB Foundation # (https://myopenhab.org/) #openhabcloud:baseURL=
# Local port that the openHAB runtime is available through HTTP. # Optional, default is 8080 #openhabcloud:localPort=
# Defines the mode in which you want to operate the connector. # Possible values are: # - notification: Only push notifications are enabled, no remote access is allowed. # - remote: Push notifications and remote access are enabled. # Optional, default is 'remote'. #openhabcloud:mode=
# A comma-separated list of items to be exposed to external services like IFTTT. # Events of those items are pushed to the openHAB Cloud and commands received for # these items from the openHAB Cloud service are accepted and sent to the local bus. # Optional, default is an empty list. #openhabcloud:expose= With a Pi text editor, see & note the contents of /usr/share/openhab/webapps/ uuid & /usr/share/openhab/webapps/static/ secret. Prepare a robust password. A password technique I like is aiming for at least 9 characters, choose a phrase from a song or a made up sentence, reduce each word to a single letter (keeping capitalization), maybe add a symbolic mark (like < . , & ^ $ # if permitted) & add a number like a year. For example, "When Johnny comes marching home again 2015" becomes the password: WJcmha2015 This is a challenge for others to guess, but memorable to you. Register as a new user here. (<< Caution: the site address no longer has a period after "my") You will supply your email address (must be all lower case), a password (see above) for your myopenhab account, AND the information you copy from the uuid & secret files. Notice you are providing like TWO passwords, one for your account & "secret," the code for connecting with your OpenHAB server. Added April, 24, 2016: If you do a new install of OpenHAB later, you must update your myopenhab account with the NEW uuid & secret. Here login to myopenhab by giving your previously registered email address & ACCOUNT password. Then at the upper right, click on your email address then Account. Enter the NEW uuid & secret there. In the Getting Started Guide is the section “Adjusting openHAB security settings to work with my.openHAB.” I included most of this in your downloaded openhab.cfg files. If you followed the directions above, you should have finished the rest. << Not sure about this. Need to check. Restart OpenHAB server: $ sudo /etc/init.d/openhab start. Once all this is accomplished you should be able to use any computer to log in to your OpenHAB user interface via my.openhab.org/login Even Better: Controlling OpenHAB with your (internet- or cellular- connected) Apple or Android device
Get OpenHAB iOS App at App Store. Or get OpenHAB Android App at Google Play. Also updated, 1/30/2017: Configuring openHAB iOS and Android apps can't be easier. Just set remote URL to myopenhab.org/ in your app's settings and set username (email address) and password (account password) to the same ones (see above) you use to log in to myopenhab.org website, and you are done. << If you used the OLD openHAB Cloud Service, the remote URL must be changed (no period after "my"). Change the password if you registered with one different than what you used with the old openHAB cloud site. Once you’ve registered at my.openhab.org & your app is configured as above, you can use the app to see & control your OpenHAB server with the same user interface you see on the browser where the server is running. I hope by now that your OpenHAB with Mosquitto is working well on your Raspberry Pi & elsewhere. Best wishes & enjoy!
|
|
|
Post by papa on Feb 7, 2016 2:16:44 GMT
Protect Your OpenHAB / Mosquitto/ etc on Raspberry Pi
I started this thread with caution: Avoid shutting down the Pi by turning off its power or doing anything else except by Menu / Shutdown / Shutdown. Avoid restarting the Pi by turning its power off & on or doing anything else except by Menu / Shutdown / Reboot. Otherwise you can corrupt its SD card & you'll have to start from scratch. That said, even with all your best practices, a power outage could still corrupt your SD card. As soon as you get your PI set up with OpenHAB / Mosquitto, I recommend you make a backup image of your SD card that you can quickly install on a new or corrupted card for yourself or a friend. To backup or restore your SD card, follow this guide.
|
|
|
Post by greginkansas on Feb 7, 2016 12:08:37 GMT
Nice work papa. I use this, fast - run on system with no shutdown. github.com/billw2/rpi-cloneAlso 8-16 gig ssds are $15 I have done this. This gives a little more speed and no SD wearout, so you can let the logs run. Greg
|
|
|
Post by papa on Feb 7, 2016 15:05:16 GMT
Thanks for the kudos & added info, greginkansas
Seems good to have the option of cloning a SD card WHILE it's running in a PI & cloning TO an SD card adapted into that Pi's USB port. Also seems the rpi-clone has a good system of progressive backups.
Though the method I documented requires Pi shutdown & transferring SD card to card reader, it could allow many backups limited only by hard disk size.
Hmmm, I wonder if Pis can handle a portable hard drive in a USB port & if rpi-clone could point to a method to backup & restore images via the portable hard drive.
|
|
|
Post by greginkansas on Feb 7, 2016 16:15:44 GMT
Though the method I documented requires Pi shutdown & transferring SD card to card reader, it could allow many backups limited only by hard disk size. I remove the "SD temp" backup and do images on big changes, and just run rpi-clone to the SD every now and then.
|
|
|
Post by chrisinkc on Feb 8, 2016 22:36:18 GMT
Papa, where was this a month ago when I started working on setting up OpenHab on a Pi?? This would have saved me A LOT of time trying to piece together all of the different steps from different sources of info.
I hope everyone who visits this forum truly appreciates all of the time you put into these tutorials.
I know I do!
|
|
|
Post by papa on Feb 9, 2016 1:19:01 GMT
chrisinkc, thanks for your feedback. After getting the nodes working & installing / configuring OpenHAB / Mosquitto on Windows & on a Linux laptop, the Pi implementation went pretty quick, but documenting it all really took longer.
So I'm glad my documentation would have helped you & could help others. I believe different types of documentation are helpful for different people. I try to shape mine for people like I was on much & still am on many other things: "green as grass" & scrounging many places to get clues to overcome obstacles. My documentation is very detailed which may not appeal to some folks. I hope that people can skip details they don't need & use the ones they do need.
So if you know / learn a way to overcome a problem, to explain a good way to accomplish part of this project or to advance it ... please take some time to share it here in some form.
|
|
|
Post by papa on Feb 21, 2016 20:29:56 GMT
Helpful Tip for Debugging OpenHAB Config File Entries
On Linux / Raspberry PI, How to View Continuous Updates to Log Files
I find value in older threads on this forum, real treasure troves. I just came across Raspberry Pi better way to view changing log files? which began: [ Papa: When I moved from Windows to Linux / Raspberry PI, I had the same disappointment & desire. ]
Computourist suggested: Start Openhab manually using a remote terminal program like Putty: log in and: > sudo /opt/openhab/start.sh and you'll see events in realtime.. [ Papa: Same for me. I did find start.sh among OpenHAB downloads, but did not get it to work. ] Papa: In describing demondreamer's situation, computourist also described mine & the solution. So now in a local or remote terminal window, I can enter the following & see an ongoing output of events, updates of various OpenHAB states: tail -f /var/log/openhab/events.log I can enter the following & see OpenHAB's startup messages, error messages, & shut down messages: tail -f /var/log/openhab/openhab.log I can enter the follow & see OpenHAB's GETs for Feb 21, 2016: tail -f /var/log/openhab/2016_02_21.request.log
I can have one or all of the above terminal windows open to monitor how OpenHAB is doing. On these displays, watch for where config file entries are working or not. Use the scroll button to move around in the display or to halt it from scrolling by. (Of course, you can also open an openhab log file in a text error & search for problems there.) Then you can internet search for the wording of the error message. Thanks, demondreamer for asking, & thanks computourist for answering.
|
|
|
Post by papa on Feb 22, 2016 19:48:12 GMT
Update on the Weather Binding
At this post on OpenHAB community, I saw that more people were having trouble with the weather binding in recent versions of OpenHAB. Here is a suggested work around (I have not tried it yet) This would mean (in the openhab/addons folder) replacing a org.openhab.binding.weather.1.8.x.jar file with a org.openhab.binding.weather.1.7.x.jar file. You may need to stop OpenHAB. You might just rename the org.openhab.binding.weather.1.8.x.jar to org.openhab.binding.weather.1.8.x.jas. Keep a copy of that 1.7.x file in a safe place. Linux updates might overwrite it in the openhab/addons folder. If you don't already have a copy of org.openhab.binding.weather.1.7.x.jar, you can download the total addons file here & just extract that file.
|
|
|
Post by tjohansen on Feb 27, 2016 8:59:44 GMT
Hi papa, just got a little comment on a part of this guide. its not possible to do a wget on files attached to the proboard. like the url: homeautomation.proboards.com/attachment/download/169so workrounds are needed to get it to the pi. just saying, I know how, but others might not.
|
|
|
Post by papa on Feb 27, 2016 13:37:06 GMT
tjohansen, you have a point there. May be time for a post about SSH, putty, & the like. Though if one has a inexpensive keyboard / touch pad & monitor connected to the pi, they could download things via a browser. Then again that would require downloading to an unprotected folder & sudo moving it into the openhab config folders. One way or another, probably could use some more explanation for newer users.
|
|
|
Post by papa on Feb 29, 2016 2:11:31 GMT
I believe we a ll want an awesome or at least a relatively robust DIY Home Automation system. When we bump into difficulties, have we not implemented things correctly OR are we bumping into limitations of the system? Are there ways to adapt to minimize bottle necks or work around them? Turns out the computer hosting OpenHAB / MQTT, especially a Raspberry Pi, could become part of a bottle neck. I've started a new thread, DIY Home Automation: Capabilities & Limits, hoping we can address these matters there. Please join me on that new thread in posting some information about your system, limits you feel you've experienced, & how you've tried to address them.
|
|
|
Post by papa on Feb 29, 2016 21:24:57 GMT
sam4205 reminded me of this thread about Raspberry Pi's performance related to OpenHAB. On that thread, some people report robust systems running on Raspberry Pi 2, but discourage using Pi 1 One big recommendation was to avoid major writes to the Pi SD card because the cards corrupt sooner. Rather for writes, use a USB drive of some kind. Visit the link for more details. ========================== Update 3/23/2017See this post from jimkernsjr about how to avoid filling up limited disk space on an older Linux machine or a memory card on a Raspberry Pi
|
|
|
Post by papa on Mar 2, 2016 15:35:10 GMT
See the top post on this thread, Feb 5, 2016 at 10:41am. That mentions downloading to another computer & using a thumb drive to get it to the Pi. In regard to using SSH from another computer to work on Pi files, I said (top post above), "Follow SSH instructions beginning here." What if one wants to copy files to a Pi without using a thumbdrive. The SSH instructions include downloading / installing Putty. Along with Putty comes another useful program, PSCP which one can use to copy files to a Pi from a Windows or Linux computer. Follow these instructions to do so. If one needs from the beginning to set up a Pi that has no monitor, keyboard, or mouse, do an internet search for "Raspberry Pi headless"
|
|
|
Post by papa on Oct 12, 2016 15:49:18 GMT
Based on further experience, this thread was updated on Oct. 12, 2016. Posts edited: Feb 5, 2016 at 9:36am, Feb 5, 2016 at 9:41am, Feb 6, 2016 at 1:07pm, & Feb 6, 2016 at 2:38pm
The changes in the indicated posts include an updated openhab-papa4.zip collection of sample OpenHAB config files (see the Feb 5, 2016 at 9:41am post) & instructions on installing & customizing them.
|
|
|
Post by papa on Jan 30, 2017 20:35:34 GMT
The OpenHAB Cloud Service has moved, requiring changes.
In the Feb 6, 2016 post above that includes " Getting Internet Access to your OpenHAB network via MyOpenHAB" I updated getting remote access to your OpenHAB User Interface via an internet browser or smart phone app.
|
|
|
Post by jimkernsjr on Mar 16, 2017 0:45:42 GMT
Hi Papa... It doesnt have to be a hassle editing the files on the PI. Set yourself up a SAMBA share, then you can use Windoze file and print sharing to map a drive to it. Since you have limitied linux knowledge and seem to be best at windows, you can just access the files through the drive letter. Install SAMBA first, then WEBMIN. ALERT, Webmin has a couple dependencies, and I'm sorry I dont use PI for that as I have a full blown Linux server, but I THINK this can resolve them IF you do this way: Get SAMBA: sudo apt-get install samba (or use that R PI Package management thingie) Add Dependencies for WEBMIN: sudo apt-get install libauthen-pam-perl libio-pty-perl apt-show-versions Download WEBMIN debian package here(3rd one is the DEBIAN flavor, and I assume you run RASPBIAN): www.webmin.com/download.htmlWEBMIN MAY be in the RASPBIAN software suppository, I don't know...but you can check-it may be easier. after you download (modify of course for current version): sudo dpkg -i webmin_1.740_all.deb navigate to(substituting of course the 10.1.1.15 with your PI's IP): 10.1.1.15:10000Login with you PI username, Navigate to: Servers/Samba on the left pane and set yourself up a share. After done, just go to windows explorer, type \\address of pi (\\10.1.1.15) in my case, RIGHT click the share you made in the above step, chose map network drive, pick a letter and your are done. Alert: you may run into permissions problem. While it's not a best practice, I open the command prompt on linux, navigate to the openhab config files directory, and do a sudo chmod -R 777 name_of_openhab_install_directory This says anyone can read/write/execute all the files in the directory, and to do it recursively. On your home network, and you dont have the fileprintshare ports exposed to the outside world, you have nothing to worry about. I dont know where your OpenHAB installation may lie, as I think you use package manager to install your stuff, I put all mine under /opt. This makes it really easy to upgrade, backup, change your config files, view your logs from Windoze. Theres thousands of articles on the internet on how to do it, but you pick up quick I sure you can figure it yourself with the above, as most people on this forum can or already have as well. You dont need me to tell you all the specifics. I like it because I do have a newer Windows laptop with the Smarthome designer on it, and I can point it to that share. My linux server sits in a closet and I hate VNC, so this method is the simplest. Hope it helps!
|
|
|
Post by papa on Mar 16, 2017 0:57:37 GMT
Thanks, again, jim for the details on editing Linux files via Windows. I'm using Putty & pscp from Windows for some OH file work, but still need to edit Pi files sometimes.
Once your described set up is done, the possibilities sound more like what I'm used to. I'll give it a try when I get a chance or maybe when I get really frustrated clumsy editing on the Pi with a tiny keyboard & touch pad.
Note: This discussion continues on page 2 of this thread.
|
|