install command
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
[![License][license-shield]](LICENSE)
|
||||
|
||||
[![hacs][hacsbadge]](hacs)
|
||||
|
||||
<img align="left" width="80" height="80" src="https://raw.githubusercontent.com/devmel/hass_airsend/master/icons/icon.png" alt="App icon">
|
||||
<img align="left" width="80" src="https://raw.githubusercontent.com/devmel/hass_airsend/master/icons/icon.png" alt="App icon">
|
||||
|
||||
# AirSend Home Assistant
|
||||
|
||||
@@ -10,8 +6,10 @@ Component for sending radio commands (433-434Mhz) through the AirSend device.
|
||||
|
||||
## Installation
|
||||
|
||||
1. To use this plugin, copy the `airsend` folder into your [custom_components folder](https://developers.home-assistant.io/docs/creating_integration_file_structure/#where-home-assistant-looks-for-integrations).
|
||||
2. Add `airsend:` to your HA configuration (see configuration.example.yaml).
|
||||
1. Add `airsend:` to your HA configuration (see configuration below).
|
||||
2. Into the terminal, run `wget -q -O - https://github.com/devmel/hass_airsend/install | bash -`
|
||||
OR copy the `airsend` folder into your [custom_components folder](https://developers.home-assistant.io/docs/creating_integration_file_structure/#where-home-assistant-looks-for-integrations).
|
||||
3. Restart Home Assistant
|
||||
|
||||
## Configuration
|
||||
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
#!/bin/bash
|
||||
# wget -q -O - https://github.com/devmel/hass_airsend/install | bash -
|
||||
set -e
|
||||
|
||||
RED_COLOR='\033[0;31m'
|
||||
GREEN_COLOR='\033[0;32m'
|
||||
GREEN_YELLOW='\033[1;33m'
|
||||
NO_COLOR='\033[0m'
|
||||
|
||||
declare haPath
|
||||
declare -a paths=(
|
||||
"$PWD"
|
||||
"$PWD/config"
|
||||
"/config"
|
||||
"$HOME/.homeassistant/"
|
||||
"/usr/share/hassio/homeassistant/"
|
||||
)
|
||||
|
||||
function info () { echo -e "${GREEN_COLOR}INFO: $1${NO_COLOR}";}
|
||||
function warn () { echo -e "${GREEN_YELLOW}WARN: $1${NO_COLOR}";}
|
||||
function error () { echo -e "${RED_COLOR}ERROR: $1${NO_COLOR}"; if [ "$2" != "false" ]; then exit 1;fi; }
|
||||
|
||||
function checkRequirement () {
|
||||
if [ -z "$(command -v "$1")" ]; then
|
||||
error "'$1' is not installed"
|
||||
fi
|
||||
}
|
||||
|
||||
checkRequirement "wget"
|
||||
checkRequirement "unzip"
|
||||
|
||||
info "Trying to find the correct directory..."
|
||||
for path in "${paths[@]}"; do
|
||||
if [ -n "$haPath" ]; then
|
||||
break
|
||||
fi
|
||||
|
||||
if [ -f "$path/home-assistant.log" ]; then
|
||||
haPath="$path"
|
||||
else
|
||||
if [ -d "$path/.storage" ] && [ -f "$path/configuration.yaml" ]; then
|
||||
haPath="$path"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$haPath" ]; then
|
||||
info "Found Home Assistant configuration directory at '$haPath'"
|
||||
cd "$haPath" || error "Could not change path to $haPath"
|
||||
if [ ! -d "$haPath/custom_components" ]; then
|
||||
info "Creating custom_components directory..."
|
||||
mkdir "$haPath/custom_components"
|
||||
fi
|
||||
|
||||
info "Changing to the custom_components directory..."
|
||||
cd "$haPath/custom_components" || error "Could not change path to $haPath/custom_components"
|
||||
|
||||
info "Downloading AirSend Home Assistant Component"
|
||||
wget "https://github.com/devmel/hass_airsend/releases/download/cloud/hass_airsend.zip"
|
||||
|
||||
if [ -d "$haPath/custom_components/hass_airsend" ]; then
|
||||
warn "airsend directory already exist, cleaning up..."
|
||||
rm -R "$haPath/custom_components/hass_airsend"
|
||||
fi
|
||||
|
||||
info "Creating airsend directory..."
|
||||
mkdir "$haPath/custom_components/airsend"
|
||||
|
||||
info "Unpacking hass_airsend..."
|
||||
unzip "$haPath/custom_components/hass_airsend.zip" -d "$haPath/custom_components/airsend" >/dev/null 2>&1
|
||||
|
||||
info "Removing hass_airsend zip file..."
|
||||
rm "$haPath/custom_components/hass_airsend.zip"
|
||||
info "Installation complete."
|
||||
echo
|
||||
info "Remember to add configuration and restart Home Assistant"
|
||||
|
||||
else
|
||||
echo
|
||||
error "Could not find the directory for Home Assistant" false
|
||||
echo "Manually change the directory to the root of your Home Assistant configuration"
|
||||
echo "With the user that is running Home Assistant"
|
||||
echo "and run the script again"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user