1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/homeassistant_ynh.git synced 2024-09-03 19:26:16 +02:00

Merge pull request #166 from YunoHost-Apps/testing

Testing
This commit is contained in:
ewilly 2022-12-16 17:34:26 +00:00 committed by GitHub
commit d20e6f4a89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 139 additions and 28 deletions

View file

@ -17,13 +17,13 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
Home automation platform Home automation platform
**Shipped version:** 2022.12.0~ynh1 **Shipped version:** 2022.12.6~ynh1
**Demo:** https://demo.home-assistant.io **Demo:** https://demo.home-assistant.io
## Screenshots ## Screenshots
![Screenshot of Home Assistant](./doc/screenshots/screenshot1) ![Screenshot of Home Assistant](./doc/screenshots/screenshot1.png)
## Disclaimers / important information ## Disclaimers / important information

View file

@ -17,13 +17,13 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
Plateforme domotique Plateforme domotique
**Version incluse :** 2022.12.0~ynh1 **Version incluse :** 2022.12.6~ynh1
**Démo :** https://demo.home-assistant.io **Démo :** https://demo.home-assistant.io
## Captures d'écran ## Captures d'écran
![Capture d'écran de Home Assistant](./doc/screenshots/screenshot1) ![Capture d'écran de Home Assistant](./doc/screenshots/screenshot1.png)
## Avertissements / informations importantes ## Avertissements / informations importantes

View file

@ -2,6 +2,14 @@
; Manifest ; Manifest
domain="domain.tld" domain="domain.tld"
is_public=1 is_public=1
home="Home"
latitude="32.87336"
longitude="117.22743"
elevation="430"
unit_system="metric"
currency="USD"
country="US"
time_zone="America/Los_Angeles"
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=0 setup_sub_dir=0

View file

@ -1,4 +1,12 @@
homeassistant: homeassistant:
name: __HOME__
latitude: __LATITUDE__
longitude: __LONGITUDE__
elevation: __ELEVATION__
unit_system: __UNIT_SYSTEM__
currency: __CURRENCY__
country: __COUNTRY__
time_zone: __TIME_ZONE__
external_url: "https://__DOMAIN__" external_url: "https://__DOMAIN__"
auth_providers: auth_providers:
- type: command_line - type: command_line

View file

Before

Width:  |  Height:  |  Size: 226 KiB

After

Width:  |  Height:  |  Size: 226 KiB

View file

@ -6,7 +6,7 @@
"en": "Home automation platform", "en": "Home automation platform",
"fr": "Plateforme domotique" "fr": "Plateforme domotique"
}, },
"version": "2022.12.0~ynh1", "version": "2022.12.6~ynh1",
"url": "https://github.com/home-assistant/home-assistant", "url": "https://github.com/home-assistant/home-assistant",
"upstream": { "upstream": {
"license": "Apache-2.0", "license": "Apache-2.0",
@ -41,6 +41,71 @@
"fr": "Dans le cas contraire, l'application sur Smartphone ne fonctionnera pas" "fr": "Dans le cas contraire, l'application sur Smartphone ne fonctionnera pas"
}, },
"default": true "default": true
},
{
"name": "home",
"type": "string",
"ask": {
"en": "Name of the location where Home Assistant is running."
},
"default": "Home"
},
{
"name": "latitude",
"type": "string",
"ask": {
"en": "Latitude of your location required to calculate the time the sun rises and sets--> https://www.openstreetmap.org"
},
"default": 32.87336
},
{
"name": "longitude",
"type": "string",
"ask": {
"en": "Longitude of your location required to calculate the time the sun rises and sets --> https://www.openstreetmap.org"
},
"default": 117.22743
},
{
"name": "elevation",
"type": "number",
"ask": {
"en": "Altitude above sea level in meters. Impacts sunrise data."
},
"default": 430
},
{
"name": "unit_system",
"type": "string",
"ask": {
"en": "metric for Metric, us_customary for US Customary. This also sets temperature_unit, Celsius for Metric and Fahrenheit for US Customary."
},
"choices": ["metric", "us_customary"],
"default": "metric"
},
{
"name": "currency",
"type": "string",
"ask": {
"en": "Pick your currency code from the column Code of Wikipedias list of ISO 4217 active codes --> https://en.wikipedia.org/wiki/ISO_4217#Active_codes"
},
"default": "USD"
},
{
"name": "country",
"type": "string",
"ask": {
"en": "Country in which Home Assistant is running. This may, for example, influence radio settings to comply with local regulations. The country should be specified as an ISO 3166.1 alpha-2 code. Pick your country from the column Code of Wikipedias list of ISO 31661 alpha-2 officially assigned code --> https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements"
},
"default": "US"
},
{
"name": "time_zone",
"type": "string",
"ask": {
"en": "Pick your time zone from the column TZ of Wikipedias list of tz database time zones --> https://en.wikipedia.org/wiki/List_of_tz_database_time_zones"
},
"default": "America/Los_Angeles"
} }
] ]
} }

