Skip to content

Commit

Permalink
feat: added new scenario "light-control" and "src/*" with TM (#10)
Browse files Browse the repository at this point in the history
* feat: add new scenario light-control
* docs: add draft example for creation new scenario
* docs: add to develop README info about
- translation
- var naming
* feat: add topicmgr (TM) lib
  • Loading branch information
vitalii-wb authored Jan 24, 2025
1 parent 535f93b commit 7a46f94
Show file tree
Hide file tree
Showing 44 changed files with 5,563 additions and 229 deletions.
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This line resolve warning
# This diff contains a change in line endings from 'LF' to 'CRLF'.
#
# link: https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings

# Use LF for all files because this project used on linux driven controller
* text=auto eol=lf
3 changes: 3 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"MD033": false
}
8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"trailingComma": "es5",
"printWidth": 77,
"tabWidth": 2,
"semi": true,
"useTabs": false,
"singleQuote": true
}
22 changes: 19 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@
# DESTDIR=/
PREFIX=/usr

# Путь к папке со сценариями
# Локальные пути в директории сборки
# Дирректория со сценариями
SCENARIOS_ROOT := scenarios/

# Папка для схем и изображений в схеме
# Директория для схем и изображений в схеме
SCHEMA_DIR := schema/

# Директория с общими файлами исходников нескольких сценариев
SRC_DIR := src/

# Целевые пути
CONFIG_DEST := $(DESTDIR)/etc
IMAGE_DEST := $(DESTDIR)/var/www/images
IMAGE_DEST := $(DESTDIR)/var/www/images/wb-scenarios
SCHEMA_DEST := $(DESTDIR)$(PREFIX)/share/wb-mqtt-confed/schemas
# Используем системный путь до скриптов /usr/share/wb-rules-system/rules
# так как /etc/wb-rules/* должно использоваться для пользовательских скриптов
Expand All @@ -28,6 +32,7 @@ MODULES_DEST := $(DESTDIR)$(PREFIX)/share/wb-rules-modules

# Поиск папок сценариев внутри папки scenarios
SCENARIO_DIRS := $(wildcard $(SCENARIOS_ROOT)*)
SRC_MODULE_FILES := $(wildcard $(SRC_DIR)*.mod.js)

# @note: Потенциально могут быть пробелы и спец символы в именах файлов
# или папок - можно сделать проверку перед началом работы
Expand All @@ -47,6 +52,8 @@ clean:
dummy:
@echo "This is a dummy target"

# @note: Используем везде цикл а не просто install, чтобы иметь возможность
# видеть в логе какие именно файлы копируются поштучно
install:
@echo "Starting installation process..."

Expand All @@ -65,6 +72,15 @@ install:
echo "Copying schema $(file) to $(SCHEMA_DEST)";\
install -Dm644 $(file) -t $(SCHEMA_DEST);)

@# Установка общих файлов сценариев из папки src
@if [ -z "$(SRC_MODULE_FILES)" ]; then \
echo "No .mod.js files found in dir."; \
else \
$(foreach file,$(SRC_MODULE_FILES),\
echo "Copying module file $(file) to $(MODULES_DEST)";\
install -Dm644 $(file) -t $(MODULES_DEST);) \
fi

@# Установка каждого сценария из подпапок
@$(foreach dir,$(SCENARIO_DIRS),\
echo "Installing from directory $(dir)...";\
Expand Down
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
Данный репозиторий содержит готовые сценарии которые помогают
быстрее подключать устройства и связывать их между собой

На данный момент реализованые сценарии:
На данный момент реализованы сценарии:

- [Управление устройствами](scenarios/devices-control/README.md)
- [Управление светом](scenarios/light-control/README.md)

## Установка

Expand All @@ -19,5 +20,16 @@
После этого у вас в пункте `Настройки` -> `Конфигурационные файлы`
должен появится пункт `Сценарии автоматизации`

## Использование

Сценарии можно использовать двумя способами:

- Через WEBUI конфигурируя сценарий заполняя поля в браузере
- В правилах wb-rules используя соответствующие модули

Подробнее об использовании каждого сценария смотрите в их документации

## Разработчикам новых сценариев

Для информации о разработке новых сценариев - смотрите
файл для разработчиков [README](develop/README.md).
файл для разработчиков [`develop/README.md`](develop/README.md).
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
wb-scenarios (1.1.0) stable; urgency=medium

* feat: implement new scenario light-control

-- Vitalii Gaponov <[email protected]> Thu, 23 Jan 2024 10:00:00 +0300

wb-scenarios (1.0.6) stable; urgency=medium

* fix: ignored device settings in control scenarios, improves error logging
Expand Down
2 changes: 1 addition & 1 deletion debian/compat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9
10
9 changes: 5 additions & 4 deletions debian/wb-scenarios.dirs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/usr/share/wb-rules-system/rules
/usr/share/wb-mqtt-confed/schemas
/var/www/images
/usr/share/wb-rules-modules
usr/share/wb-rules-system/rules
usr/share/wb-mqtt-confed/schemas
var/www/images/wb-scenarios
usr/share/wb-rules-modules
etc
Loading

0 comments on commit 7a46f94

Please sign in to comment.