From cdb778aac601dfd37711938f5397458192d335d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Sat, 6 Jan 2018 15:40:51 +0100 Subject: [PATCH 1/6] Added docs for Homebridge --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index aa0d1595..b305c8b7 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,15 @@ Usually this script is not run after installation but could be used with some mo This script was originally contributed by [@Landrash](https://github.com/landrash). +### Install Homebridge with Home Assistant addon *(install_homebridge.sh)* +This script will install and configure Homebridge to be used with Home Assistant. +This will allow you to controll your home with Apple's HomeKit (Siri on iOS, OSX and AppleTV). +By default all devices are hidden, and you will need to add som entries in your `customize.yaml` configuration. +You can learn more about this in the [Home Assistant for Homebridge repo.](https://github.com/home-assistant/homebridge-homeassistant#customization) +_NB!: This install script will fail resulting in your Pi to reboot, if you do not use an recomended level powersupply._ + +This script was originally contributed by [@Ludeeus](https://github.com/ludeeus). + ### Install databases The following scripts are meant for use with the [recorder](https://home-assistant.io/components/recorder/) component in Home Assistant and install databases and/or tools required for using them. From 32269450c6b099cda81daa1dcad69adae4b44d5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Sat, 6 Jan 2018 15:42:41 +0100 Subject: [PATCH 2/6] Added install script for Homebridge --- .../opt/hassbian/suites/install_homebridge.sh | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 package/opt/hassbian/suites/install_homebridge.sh diff --git a/package/opt/hassbian/suites/install_homebridge.sh b/package/opt/hassbian/suites/install_homebridge.sh new file mode 100644 index 00000000..3d93931f --- /dev/null +++ b/package/opt/hassbian/suites/install_homebridge.sh @@ -0,0 +1,130 @@ +#!/bin/bash +function homebridge-show-short-info { + echo "Installs and configure homebridge for Home Assistant." +} + +function homebridge-show-long-info { + echo "Installs and configure homebridge for Home Assistant" + echo "This will allow you to use HomeKit enabled devices to control Home Assistant." +} + +function homebridge-show-copyright-info { + echo "Original concept by Ludeeus " + echo "Disclaimer: Some parts of this script is 'borrowed' from Dale Higgs " +} + +function homebridge-install-package { +homebridge-show-long-info +homebridge-show-copyright-info + +echo "Preparing system, and adding dependencies..." +sudo apt update +sudo apt -y upgrade +sudo apt install -y make git +curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - +sudo apt install -y nodejs +sudo apt install -y libavahi-compat-libdnssd-dev + +echo "Installing homebridge for homeassistant..." +sudo npm install -g --unsafe-perm homebridge hap-nodejs node-gyp +sudo npm install -g homebridge-homeassistant + +echo "Adding homebridge user, and creating config file..." +sudo useradd -M --system homebridge +sudo mkdir /home/homebridge +sudo mkdir /home/homebridge/.homebridge +sudo touch /home/homebridge/.homebridge/config.json + +echo "" +echo "" +echo "Example: https://home.duckdns.org:8123" +echo -n "Enter your Home Assistant URL and port: " +read HOMEASSISTANT_URL +if [ ! "$HOMEASSISTANT_URL" ]; then + HOMEASSISTANT_URL="http://127.0.0.1:8123" +fi + +echo "" +echo "" +echo -n "Enter your Home Assistant API password: " +read -s HOMEASSISTANT_PASSWORD +echo + +HOMEBRIDGE_PIN=$(printf "%03d-%02d-%03d" $(($RANDOM % 999)) $(($RANDOM % 99)) $(($RANDOM % 999))) +HEX_CHARS=0123456789ABCDEF +RANDOM_MAC=$( for i in {1..6} ; do echo -n ${HEX_CHARS:$(( $RANDOM % 16 )):1} ; done | sed -e 's/\(..\)/:\1/g' ) +HOMEBRIDGE_USERNAME=CC:22:3D$RANDOM_MAC +HOMEBRIDGE_PORT=$( printf "57%03d" $(($RANDOM % 999))) +cat > /home/homebridge/.homebridge/config.json < /etc/systemd/system/homebridge.service < Date: Sun, 7 Jan 2018 00:53:17 +0100 Subject: [PATCH 3/6] Corrected discord channel name --- package/opt/hassbian/suites/install_homebridge.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/opt/hassbian/suites/install_homebridge.sh b/package/opt/hassbian/suites/install_homebridge.sh index 3d93931f..8a10caaa 100644 --- a/package/opt/hassbian/suites/install_homebridge.sh +++ b/package/opt/hassbian/suites/install_homebridge.sh @@ -116,7 +116,7 @@ if [ "$validation" != "0" ]; then echo "For more information see this repo:" echo "https://github.com/home-assistant/homebridge-homeassistant#customization" echo - echo "If you have issues with this script, please say something in the #hassbian channel on Discord." + echo "If you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo else echo -e "\e[31mInstallation failed..." From cd06d169b5f5f941458bfd7b16a6db7f0ffa0f79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Fri, 12 Jan 2018 20:34:51 +0100 Subject: [PATCH 4/6] Added option to expose to samba - I samba is installed, users get option to expose `/home/homebridge/.homebridge` as `homebridge` user - Corrected some language formatting - Corrected discord channel in failed state --- .../opt/hassbian/suites/install_homebridge.sh | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/package/opt/hassbian/suites/install_homebridge.sh b/package/opt/hassbian/suites/install_homebridge.sh index 8a10caaa..e3745498 100644 --- a/package/opt/hassbian/suites/install_homebridge.sh +++ b/package/opt/hassbian/suites/install_homebridge.sh @@ -10,7 +10,7 @@ function homebridge-show-long-info { function homebridge-show-copyright-info { echo "Original concept by Ludeeus " - echo "Disclaimer: Some parts of this script is 'borrowed' from Dale Higgs " + echo "Disclaimer: Some parts of this script is inspired by Dale Higgs " } function homebridge-install-package { @@ -104,6 +104,24 @@ sudo systemctl daemon-reload sudo systemctl enable homebridge.service sudo systemctl start homebridge.service +if [ -f "/usr/sbin/samba" ]; then + read -p "Do you want to add samba share for homebridge configuration? [N/y] : " SAMBA + if [ "$SAMBA" == "y" ] || [ "$SAMBA" == "Y" ]; then + echo "Adding configuration to samba..." + sudo smbpasswd -a homebridge -n + echo "[homebridge]" | tee -a /etc/samba/smb.conf + echo "path = /home/homebridge/.homebridge" | tee -a /etc/samba/smb.conf + echo "writeable = yes" | tee -a /etc/samba/smb.conf + echo "guest ok = yes" | tee -a /etc/samba/smb.conf + echo "create mask = 0644" | tee -a /etc/samba/smb.conf + echo "directory mask = 0755" | tee -a /etc/samba/smb.conf + echo "force user = homebridge" | tee -a /etc/samba/smb.conf + echo "" | tee -a /etc/samba/smb.conf + echo "Restarting Samba service" + sudo systemctl restart smbd.service + fi +fi + echo "Checking the installation..." validation=$(ps -ef | grep -v grep | grep homebridge | wc -l) if [ "$validation" != "0" ]; then @@ -121,7 +139,7 @@ if [ "$validation" != "0" ]; then else echo -e "\e[31mInstallation failed..." echo -e "\e[31mAborting..." - echo -e "\e[0mIf you have issues with this script, please say something in the #hassbian channel on Discord." + echo -e "\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." return 1 fi return 0 From 6af516b0f57410dd6f25ca1c0f0d5ea2c915d85a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Sun, 14 Jan 2018 00:30:05 +0100 Subject: [PATCH 5/6] Added installation instructions for homebridge. --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b305c8b7..4716721f 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,9 @@ This will allow you to controll your home with Apple's HomeKit (Siri on iOS, OSX By default all devices are hidden, and you will need to add som entries in your `customize.yaml` configuration. You can learn more about this in the [Home Assistant for Homebridge repo.](https://github.com/home-assistant/homebridge-homeassistant#customization) _NB!: This install script will fail resulting in your Pi to reboot, if you do not use an recomended level powersupply._ - +``` +sudo hassbian-config install homebridge +``` This script was originally contributed by [@Ludeeus](https://github.com/ludeeus). ### Install databases From 850eaa52728104510dc57d4df0f879847dec4e05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Sat, 27 Jan 2018 20:48:13 +0100 Subject: [PATCH 6/6] Update install_homebridge.sh --- package/opt/hassbian/suites/install_homebridge.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package/opt/hassbian/suites/install_homebridge.sh b/package/opt/hassbian/suites/install_homebridge.sh index e3745498..c452a216 100644 --- a/package/opt/hassbian/suites/install_homebridge.sh +++ b/package/opt/hassbian/suites/install_homebridge.sh @@ -30,8 +30,7 @@ sudo npm install -g --unsafe-perm homebridge hap-nodejs node-gyp sudo npm install -g homebridge-homeassistant echo "Adding homebridge user, and creating config file..." -sudo useradd -M --system homebridge -sudo mkdir /home/homebridge +sudo useradd --system --create-home homebridge sudo mkdir /home/homebridge/.homebridge sudo touch /home/homebridge/.homebridge/config.json