diff --git a/.gitignore b/.gitignore index 46dcf6b7..29b6829e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,32 +7,25 @@ *.debhelper *.substvars *.o -*/debian/libmosquitto-dev/* -*/debian/libmosquitto1/* -*/debian/libmosquittopp-dev/* -*/debian/libmosquittopp1/* -*/debian/mosquitto-clients/* -*/debian/mosquitto-dbg/* -*/debian/mosquitto-dev/* -*/debian/mosquitto/* -*/debian/wb-rules-system/* *.swp *.un~ - -**/debian/files -**/debian/*.debhelper -**/debian/*.debhelper.log -**/debian/*.substvars - -utils/debian/wb-utils/ -wb-utils_*.deb -wb-utils_*.changes - -configs/debian/wb-configs/ -wb-configs_*.* *.pyc - .tern-port -debian/wb-rules-system -node_modules/ +# Ignore all debian package build files +/debian/* +# Exclude only specific control files, configuration and maintainer scripts +!/debian/changelog +!/debian/compat +!/debian/control +!/debian/copyright +!/debian/rules +!/debian/*dirs +!/debian/*install +!/debian/*config +!/debian/*postrm +!/debian/*prerm +!/debian/*templates +!/debian/*service +!/debian/*preinst +!/debian/*postinst diff --git a/debian/changelog b/debian/changelog index 687e9f69..ed842a52 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,15 @@ +wb-scenarios (1.0.3) stable; urgency=medium + + * refactor: rename files, improve .gitignore, delete redundant files + * fix: path typo, add redundant files to ignore, typo in changelog + + -- Vitalii Gaponov Mon, 28 Oct 2024 23:50:00 +0300 + wb-scenarios (1.0.2) stable; urgency=medium * Fix git history - -- Andrey Ksenofontov Thu, 28 Oct 2024 20:45:00 +0300 + -- Andrey Ksenofontov Mon, 28 Oct 2024 20:45:00 +0300 wb-scenarios (1.0.1) stable; urgency=medium diff --git a/debian/wb-scenarios/DEBIAN/conffiles b/debian/wb-scenarios/DEBIAN/conffiles deleted file mode 100644 index 72084b02..00000000 --- a/debian/wb-scenarios/DEBIAN/conffiles +++ /dev/null @@ -1,2 +0,0 @@ -/etc/scenarios.conf -/etc/wb-rules-modules/link-in-to-out.mod.js diff --git a/debian/wb-scenarios/DEBIAN/control b/debian/wb-scenarios/DEBIAN/control deleted file mode 100644 index de343a4d..00000000 --- a/debian/wb-scenarios/DEBIAN/control +++ /dev/null @@ -1,11 +0,0 @@ -Package: wb-scenarios -Version: 1.0.0 -Architecture: all -Maintainer: Wiren Board Team -Installed-Size: 48 -Depends: wb-rules (>= 2.20.0~~), wb-utils (>= 2.1) -Recommends: linux-image-wb2 | linux-image-wb6 (>= 4.9+wb20180729224630) | linux-image-wb7, wb-hwconf-manager (>= 1.30.1), wb-release-info -Section: misc -Priority: optional -Homepage: https://github.com/wirenboard/wb-scenarios -Description: Scenarios for Wiren Board diff --git a/debian/wb-scenarios/DEBIAN/md5sums b/debian/wb-scenarios/DEBIAN/md5sums deleted file mode 100644 index 1e7fd5ed..00000000 --- a/debian/wb-scenarios/DEBIAN/md5sums +++ /dev/null @@ -1,4 +0,0 @@ -2c1d1efd691abcbaf1ae36a30814a4ab usr/share/doc/wb-scenarios/changelog.gz -3e8e3913daade55b4964103072feaf9d usr/share/wb-mqtt-confed/schemas/scenarios.schema.json -2bce47e6f8ec8b1eb8045e407850617e usr/share/wb-rules-system/rules/scenarios.js -1dd8d4860f7ab12ddb07e5d601e9baef var/www/images/scenarios-link-in-to-out.png diff --git a/debian/wb-scenarios/DEBIAN/postinst b/debian/wb-scenarios/DEBIAN/postinst deleted file mode 100755 index 06d2e03e..00000000 --- a/debian/wb-scenarios/DEBIAN/postinst +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -set -e - -deb-systemd-invoke restart wb-rules - - - -exit 0 diff --git a/debian/wb-scenarios/etc/scenarios.conf b/debian/wb-scenarios/etc/scenarios.conf deleted file mode 100644 index f1f9ed5b..00000000 --- a/debian/wb-scenarios/etc/scenarios.conf +++ /dev/null @@ -1,20 +0,0 @@ -{ - "scenarios": [ - { - "enable": true, - "inControl": "vd-wall-switch1/enabled", - "inverseLink": false, - "name": "first_link", - "outControl": "vd-pump/enabled", - "scenarioType": "linkInToOut" - }, - { - "enable": true, - "inControl": "vd-wall-switch2/enabled", - "inverseLink": true, - "name": "second_link", - "outControl": "vd-pump/enabled", - "scenarioType": "linkInToOut" - } - ] -} diff --git a/debian/wb-scenarios/etc/wb-rules-modules/link-in-to-out.mod.js b/debian/wb-scenarios/etc/wb-rules-modules/link-in-to-out.mod.js deleted file mode 100644 index 5da71ff1..00000000 --- a/debian/wb-scenarios/etc/wb-rules-modules/link-in-to-out.mod.js +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @file Модуль для инициализации прямой или инвертированной связи - * между двумя switch топиками MQTT - * @author Vitalii Gaponov - * @link Комментарии в формате JSDoc - */ - -/** - * Инициализирует виртуальное устройство и определяет правило для управления - * устройством - * @param {string} idPrefix - Префикс сценария, используемое для - * идентификации виртуального устройства - * @param {string} inControl - Идентификатор входного контроля, значение - * которого следует слушать - * Пример: "vd_wall_switch/enabled" - * @param {string} outControl - Идентификатор выходного контроля, значение - * которого следует контролировать - * Пример: "vd_pump/enabled" - * @param {boolean} inverseLink - Указывает, должна ли связь быть - * инвертированной - */ -function init(idPrefix, inControl, outControl, inverseLink) { - device = defineVirtualDevice("GenVd_" + idPrefix, { - title: "Generated VD: " + idPrefix, - cells: { - enabled: { - type: "switch", - value: false - }, - } - }); - - defineRule("GenRule_" + idPrefix, { - whenChanged: inControl, - then: function (newValue, devName, cellName) { - // Проверка инверсии и присваивание значения в зависимости от него - if (inverseLink) { - dev[outControl] = !newValue; // Инвертирование значения - } else { - dev[outControl] = newValue; // Прямое присваивание значения - } - } - }); -}; - -exports.init = function (idPrefix, inControl, outControl, inverseLink) { - init(idPrefix, inControl, outControl, inverseLink); -}; diff --git a/debian/wb-scenarios/usr/share/doc/wb-scenarios/changelog.gz b/debian/wb-scenarios/usr/share/doc/wb-scenarios/changelog.gz deleted file mode 100644 index 3546b250..00000000 Binary files a/debian/wb-scenarios/usr/share/doc/wb-scenarios/changelog.gz and /dev/null differ diff --git a/debian/wb-scenarios/usr/share/wb-mqtt-confed/schemas/scenarios.schema.json b/debian/wb-scenarios/usr/share/wb-mqtt-confed/schemas/scenarios.schema.json deleted file mode 100644 index c850e565..00000000 --- a/debian/wb-scenarios/usr/share/wb-mqtt-confed/schemas/scenarios.schema.json +++ /dev/null @@ -1,157 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "title": "Automation scenarios", - "configFile": { - "path": "/etc/scenarios.conf", - "service": "wb-rules" - }, - "definitions": { - "scenario": { - "title": "Scenario", - "headerTemplate": "{{ self.name }}", - "oneOf": [ - { "$ref": "#/definitions/linkInToOut" } - ], - "_format": "wb-multiple", - "options": { - "keep_oneof_values": false, - "disable_collapse": true, - "disable_edit_json": true, - "disable_properties": true, - "wb": { - "disable_panel": true - } - } - }, - "linkInToOut": { - "type": "object", - "title": "Link in to out", - "description":"Данный сценарий предоставляет возможность прямого соединения дискретного входа с дискретным выходом
", - "_format": "grid", - "properties": { - "scenarioType": { - "type": "string", - "enum": ["linkInToOut"], - "default": "linkInToOut", - "options": { - "hidden": true - } - }, - "enable": { - "type": "boolean", - "title": "Enable", - "default": true, - "_format": "checkbox", - "propertyOrder": 1, - "options": { - "grid_columns": 12 - } - }, - "name": { - "type": "string", - "title": "Scenario name", - "default": "Управление нагрузкой", - "minLength": 1, - "maxLength": 30, - "propertyOrder": 2, - "options": { - "grid_columns": 12 - } - }, - "id_prefix": { - "type": "string", - "title": "ID Prefix", - "description": "Одно слово на английском языке исключая: пробел, /, +, #. Длина до 15 символов.", - "_pattern_comment": "Запрещает пробелы, /, +, и #, а также ограничивает строку использованием только цифр, нижнего подчеркивания и английских букв", - "pattern": "^[0-9a-zA-Z_]+$", - "default": "link_from_to", - "minLength": 1, - "maxLength": 15, - "propertyOrder": 3, - "options": { - "grid_columns": 12 - } - }, - "inControl": { - "type": "string", - "_format": "wb-autocomplete", - "title": "Input control", - "description": "What input control we need use in format: device/control", - "pattern": "^[^/+#]+/[^/+#]+$", - "propertyOrder": 4, - "options": { - "grid_columns": 12, - "wb": { - "data": "devices" - } - }, - "minLength": 1 - }, - "inverseLink": { - "type": "boolean", - "title": "Inverse link behavior", - "default": false, - "_format": "checkbox", - "propertyOrder": 5, - "options": { - "grid_columns": 12 - } - }, - "outControl": { - "type": "string", - "_format": "wb-autocomplete", - "title": "Output control", - "description": "What output control we need use in format: device/control", - "pattern": "^[^/+#]+/[^/+#]+$", - "propertyOrder": 6, - "options": { - "grid_columns": 12, - "wb": { - "data": "devices" - } - }, - "minLength": 1 - } - }, - "required": ["scenarioType", "enable", "name", "id_prefix"] - } - }, - - "properties": { - "scenarios": { - "type": "array", - "title": "Scenarios", - "items": { "$ref": "#/definitions/scenario" }, - "options": { - "disable_collapse": true, - "disable_array_reorder": true, - "disable_array_delete_last_row": true, - "enable_array_copy": true - }, - "_format": "tabs" - } - }, - - "required": ["scenarios"], - - "options": { - "wb": { - "disable_title": true - } - }, - - "translations": { - "en": { - }, - "ru": { - "Automation": "Сценарии автоматизации", - "Scenarios": "Сценарии", - "Scenario": "Сценарий", - "Scenario name": "Название сценария", - "Link in to out": "Связь входа с выходом", - "Name": "Имя", - "Optional": "Не обязательно" - } - } -} diff --git a/debian/wb-scenarios/var/www/images/scenarios-link-in-to-out.png b/debian/wb-scenarios/var/www/images/scenarios-link-in-to-out.png deleted file mode 100644 index a1da3094..00000000 Binary files a/debian/wb-scenarios/var/www/images/scenarios-link-in-to-out.png and /dev/null differ diff --git a/scenarios/link-in-to-out/DELETE-virtual-devices-for-tests/vd-pump.js b/scenarios/link-in-to-out/DELETE-virtual-devices-for-tests/vd-pump.js deleted file mode 100644 index 3f9da98c..00000000 --- a/scenarios/link-in-to-out/DELETE-virtual-devices-for-tests/vd-pump.js +++ /dev/null @@ -1,10 +0,0 @@ -defineVirtualDevice('vd-pump', { - title: {en: 'Virtual pump', ru: 'Виртуальный насос'} , - cells: { - enabled: { - title: "Статус насоса", - type: "switch", - value: false - }, - } -}); diff --git a/scenarios/link-in-to-out/DELETE-virtual-devices-for-tests/vd-wall-switch1.js b/scenarios/link-in-to-out/DELETE-virtual-devices-for-tests/vd-wall-switch1.js deleted file mode 100644 index c5ae8e74..00000000 --- a/scenarios/link-in-to-out/DELETE-virtual-devices-for-tests/vd-wall-switch1.js +++ /dev/null @@ -1,10 +0,0 @@ -defineVirtualDevice('vd-wall-switch1', { - title: {en: 'Virtual wall switch 1', ru: 'Виртуальный настенный выключатель 1'} , - cells: { - enabled: { - title: "Статус выключателя 1", - type: "switch", - value: false - }, - } -}); diff --git a/scenarios/link-in-to-out/DELETE-virtual-devices-for-tests/vd-wall-switch2.js b/scenarios/link-in-to-out/DELETE-virtual-devices-for-tests/vd-wall-switch2.js deleted file mode 100644 index da4da27b..00000000 --- a/scenarios/link-in-to-out/DELETE-virtual-devices-for-tests/vd-wall-switch2.js +++ /dev/null @@ -1,10 +0,0 @@ -defineVirtualDevice('vd-wall-switch2', { - title: {en: 'Virtual wall switch 2', ru: 'Виртуальный настенный выключатель 2'} , - cells: { - enabled: { - title: "Статус выключателя 2", - type: "switch", - value: false - }, - } -}); diff --git a/debian/wb-scenarios/usr/share/wb-rules-system/rules/scenarios.js b/scenarios/link-in-to-out/init-link-in-to-out.js similarity index 97% rename from debian/wb-scenarios/usr/share/wb-rules-system/rules/scenarios.js rename to scenarios/link-in-to-out/init-link-in-to-out.js index 9c503387..339ff3e7 100644 --- a/debian/wb-scenarios/usr/share/wb-rules-system/rules/scenarios.js +++ b/scenarios/link-in-to-out/init-link-in-to-out.js @@ -22,7 +22,7 @@ var LINK_IN_TO_OUT_TYPE = "linkInToOut"; * Глобальная переменная, хранящая строку пути расположения файла конфигурации * @type {string} */ -var CONFIG_PATH = "/etc/scenarios.conf"; +var CONFIG_PATH = "/etc/wb-scenarios.conf"; /** * Находит и возвращает все включеные сценарии с типом LINK_IN_TO_OUT_TYPE @@ -71,7 +71,7 @@ function initializeScenario(scenario) { } function main() { - var config = readConfig("/etc/scenarios.conf"); + var config = readConfig(CONFIG_PATH); log("Input config: " + JSON.stringify(config)); var listScenario = config.scenarios; diff --git a/scenarios/link-in-to-out/scenarios.js b/scenarios/link-in-to-out/scenarios.js deleted file mode 100644 index 9c503387..00000000 --- a/scenarios/link-in-to-out/scenarios.js +++ /dev/null @@ -1,92 +0,0 @@ -/** - * @file Скрипт для инициализации сценариев с типом LINK_IN_TO_OUT_TYPE - * @overview Этот скрипт загружает все конфигурации сценарииев с типом - * LINK_IN_TO_OUT_TYPE из файла, находит все активные сценарии - * данного типа, и инициализирует их согласно настройкам, указанным - * в каждом сценарии. Сценарии могут быть инвертированы в - * зависимости от указанных параметров - * @author Vitalii Gaponov - * @link Комментарии в формате JSDoc - */ - -var moduleInToOut = require("link-in-to-out.mod"); - -/** - * Глобальная переменная, хранящая строку типа сценария для поиска в конфиге - * Сценарии LINK_IN_TO_OUT_TYPE могут соединять только два MQTT switch топика - * @type {string} - */ -var LINK_IN_TO_OUT_TYPE = "linkInToOut"; - -/** - * Глобальная переменная, хранящая строку пути расположения файла конфигурации - * @type {string} - */ -var CONFIG_PATH = "/etc/scenarios.conf"; - -/** - * Находит и возвращает все включеные сценарии с типом LINK_IN_TO_OUT_TYPE - * @param {Array} listScenario - Массив всех сценариев из конфигурации - * @returns {Array} Массив активных сценариев с типом LINK_IN_TO_OUT_TYPE - */ -function findAllLinkInToOutScenarios(listScenario) { - var scenarios = []; - for (var i = 0; i < listScenario.length; i++) { - var scenario = listScenario[i]; - var isTarget = (scenario.scenarioType === LINK_IN_TO_OUT_TYPE) && - (scenario.enable === true); - if (isTarget) { - scenarios.push(scenario); - } - } - return scenarios; -} - -/** - * Инициализирует сценарий с использованием указанных настроек - * @param {object} scenario - Объект сценария, содержащий настройки - */ -function initializeScenario(scenario) { - log("Scenario found: " + JSON.stringify(scenario)); - log("Control Input: " + scenario.inControl); - log("Control Output: " + scenario.outControl); - - // Check type prop - must be "switch" and equal - inputType = dev[scenario.inControl + "#type"]; - outputType = dev[scenario.outControl + "#type"]; - log("Input type: " + inputType); - log("Output type: " + outputType); - - var isValidTypes = (inputType === outputType) && (inputType === "switch"); - if (!isValidTypes) { - log("Error: In and Out types are not the same for: " + scenario.name); - return; - } - - moduleInToOut.init(scenario.id_prefix, - scenario.inControl, - scenario.outControl, - scenario.inverseLink); - log("Initialization successful for: " + scenario.name); -} - -function main() { - var config = readConfig("/etc/scenarios.conf"); - log("Input config: " + JSON.stringify(config)); - - var listScenario = config.scenarios; - if (!Array.isArray(listScenario) || listScenario.length === 0) { - log("Error: 'scenarios' is not an array, does not exist, or is empty."); - return; - } - - var linkScenarios = findAllLinkInToOutScenarios(listScenario); - if (linkScenarios.length === 0) { - log("Error: No scenarios of type '" + LINK_IN_TO_OUT_TYPE + "' found."); - return; - } - - linkScenarios.forEach(initializeScenario); -} - -main(); \ No newline at end of file