Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add buttons support in WB-MWAC v.1 template #858

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
wb-mqtt-serial (2.153.3) stable; urgency=medium

* WB-MWAC template: add buttons support

-- Radmir Khakimov <[email protected]> Fri, 24 Jan 2025 10:27:28 +0500
ad7718 marked this conversation as resolved.
Show resolved Hide resolved

wb-mqtt-serial (2.153.2) stable; urgency=medium

* WB-MAI6 template: add scale for physical value
Expand Down
218 changes: 212 additions & 6 deletions templates/config-wb-mwac.json.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
{% set OUT_NUM_K2 = 2 -%}
{% set OUT_NUM_ALARM = 3 -%}
{% set OUT_NUM_CLEANING_MODE = 4 -%}

{% set IN_MODE_BUTTON = 6 -%}
{% set MMATRIX_OUTPUTS_NUMBER = 8 -%}
{
"title": "WB-MWAC_template_title",
"device_type": "WB-MWAC",
Expand Down Expand Up @@ -35,12 +38,29 @@
"title": "Input {{ letter }}{{ in_num - in_num_offset }}",
"id": "input_f{{ in_num }}"
},
{
"title": "Press Parameters",
"id": "gg_in{{ in_num }}_press_params",
"group": "input_f{{ in_num }}"
},
{
"title": "Actions when the input is closed / opened",
"id": "gg_in{{ in_num }}_mapping_matrix_actions",
"description": "mapping_matrix_actions_description",
"group": "input_f{{ in_num }}"
},
{% for out_num in range(1, OUTPUTS_NUMBER + 1) -%}
{
"title":
{% if out_num == OUT_NUM_K1 %} "Output K1 actions",
{% elif out_num == OUT_NUM_K2 %} "Output K2 actions",
{% elif out_num == OUT_NUM_ALARM %} "Actions for \"Leakage\" mode",
{% else %} "Actions for \"Wet cleaning\" mode",
{% endif %}
Comment on lines +52 to +59
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{% for out_num in range(1, OUTPUTS_NUMBER + 1) -%}
{
"title":
{% if out_num == OUT_NUM_K1 %} "Output K1 actions",
{% elif out_num == OUT_NUM_K2 %} "Output K2 actions",
{% elif out_num == OUT_NUM_ALARM %} "Actions for \"Leakage\" mode",
{% else %} "Actions for \"Wet cleaning\" mode",
{% endif %}
{% set titles = {
OUT_NUM_K1: "Output K1 actions",
OUT_NUM_K2: "Output K2 actions",
OUT_NUM_ALARM: 'Actions for \\"Leakage\\" mode'
} -%}
{% for out_num in range(1, OUTPUTS_NUMBER + 1) -%}
{
"title": "{{ titles.get(out_num, 'Actions for \\"Wet cleaning\\" mode') }}",

"id": "gg_in{{ in_num }}_out{{ out_num }}_button_actions",
"group": "input_f{{ in_num }}"
},
{% endfor -%}
{
"title": "input_f{{ in_num }}_channels",
"id": "gg_in{{ in_num }}_channels",
Expand Down Expand Up @@ -120,30 +140,136 @@
"in{{ in_num }}_mode": {
"title": "Input {{ letter }}{{ in_num - in_num_offset }} Mode",
"address": {{ 8 + in_num }},
"description": "mode_description",
"reg_type": "holding",
"enum": [0, 1, 2, 3, 4, 5],
"enum": [0, 1, 2, 3, 4, 5, 6],
"default": {% if in_num < 4 %}4{% else %}5{% endif %},
"enum_titles": [
"push button",
"latching switch",
"turn off all outputs",
"control disabled",
"operate according to mapping-matrix",
"operate according to mapping-matrix, repeat action in 20 min if input still activated"
"operate according to mapping-matrix, repeat action in 20 min if input still activated",
"discrete input or button"
],
"group": "input_f{{ in_num }}",
"order": 1
},
"in{{ in_num }}_debounce_ms": {
"title": "Input {{ letter }}{{ in_num - in_num_offset }} Debounce (ms)",
"title": "Debounce (ms)",
"description": "debounce_description",
"address": {{ 19 + in_num }},
"reg_type": "holding",
"min": 0,
"max": 2000,
"default": 50,
"group": "input_f{{ in_num }}",
"order": 2
"order": 2,
"condition": "in{{ in_num }}_mode=={{ IN_MODE_BUTTON }}"
},
"in{{ in_num }}_debounce_ms_no_buttons": {
"title": "Debounce (ms)",
"description": "debounce_description_no_buttons",
"address": {{ 19 + in_num }},
"reg_type": "holding",
"min": 0,
"max": 2000,
"default": 50,
"group": "input_f{{ in_num }}",
"order": 2,
"condition": "in{{ in_num }}_mode!={{ IN_MODE_BUTTON }}"
},
"in{{ in_num }}_lp_hold_time": {
"group": "gg_in{{ in_num }}_press_params",
"title": "lp_hold_time_title",
"description": "lp_hold_time_description",
"order": 1,
"address": {{ 1100 + in_num - 1 }},
"reg_type": "holding",
"default": 1000,
"min": 500,
"max": 5000,
"condition": "in{{ in_num }}_mode=={{ IN_MODE_BUTTON }}"
},
"in{{ in_num }}_secp_waiting_time": {
"group": "gg_in{{ in_num }}_press_params",
"title": "secp_waiting_time_title",
"description": "secp_waiting_time_description",
"order": 2,
"address": {{ 1140 + in_num - 1 }},
"reg_type": "holding",
"default": 300,
"min": 0,
"max": 2000,
"condition": "in{{ in_num }}_mode=={{ IN_MODE_BUTTON }}"
},
{% for out_num in range(1, OUTPUTS_NUMBER + 1) -%}
"in{{ in_num }}_out{{ out_num }}_sp": {
"group": "gg_in{{ in_num }}_out{{ out_num }}_button_actions",
"title": "Short Press",
"order": 3,
"address": {{ 544 + out_num - 1 + (in_num - 1) * MMATRIX_OUTPUTS_NUMBER }},
"reg_type": "holding",
"default": 0,
{%- if out_num == OUT_NUM_ALARM %}
"enum": [0, 1],
"enum_titles": ["do nothing", "off"],
{% else %}
"enum": [0, 1, 2, 3],
"enum_titles": ["do nothing", "off", "on", "toggle"],
{% endif -%}
"condition": "in{{ in_num }}_mode=={{ IN_MODE_BUTTON }}"
},
"in{{in_num}}_out{{ out_num }}_lp": {
"group": "gg_in{{ in_num }}_out{{ out_num }}_button_actions",
"title": "Long Press",
"order": 4,
"address": {{ 608 + out_num - 1 + (in_num - 1) * MMATRIX_OUTPUTS_NUMBER }},
"reg_type": "holding",
"default": 0,
{%- if out_num == OUT_NUM_ALARM %}
"enum": [0, 1],
"enum_titles": ["do nothing", "off"],
{% else %}
"enum": [0, 1, 2, 3],
"enum_titles": ["do nothing", "off", "on", "toggle"],
{% endif -%}
"condition": "in{{ in_num }}_mode=={{ IN_MODE_BUTTON }}"
},
"in{{ in_num }}_out{{ out_num }}_dp": {
"group": "gg_in{{ in_num }}_out{{ out_num }}_button_actions",
"title": "Double Press",
"order": 5,
"address": {{ 672 + out_num - 1 + (in_num - 1) * MMATRIX_OUTPUTS_NUMBER }},
"reg_type": "holding",
"default": 0,
{%- if out_num == OUT_NUM_ALARM %}
"enum": [0, 1],
"enum_titles": ["do nothing", "off"],
{% else %}
"enum": [0, 1, 2, 3],
"enum_titles": ["do nothing", "off", "on", "toggle"],
{% endif -%}
"condition": "in{{ in_num }}_mode=={{ IN_MODE_BUTTON }}"
},
"in{{ in_num }}_out{{ out_num }}_slp": {
"group": "gg_in{{ in_num }}_out{{ out_num }}_button_actions",
"title": "Short then long Press",
"order": 6,
"address": {{ 736 + out_num - 1 + (in_num - 1) * MMATRIX_OUTPUTS_NUMBER }},
"reg_type": "holding",
"default": 0,
{%- if out_num == OUT_NUM_ALARM %}
"enum": [0, 1],
"enum_titles": ["do nothing", "off"],
{% else %}
"enum": [0, 1, 2, 3],
"enum_titles": ["do nothing", "off", "on", "toggle"],
{% endif -%}
"condition": "in{{ in_num }}_mode=={{ IN_MODE_BUTTON }}"
},
{% endfor -%}
{% for i in range(2) -%}
{% for out_num in range(1, OUTPUTS_NUMBER + 1) -%}
{% if not (i == 1 and out_num == OUT_NUM_CLEANING_MODE) -%}
Expand Down Expand Up @@ -358,7 +484,47 @@
"round_to": 0.001,
"enabled": false,
"group": "gg_in{{ in_num }}_channels"
},
},
{
"name": "Input {{ letter }}{{ in_num - in_num_offset}} Single Press Counter",
"enabled": false,
"reg_type": "press_counter",
"address": {{ 464 + (in_num - 1) }},
"type": "value",
"sporadic": true,
"group": "gg_in{{ in_num }}_channels",
"condition": "in{{ in_num }}_mode=={{ IN_MODE_BUTTON }}"
},
{
"name": "Input {{ letter }}{{ in_num - in_num_offset }} Long Press Counter",
"enabled": false,
"reg_type": "press_counter",
"address": {{ 480 + (in_num - 1) }},
"type": "value",
"sporadic": true,
"group": "gg_in{{ in_num }}_channels",
"condition": "in{{in_num}}_mode=={{ IN_MODE_BUTTON }}"
},
{
"name": "Input {{ letter }}{{ in_num - in_num_offset }} Double Press Counter",
"enabled": false,
"reg_type": "press_counter",
"address": {{ 496 + (in_num - 1) }},
"type": "value",
"sporadic": true,
"group": "gg_in{{ in_num }}_channels",
"condition": "in{{in_num}}_mode=={{ IN_MODE_BUTTON }}"
},
{
"name": "Input {{ letter }}{{ in_num - in_num_offset }} Shortlong Press Counter",
"enabled": false,
"reg_type": "press_counter",
"address": {{ 512 + (in_num - 1) }},
"type": "value",
"sporadic": true,
"group": "gg_in{{ in_num }}_channels",
"condition": "in{{ in_num }}_mode=={{ IN_MODE_BUTTON }}"
},
{% endfor -%}
{% for out_num in range(1, OUTPUTS_NUMBER - 1) -%}
{
Expand Down Expand Up @@ -456,6 +622,15 @@
"poll_timeout_description": "Parameter defines the time of absence of polling in seconds, after which safety mode will be activated. 1 - 65534 ms, 10 by default.",
"relays_state_after_poweron_description": "Default - \"Switch to safety state\"",

"debounce_description": "For button press detection, the value must be 5 - 10 times less than the waiting time for the second press. Adds a delay to the response to presses. Recommended 50 ms.",
"debounce_description_no_buttons": "Adds a delay to the response. Recommended 50 ms.",
"lp_hold_time_title": "Long Press Time (ms)",
"lp_hold_time_description": "If the press lasts longer, we consider it long. Recommended 1000 ms.",
"secp_waiting_time_title": "Second Press Waiting Time (ms)",
"secp_waiting_time_description": "If there is no second press during the specified time then press is single. 0 - disables all presses except short and long. Adds a delay to the response to a short press. Recommended 300 ms.",

"mode_description": "For press detection, firmware version 1.21.0 or newer is required",

"Cleaning Mode": "\"Wet cleaning\" Mode",
"wet_cleaning_mode_description": "In the \"Wet cleaning\" mode, the module does not respond to leakage sensors. The mode is available starting from firmware version 1.21.0",
"wet_cleaning_mode_timer_description": "1 - 360 min"
Expand All @@ -472,10 +647,17 @@
"wet_cleaning_mode_timer_description": "1 — 360 мин",
"\"Wet cleaning\" mode timer (min)": "Таймер режима \"Влажная уборка\" (мин)",

"mode_description": "Для детектирования нажатий требуется прошивка версии 1.21.0 или новее",
"Debounce (ms)": "Время подавления дребезга (мс)",

{% for in_num in range(1, INPUTS_NUMBER + 1) -%}
{% set letter = "S" if in_num < 4 else "F" -%}
{% set in_num_offset = 0 if in_num < 4 else 3 -%}
"Input {{ letter }}{{ in_num - in_num_offset }}": "Вход {{ letter }}{{ in_num - in_num_offset }}",
"Input {{ letter }}{{ in_num - in_num_offset }} Single Press Counter": "Счетчик коротких нажатий входа {{ letter }}{{ in_num - in_num_offset }}",
"Input {{ letter }}{{ in_num - in_num_offset }} Long Press Counter": "Счетчик длинных нажатий входа {{ letter }}{{ in_num - in_num_offset }}",
"Input {{ letter }}{{ in_num - in_num_offset }} Double Press Counter": "Счетчик двойных нажатий входа {{ letter }}{{ in_num - in_num_offset }}",
"Input {{ letter }}{{ in_num - in_num_offset }} Shortlong Press Counter": "Счетчик коротких, а затем длинных нажатий входа {{ letter }}{{ in_num - in_num_offset }}",
"Input {{ letter }}{{ in_num - in_num_offset }} Mode": "Режим работы входа {{ letter }}{{ in_num - in_num_offset }}",
"Input {{ letter }}{{ in_num - in_num_offset }} Debounce (ms)": "Время защиты от дребезга входа {{ letter }}{{ in_num - in_num_offset }} (мс)",
"{{ letter }}{{ in_num - in_num_offset }} Counter": "Счетчик {{ letter }}{{ in_num - in_num_offset }}",
Expand All @@ -492,7 +674,8 @@
"control disabled": "управление отключено",
"operate according to mapping-matrix": "управлять по mapping-матрице",
"operate according to mapping-matrix, repeat action in 20 min if input still activated": "управлять по mapping-матрице; повторить действие через 20 мин., если вход все еще активирован",

"discrete input or button": "дискретный вход или кнопка",

{% for lp_in_num in range(1, LP_INPUTS_NUMBER + 1) -%}
"P{{ lp_in_num }} Counter": "Счетчик P{{ lp_in_num }}",
"P{{ lp_in_num }} Counter Offset": "Начальное значение счетчика P{{ lp_in_num }}",
Expand All @@ -506,6 +689,11 @@
"MCU Temperature": "Температура МК",
"MCU Voltage": "Напряжение питания МК",

"do nothing": "нет действия",
"off": "выключить",
"on": "включить",
"toggle": "переключить",

"Relays State After Power On": "Состояния реле при подаче питания",
"Restore last state": "Восстановить последнее состояние",
"Safe State": "Безопасное состояние",
Expand All @@ -530,6 +718,24 @@
"Relays State After Power On": "Состояния реле при подаче питания",
"relays_state_after_poweron_description": "По умолчанию — \"Перевести в безопасное состояние\"",

"Short Press": "Короткое нажатие",
"Long Press": "Длинное нажатие",
"Double Press": "Двойное нажатие",
"Short then long Press": "Короткое, затем длинное нажатие",

"Output K1 actions": "Действия для выхода K1",
"Output K2 actions": "Действия для выхода K2",
"Actions for \"Leakage\" mode": "Действия для режима \"Протечка\"",
"Actions for \"Wet cleaning\" mode": "Действия для режима \"Влажная уборка\"",

"Press Parameters": "Параметры нажатий",
"debounce_description": "Для детектирования нажатий значение должно быть в 5 — 10 раз меньше, чем время ожидания второго нажатия. Вносит задержку в реакцию на нажатия. Рекомендовано 50 мс.",
"debounce_description_no_buttons": "Вносит задержку в реакцию. Рекомендовано 50 мс.",
"lp_hold_time_title": "Время длинного нажатия (мс)",
"lp_hold_time_description": "Если нажатие длится дольше — считаем его длинным. Рекомендовано 1000 мс.",
"secp_waiting_time_title": "Время ожидания второго нажатия (мс)",
"secp_waiting_time_description": "Если за указанное время второго нажатия не было — считаем нажатие одиночным. 0 — отключит все нажатия кроме короткого и длинного. Вносит задержку в реакцию на короткое нажатие. Рекомендовано 300 мс.",

"no action / no action": "нет действия / нет действия",
"no action / reset": "нет действия / выключить",
"no action / set": "нет действия / включить",
Expand Down
24 changes: 24 additions & 0 deletions test/TDeviceTemplatesTest.Validate.dat
Original file line number Diff line number Diff line change
Expand Up @@ -20683,6 +20683,30 @@ WB-MWAC
F3 Counter => F3 Counter
F3 Freq => F3 Freq
FW Version => FW Version
Input F1 Double Press Counter => Input F1 Double Press Counter
Input F1 Long Press Counter => Input F1 Long Press Counter
Input F1 Shortlong Press Counter => Input F1 Shortlong Press Counter
Input F1 Single Press Counter => Input F1 Single Press Counter
Input F2 Double Press Counter => Input F2 Double Press Counter
Input F2 Long Press Counter => Input F2 Long Press Counter
Input F2 Shortlong Press Counter => Input F2 Shortlong Press Counter
Input F2 Single Press Counter => Input F2 Single Press Counter
Input F3 Double Press Counter => Input F3 Double Press Counter
Input F3 Long Press Counter => Input F3 Long Press Counter
Input F3 Shortlong Press Counter => Input F3 Shortlong Press Counter
Input F3 Single Press Counter => Input F3 Single Press Counter
Input S1 Double Press Counter => Input S1 Double Press Counter
Input S1 Long Press Counter => Input S1 Long Press Counter
Input S1 Shortlong Press Counter => Input S1 Shortlong Press Counter
Input S1 Single Press Counter => Input S1 Single Press Counter
Input S2 Double Press Counter => Input S2 Double Press Counter
Input S2 Long Press Counter => Input S2 Long Press Counter
Input S2 Shortlong Press Counter => Input S2 Shortlong Press Counter
Input S2 Single Press Counter => Input S2 Single Press Counter
Input S3 Double Press Counter => Input S3 Double Press Counter
Input S3 Long Press Counter => Input S3 Long Press Counter
Input S3 Shortlong Press Counter => Input S3 Shortlong Press Counter
Input S3 Single Press Counter => Input S3 Single Press Counter
Input Voltage => Input Voltage
K1 => K1
K2 => K2
Expand Down