步骤1:
始终要确保您使用的是最新更新的软件包,因此,从此开始吧:
sudo apt-get updatesudo apt-get upgrade
某些应用可能会要求您更新固件,但通常不是必需的。我建议还是这样做。
sudo rpi-update
您可以使用任何一种将文件复制到pi的方式。我选择下载它们。我还喜欢将它们直接下载到将要从中提取它们的文件夹中。然后,我将做一些整理工作,并删除不必要的zip文件。首先让我们创建所需的文件夹。
sudo mkdir /opt/openhab
然后您将要下载最新版本到该文件夹。您可以通过以下方法进行操作:转到openhab下载页面,然后右键单击运行时核心下载并复制链接地址以获取最新版本。然后,您可以将下面的网址替换为您复制的网址。
cd /opt/openhab
wget https://github.com/openhab/openhab/releases/download/v1.5.1/distribution-1.5.1-runtime.zip
好,让我们安装此b * tch。您下载的zip文件应该已经提取到正确的位置。如果您还没有,请转到openhab文件夹并在其中解压缩运行时zip文件。
cd /opt/openhabsudo
unzip distribution-1.5.1-runtime.zip
现在让我们删除将不再包含的zip文件。
rm distribution-1.5.1-runtime.zip
很好,已经安装了运行时并删除了zip文件,但是为了使openhab正常工作,您需要添加绑定。在提取运行时zip后,将创建一个“附加组件”文件夹。所有绑定都属于此文件夹。转到addons文件夹并解压缩addons zip。首先让我们将它们下载到适当的文件夹中。
cd addons/
wget https://github.com/openhab/openhab/releases/download/v1.5.1/distribution-1.5.1-addons.zip
其中包含可用于openhab的所有绑定。如openhab wiki中所述,绑定是可选软件包,可用于扩展openhab的功能。通过绑定的帮助,openhab用户可以例如访问asterisk通信软件或连接到knx家庭自动化总线。
让我们先安装所有这些,以后我们就可以筛选并决定保留哪一个。您只需从addons文件夹中删除.jar文件。
sudo unzip distribution-1.5.1-addons.zip删除或擦除zip文件。
rm distribution-1.5.1-addons.zip
接下来,我们将一个文件夹返回到openhab文件夹并复制“ openhab_default.cfg”文件。您将其称为“ openhab.cfg”。如果您必须更新您的openhab,则默认文件也会被更新。通过复制该文件,openhab将使用该文件进行配置,并且也不会对其进行更新。由于您将进行自己的自定义配置,因此务必将这些文件写入“ openhab.cfg”文件中以确保安全。
cd 。. sudo cp configurations/openhab_default.cfg configurations/openhab.cfg
在为了了解这种疯狂的事情是如何工作的,我建议部署演示应用程序。这是让您立足并对此有所了解的好方法。
cd /opt/openhab
wget https://github.com/openhab/openhab/releases/download/v1.5.1/distribution-1.5.1-demo-configuration.zip
转到openhab文件夹并在那里提取演示zip文件。 。 cd /opt/openhab
sudo unzip distribution-1.5.1-demo-configuration.zip
删除垃圾文件
rm distribution-1.5.1-demo-configuration.zip
默认情况下,“ start.sh”脚本不是可执行文件。为了使它可执行,请执行以下操作:
sudo chmod +x start.sh
sudo 。/start.sh
然后,乐趣就开始了!您应该有一个完全加载的演示,可以用来熟悉openhab。只需转到您的电话或计算机,然后将以下网址放在您喜欢的浏览器中即可。确保将ip地址替换为pi的ip地址。
http://192.168.x.xxx:8080/openhab.app?sitemap=demo
步骤2:将openhab配置为在启动时自动启动
如果发生电涌,断电或决定重新启动pi,则需要重新启动您的openhab程序。后端那是一个很大的痛苦,所以我们将要配置它在启动时启动。
首先,您将要在/etc/init.d文件夹中创建一个名为“ openhab”的新文件。
您将要使用nano编辑器向openhab文件中添加几行代码或您最喜欢的编辑器。
sudo nano /etc/init.d/openhab
添加此代码:
#! /bin/sh
### begin init info # provides: openhab # required-start: $remote_fs $syslog # required-stop: $remote_fs $syslog # default-start: 2 3 4 5 # default-stop: 0 1 6 # short-description: openhab daemon ### end init info# author: thomas brettinger# do not “set -e”# path should only include /usr/* if it runs after the mountnfs.sh script path=/sbin:/usr/sbin:/bin:/usr/bindesc=“open home automation bus daemon” name=openhab daemon=/usr/bin/java pidfile=/var/run/$name.pid scriptname=/etc/init.d/$name eclipsehome=“/opt/openhab”; httpport=8080 httpsport=8443 telnetport=5555 # be sure you are adopting the user to your local oh user run_as=pi# get path to equinox jar inside $eclipsehome folder cp=$(find $eclipsehome/server -name “org.eclipse.equinox.launcher_*.jar” | sort | tail -1);daemon_args=“-dosgi.clean=true -declipse.ignoreapp=true -dosgi.noshutdown=true -djetty.port=$httpport -djetty.port.ssl=$httpsport -djetty.home=$eclipsehome -dlogback.configurationfile=$eclipsehome/configurations/logback.xml -dfelix.fileinstall.dir=$eclipsehome/addons -djava.library.path=$eclipsehome/lib -djava.security.auth.login.config=$eclipsehome/etc/login.conf -dorg.quartz.properties=$eclipsehome/etc/quartz.properties -djava.awt.headless=true -jar $cp -console ${telnetport}”# exit if the package is not installed [ -x “$daemon” ] || exit 0# read configuration variable file if it is present [ -r /etc/default/$name ] && 。 /etc/default/$name# load the verbose setting and other rcs variables 。 /lib/init/vars.sh# define lsb log_* functions. # depend on lsb-base (》= 3.2-14) to ensure that this file is present # and status_of_proc is working. 。 /lib/lsb/init-functions# # function that starts the daemon/service # do_start() { # return # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started start-stop-daemon --start --quiet --make-pidfile --pidfile $pidfile --chuid $run_as --chdir $eclipsehome --exec $daemon --test 》 /dev/null \ || return 1 start-stop-daemon --start --quiet --background --make-pidfile --pidfile $pidfile --chuid $run_as --chdir $eclipsehome --exec $daemon -- $daemon_args \ || return 2 # add code here, if necessary, that waits for the process to be ready # to handle requests from services started subsequently which depend # on this one. as a last resort, sleep for some time. return 0 }# # function that stops the daemon/service # do_stop() { # return # 0 if daemon has been stopped # 1 if daemon was already stopped # 2 if daemon could not be stopped # other if a failure occurred start-stop-daemon --stop --quiet --retry=term/30/kill/5 --pidfile $pidfile --name $name retval=“$?” [ “$retval” = 2 ] && return 2 # wait for children to finish too if this is a daemon that forks # and if the daemon is only ever run from this initscript. # if the above conditions are not satisfied then add some other code # that waits for the process to drop all resources that could be # needed by services started subsequently. a last resort is to # sleep for some time. start-stop-daemon --stop --quiet --oknodo --retry=0/30/kill/5 --exec $daemon [ “$?” = 2 ] && return 2 # many daemons don‘t delete their pidfiles when they exit. rm -f $pidfile return “$retval” }# # function that sends a sighup to the daemon/service # do_reload() { # # if the daemon can reload its configuration without # restarting (for example, when it is sent a sighup), # then implement that here. # do_stop sleep 1 do_start return 0 }case “$1” in start) log_daemon_msg “starting $desc” do_start case “$?” in 0|1) log_end_msg 0 ;; 2) log_end_msg 1 ;; esac ;; stop) log_daemon_msg “stopping $desc” do_stop case “$?” in 0|1) log_end_msg 0 ;; 2) log_end_msg 1 ;; esac ;; status) status_of_proc “$daemon” “$name” && exit 0 || exit $? ;; #reload|force-reload) # # if do_reload() is not implemented then leave this commented out # and leave ’force-reload‘ as an alias for ’restart‘。 # #log_daemon_msg “reloading $desc” “$name” #do_reload #log_end_msg $? #;; restart|force-reload) # # if the “reload” option is implemented then remove the # ’force-reload‘ alias # log_daemon_msg “restarting $desc” do_stop case “$?” in 0|1) do_start case “$?” in 0) log_end_msg 0 ;; 1) log_end_msg 1 ;; # old process is still running *) log_end_msg 1 ;; # failed to start esac ;; *) # failed to stop log_end_msg 1 ;; esac ;; *) #echo “usage: $scriptname {start|stop|restart|reload|force-reload}” 》&2 echo “usage: $scriptname {start|stop|status|restart|force-reload}” 》&2 exit 3 ;; esac :
您也可以转到此处查看可读版本,也可以从此处复制并粘贴代码。
您可能需要将 run_as = pi 更改为当前用户。
最后,您将要使它成为可执行文件。
sudo chmod a+x /etc/init.d/openhab
并使其在pi的开始时自动启动
sudo update-rc.d openhab defaults
如果出现以下错误:
insserv: script openhab is broken: incomplete lsb comment. insserv: missing `provides:’ entry: please add. insserv: missing `required-start:‘ entry: please add even if empty. insserv: missing `required-stop:’ entry: please add even if empty. insserv: missing `default-start:‘ entry: please add even if empty. insserv: missing `default-stop:’ entry: please add even if empty. insserv: default-start undefined, assuming empty start runlevel(s) for script `openhab‘ insserv: default-stop undefined, assuming empty stop runlevel(s) for script `openhab’
然后出现缩进问题。有时,在粘贴到编辑器中时,文本会以易于阅读的格式放置,从而在某些初始代码行中放置缩进。为update-rc.d编写的任何信息都必须在第一列中。并且在“#”之前不应有任何表格或空格。如果有任何删除它们,否则您将生成该错误。
返回您的文件并仔细检查。
sudo nano /etc/init.d/openhab
前几列应如下所示(请勿复制粘贴,包含ascii字符间距),仅将其用作可视示例:
#!/bin/sh
### begin init info
#提供:openhab
#必需开始:$ remote_fs $ syslog
#必需停止:$ remote_fs $ syslog
#默认-开始:2 3 4 5
#默认值:0 1 6
#简短描述:openhab守护进程
### end init info
注意每个#之前没有空格或缩进
完成,您的raspberry pi现在将在启动时启动openhab。
步骤3:附加功能(管理控制台)
fyi
openhab有一个很酷的管理控制台,称为habmin。它非常适合执行管理任务以及配置各种过程。搜索它,并确定它是否适合您。
Sensirion室内空气质量传感方案
苏州博智慧达激光视觉传感器系列
蓝牙降噪耳机设计实战篇(五)
和SIMCom一起解锁医疗物联网IoMT
揭密OPPO手机视频拍摄EIS效果新突破
怎样在树莓派上使用OpenHAB
MEMS产品与技术,让创新超越一切可能
荧光定量食品重金属检测仪 技术参数特点
利元亨为中国锂电池装备在动力电池产能新一轮爆发期中做足准备
North Hills数据总线继电器简介
无线通信模块种类
无人机可以通过电脑LED光线窃取数据!逗我呢?
大联大世平集团推出太阳能微型逆变器方案
以网约车业务为根本的滴滴能否做好自动驾驶力战四方?
RF CMOS技术的毫米波雷达方案
深度分析全球范人形机器人技术专利布局趋势
PCB最小颈口长度连接到0603的焊盘布置规则资料概述
区块链协议Eleven01介绍
干式变压的维护保养介绍
探究芯片制作的全过程