-
This commit is contained in:
parent
1c5831c473
commit
e2d8ba78b1
@ -56,10 +56,13 @@ php -S 0.0.0.0:8080
|
||||
|
||||
Add-on использует persistent config file:
|
||||
|
||||
- `/config/config.json` внутри контейнера
|
||||
- `/homeassistant/wall_panel/config.json` внутри контейнера
|
||||
- на хосте Home Assistant это будет `/config/wall_panel/config.json`
|
||||
|
||||
Этот файл является runtime source of truth для панели в HA-режиме и переживает рестарт add-on.
|
||||
|
||||
Настройки, внесённые через add-on UI Home Assistant, используются только как bootstrap при первом создании файла. Дальше редактируйте именно этот файл.
|
||||
|
||||
Частые настройки можно менять прямо из UI add-on в Home Assistant:
|
||||
|
||||
- `app.title`
|
||||
@ -80,6 +83,8 @@ Add-on использует persistent config file:
|
||||
|
||||
Сложные структуры, вроде `rooms`, по-прежнему удобнее держать в JSON.
|
||||
|
||||
Внутренний runtime cache add-on хранит в `/data/wall_panel`.
|
||||
|
||||
### Старый embed-режим
|
||||
|
||||
Отдельный PHP-доступ по-прежнему работает:
|
||||
|
||||
@ -86,15 +86,8 @@ function app_load_config(): array
|
||||
app_ensure_directory(dirname($path));
|
||||
|
||||
$config = app_default_config();
|
||||
$storedConfig = $config;
|
||||
if (!file_exists($path)) {
|
||||
$json = json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
if ($json === false) {
|
||||
throw new RuntimeException('Failed to encode default config');
|
||||
}
|
||||
|
||||
file_put_contents($path, $json . PHP_EOL, LOCK_EX);
|
||||
} else {
|
||||
$pathExists = file_exists($path);
|
||||
if ($pathExists) {
|
||||
$raw = file_get_contents($path);
|
||||
if ($raw === false || trim($raw) !== '') {
|
||||
$decoded = json_decode((string)$raw, true);
|
||||
@ -103,10 +96,10 @@ function app_load_config(): array
|
||||
}
|
||||
|
||||
$config = array_replace_recursive($config, $decoded);
|
||||
$storedConfig = $config;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$pathExists) {
|
||||
$optionsPath = function_exists('app_addon_options_path')
|
||||
? app_addon_options_path()
|
||||
: '/data/options.json';
|
||||
@ -114,10 +107,14 @@ function app_load_config(): array
|
||||
$options = app_load_json_file($optionsPath, []);
|
||||
if (is_array($options) && $options !== []) {
|
||||
$config = array_replace_recursive($config, $options);
|
||||
if (app_runtime_mode() === 'addon' && $config !== $storedConfig) {
|
||||
app_save_config($config);
|
||||
}
|
||||
}
|
||||
$json = json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
if ($json === false) {
|
||||
throw new RuntimeException('Failed to encode default config');
|
||||
}
|
||||
|
||||
file_put_contents($path, $json . PHP_EOL, LOCK_EX);
|
||||
}
|
||||
|
||||
return $config;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"active": false,
|
||||
"sensor_entity_id": "binary_sensor.barn_all_occupancy",
|
||||
"opened_at": 1774435721,
|
||||
"opened_at": 1774436133,
|
||||
"expires_at": null
|
||||
}
|
||||
|
||||
@ -55,10 +55,13 @@ php -S 0.0.0.0:8080
|
||||
|
||||
Add-on использует persistent config file:
|
||||
|
||||
- `/config/config.json` внутри контейнера
|
||||
- `/homeassistant/wall_panel/config.json` внутри контейнера
|
||||
- на хосте Home Assistant это будет `/config/wall_panel/config.json`
|
||||
|
||||
Этот файл является runtime source of truth для панели в HA-режиме и переживает рестарт add-on.
|
||||
|
||||
Настройки, внесённые через add-on UI Home Assistant, используются только как bootstrap при первом создании файла. Дальше редактируйте именно этот файл.
|
||||
|
||||
Частые настройки можно менять прямо из UI add-on в Home Assistant:
|
||||
|
||||
- `app.title`
|
||||
@ -79,6 +82,8 @@ Add-on использует persistent config file:
|
||||
|
||||
Сложные структуры, вроде `rooms`, по-прежнему удобнее держать в JSON.
|
||||
|
||||
Внутренний runtime cache add-on хранит в `/data/wall_panel`.
|
||||
|
||||
### Старый embed-режим
|
||||
|
||||
Отдельный PHP-доступ по-прежнему работает:
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
name: Wall Panel
|
||||
description: Wall Panel PHP interface as a Home Assistant add-on
|
||||
version: "1.0.4"
|
||||
version: "1.0.5"
|
||||
slug: wall_panel
|
||||
url: https://git.striker72rus.ru/PHP/wallpanell.git
|
||||
init: false
|
||||
@ -20,7 +20,9 @@ ports:
|
||||
ports_description:
|
||||
8099/tcp: Wall Panel web UI
|
||||
map:
|
||||
- addon_config:rw
|
||||
- type: homeassistant_config
|
||||
read_only: false
|
||||
path: /homeassistant/wall_panel
|
||||
homeassistant_api: true
|
||||
options:
|
||||
app:
|
||||
|
||||
@ -86,15 +86,8 @@ function app_load_config(): array
|
||||
app_ensure_directory(dirname($path));
|
||||
|
||||
$config = app_default_config();
|
||||
$storedConfig = $config;
|
||||
if (!file_exists($path)) {
|
||||
$json = json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
if ($json === false) {
|
||||
throw new RuntimeException('Failed to encode default config');
|
||||
}
|
||||
|
||||
file_put_contents($path, $json . PHP_EOL, LOCK_EX);
|
||||
} else {
|
||||
$pathExists = file_exists($path);
|
||||
if ($pathExists) {
|
||||
$raw = file_get_contents($path);
|
||||
if ($raw === false || trim($raw) !== '') {
|
||||
$decoded = json_decode((string)$raw, true);
|
||||
@ -103,10 +96,10 @@ function app_load_config(): array
|
||||
}
|
||||
|
||||
$config = array_replace_recursive($config, $decoded);
|
||||
$storedConfig = $config;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$pathExists) {
|
||||
$optionsPath = function_exists('app_addon_options_path')
|
||||
? app_addon_options_path()
|
||||
: '/data/options.json';
|
||||
@ -114,10 +107,15 @@ function app_load_config(): array
|
||||
$options = app_load_json_file($optionsPath, []);
|
||||
if (is_array($options) && $options !== []) {
|
||||
$config = array_replace_recursive($config, $options);
|
||||
if (app_runtime_mode() === 'addon' && $config !== $storedConfig) {
|
||||
app_save_config($config);
|
||||
}
|
||||
}
|
||||
|
||||
$json = json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
if ($json === false) {
|
||||
throw new RuntimeException('Failed to encode default config');
|
||||
}
|
||||
|
||||
file_put_contents($path, $json . PHP_EOL, LOCK_EX);
|
||||
}
|
||||
|
||||
return $config;
|
||||
|
||||
@ -3,8 +3,8 @@ set -eu
|
||||
|
||||
DOCROOT="${WALL_PANEL_DOCROOT:-/app}"
|
||||
PORT="${WALL_PANEL_PORT:-8099}"
|
||||
CONFIG_PATH="${WALL_PANEL_CONFIG_PATH:-/config/config.json}"
|
||||
STORAGE_DIR="${WALL_PANEL_STORAGE_DIR:-/config/storage}"
|
||||
CONFIG_PATH="${WALL_PANEL_CONFIG_PATH:-/homeassistant/wall_panel/config.json}"
|
||||
STORAGE_DIR="${WALL_PANEL_STORAGE_DIR:-/data/wall_panel}"
|
||||
|
||||
mkdir -p "$(dirname "$CONFIG_PATH")" "$STORAGE_DIR"
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user