View file

@ -5,7 +5,7 @@
#================================================= #=================================================
# Release to install # Release to install
app_version=2022.12.0 app_version=2022.12.6
# Package dependencies # Package dependencies
pkg_dependencies="python3 python3-dev python3-venv python3-pip libffi-dev libssl-dev libjpeg-dev zlib1g-dev autoconf build-essential libopenjp2-7 libtiff5 libturbojpeg0 libmariadb-dev libmariadb-dev-compat rustc" pkg_dependencies="python3 python3-dev python3-venv python3-pip libffi-dev libssl-dev libjpeg-dev zlib1g-dev autoconf build-essential libopenjp2-7 libtiff5 libturbojpeg0 libmariadb-dev libmariadb-dev-compat rustc"
@ -13,7 +13,7 @@ pkg_dependencies="python3 python3-dev python3-venv python3-pip libffi-dev libssl
# Requirements (Major.Minor.Patch) # Requirements (Major.Minor.Patch)
# PY_VERSION=$(curl -s "https://www.python.org/ftp/python/" | grep ">3.9" | tail -n1 | cut -d '/' -f 2 | cut -d '>' -f 2) # PY_VERSION=$(curl -s "https://www.python.org/ftp/python/" | grep ">3.9" | tail -n1 | cut -d '/' -f 2 | cut -d '>' -f 2)
# Pyhton 3.9.2 will be shiped with bullseye # Pyhton 3.9.2 will be shiped with bullseye
py_required_version=3.9.2 py_required_version=3.10.9
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
@ -74,10 +74,13 @@ myynh_install_python () {
# Check python version from APT # Check python version from APT
local py_apt_version=$(python3 --version | cut -d ' ' -f 2) local py_apt_version=$(python3 --version | cut -d ' ' -f 2)
# Usefull variables
local python_major=${python%.*}
# Check existing built version of python in /usr/local/bin # Check existing built version of python in /usr/local/bin
if [ -e "/usr/local/bin/python${python:0:3}" ] if [ -e "/usr/local/bin/python$python_major" ]
then then
local py_built_version=$(/usr/local/bin/python${python:0:3} --version \ local py_built_version=$(/usr/local/bin/python$python_major --version \
| cut -d ' ' -f 2) | cut -d ' ' -f 2)
else else
local py_built_version=0 local py_built_version=0
@ -98,12 +101,12 @@ myynh_install_python () {
# Built >= Required # Built >= Required
ynh_print_info --message="Using already used python3 built version..." ynh_print_info --message="Using already used python3 built version..."
py_app_version="/usr/local/bin/python${py_built_version:0:3}" py_app_version="/usr/local/bin/python${py_built_version%.*}"
else else
ynh_print_info --message="Installing additional dependencies to build python..." ynh_print_info --message="Installing additional dependencies to build python..."
pkg_dependencies="${pkg_dependencies} tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libbz2-dev libexpat1-dev liblzma-dev wget tar" pkg_dependencies="${pkg_dependencies} tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libbz2-dev libexpat1-dev liblzma-dev wget tar libnss3-dev libreadline-dev"
ynh_install_app_dependencies "${pkg_dependencies}" ynh_install_app_dependencies "${pkg_dependencies}"
# APT < Minimal & Actual < Minimal => Build & install Python into /usr/local/bin # APT < Minimal & Actual < Minimal => Build & install Python into /usr/local/bin
@ -136,7 +139,7 @@ myynh_install_python () {
ynh_secure_remove "$tmpdir" ynh_secure_remove "$tmpdir"
# Set version # Set version
py_app_version="/usr/local/bin/python${python:0:3}" py_app_version="/usr/local/bin/python$python_major"
fi fi
fi fi
# Save python version in settings # Save python version in settings
@ -145,26 +148,33 @@ myynh_install_python () {
# Install/Upgrade Homeassistant in virtual environement # Install/Upgrade Homeassistant in virtual environement
myynh_install_homeassistant () { myynh_install_homeassistant () {
ynh_exec_as $app -H -s /bin/bash -c " \ # Create the virtual environment
echo 'create the virtual environment' \ ynh_exec_as $app $py_app_version -m venv --without-pip "$final_path"
&& $py_app_version -m venv "$final_path" \
&& echo 'activate the virtual environment' \ # Run source in a 'sub shell'
&& source "$final_path/bin/activate" \ (
&& echo 'install last version of wheel' \ # activate the virtual environment
&& pip --cache-dir "$data_path/.cache" install --upgrade wheel \ set +o nounset
&& echo 'install last version of mysqlclient' \ source "$final_path/bin/activate"
&& pip --cache-dir "$data_path/.cache" install --upgrade mysqlclient \ set -o nounset
&& echo 'install Home Assistant' \
&& pip --cache-dir "$data_path/.cache" install --upgrade $app==$app_version \ # add pip
" ynh_exec_as $app "$final_path/bin/python3" -m ensurepip
# install last version of wheel
ynh_exec_as $app "$final_path/bin/pip3" --cache-dir "$data_path/.cache" install --upgrade wheel
# install last version of mysqlclient
ynh_exec_as $app "$final_path/bin/pip3" --cache-dir "$data_path/.cache" install --upgrade mysqlclient
# install Home Assistant
ynh_exec_as $app "$final_path/bin/pip3" --cache-dir "$data_path/.cache" install --upgrade $app==$app_version
)
} }
# Upgrade the virtual environment directory # Upgrade the virtual environment directory
myynh_upgrade_venv_directory () { myynh_upgrade_venv_directory () {
ynh_exec_as $app -H -s /bin/bash -c " \ ynh_exec_as $app $py_app_version -m venv --upgrade "$final_path"
echo 'Upgrade the virtual environment directory' \
&& $py_app_version -m venv --upgrade "$final_path" \
"
} }
# Set permissions # Set permissions

View file

@ -26,6 +26,14 @@ app=$YNH_APP_INSTANCE_NAME
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
home=$YNH_APP_ARG_HOME
latitude=$YNH_APP_ARG_LATITUDE
longitude=$YNH_APP_ARG_LONGITUDE
elevation=$YNH_APP_ARG_ELEVATION
unit_system=$YNH_APP_ARG_UNIT_SYSTEM
currency=$YNH_APP_ARG_CURRENCY
country=$YNH_APP_ARG_COUNTRY
time_zone=$YNH_APP_ARG_TIME_ZONE
#================================================= #=================================================
# DEFINE USEFULL VARS # DEFINE USEFULL VARS
@ -184,6 +192,8 @@ ynh_systemd_action --service_name=$app --action=restart
ynh_script_progression --message="Configuring permissions..." ynh_script_progression --message="Configuring permissions..."
[ $is_public -eq 1 ] && ynh_permission_update --permission="main" --add="visitors" [ $is_public -eq 1 ] && ynh_permission_update --permission="main" --add="visitors"
# Allow the web UI to use its own API without Yunohost/SSOWat interfering with it. Home Assistant authentication should still be in effect.
ynh_permission_create --permission="api" --label="api" --url="/api" --allowed="visitors" "all_users" --auth_header="false" --show_tile="false" --protected="true"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX

View file

@ -31,6 +31,16 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# Create a permission if needed
if ! ynh_permission_exists --permission="api"; then
ynh_permission_create --permission="api" --label="api" --url="/api" --allowed="visitors" "all_users" --auth_header="false" --show_tile="false" --protected="true"
fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================