Купили оборудование WB пару месяцев назад. Я пробовал разобраться как его запрограммировать, но неделя была потеряна почти впустую, сейчас времени нет. Нужно ставить оборудование, но программа до сих пор не готова.
Волрос: кто сможет сделать готовый код? Просто управление освещением и одним контактором.
Выключатели сенсорные без фиксации. Одно нажатие - вкл\выкл свет. Двойное нажатие - вкл\выкл RGB подсветка. Длительное нажатие - вкл\выкл всё.
Таких 10 зон.
Есть подробности, обсудим по ходу.
Заплачу
Добрый день.
А что не получается? У нас же есть примеры обработки нажатий.
Куда подключены кнопки? (к какому модулю)
Диммер на LED https://wirenboard.com/wiki/WB-MRGBW-D?
Как вариант - напишите в нашу группу https://t.me/wirenboard
Ну или свяжитесь с интеграторами https://wirenboard.com/ru/pages/partners
Если хотите все же разобраться самостоятельно - выложите скрипт, посмотрим.
не получается написать программу. Нужно изучить новый язык программирования для конфигурации этих модулей. Если бы еще доступна была обучающая информация, а она не структурирована, приходится искать то в видосиках то на форуме, то на каких-то сайтах. Это отпугивает сильно от повторной покупки, вообще-то. Для кого это сделано? Сколько людей купят повторно это? Железки отличные, система набора модулей - прекрасная. Недоступность конфигурирования этого добра всё портит.
модуль wbio-di-wd-14 собирает все выключатели
модули (10шт) wb-mrgbw-d управляют лентами rgbw
модуль wb-mrps6/s управляет простыми светильниками
модули(2шт) wb-mвь3/300w управляет диммируемыми светильниками
я уже не помню что делалось тут
‘use strict’;
var ActionButtons = {};
/**
-
Function that identifies what kind of press was performed: single, double or long press;
-
and assigns an action for each type of press.
-
@param {string} trigger - Name of device and control in the following format: “/”.
-
@param {object} action - Defines actions to be taken for each type of button press.
-
Key: "singlePress" or "doublePress" or "longPress" or "longRelease".
-
Value: Object of the following structure {func: <function name>, prop: <array of parameters to be passed>}
-
Example:
-
{
-
singlePress: {func: myFunc1, prop: ["wb-mr6c_1", "K1"]},
-
doublePress: {func: myFunc2, prop: ["wb-mrgbw-d_2", "RGB", "255;177;85"]},
-
longPress: {func: myFunc3, prop: []},
-
longRelease: {func: myFunc4, prop: []}
-
}
-
@param {number} timeToNextPress - Time (ms) after button up to wait for the next press before reseting the counter. Default is 300 ms.
-
@param {number} timeOfLongPress - Time (ms) after button down to be considered as as a long press. Default is 1000 ms (1 sec).
*/
ActionButtons.onButtonPress = function (trigger, action, timeToNextPress, timeOfLongPress) {
log.info(“LongPress ActionButtons.onButtonPress”)//Это лог. Он попадает в /var/log/messages
var buttonPressedCounter = 0;
var timerWaitNextShortPress = null;
var timerLongPress = null;
var isLongPress = false;var ruleName = “on_button_press_” + trigger.replace("/", “_”);
defineRule(ruleName, {
whenChanged: trigger,
then: function (newValue, devName, cellName) {
log.info(“LongPress defineRule”)//Это лог. Он попадает в /var/log/messages// If button is pressed, wait for a long press if (newValue) { if (timerWaitNextShortPress) { clearTimeout(timerWaitNextShortPress); } timerLongPress = setTimeout(function () { if (typeof action.longPress === "object") { if (typeof action.longPress.func === "function") { action.longPress.func.apply(this, action.longPress.prop); } } // log(">>>>>>> long press <<<<<<"); isLongPress = true; // Long press identified, we will skip short press buttonPressedCounter = 0; }, timeOfLongPress); } // If button is released, then it is not a "long press", start to count clicks else { if (!isLongPress) { clearTimeout(timerLongPress); buttonPressedCounter += 1; timerWaitNextShortPress = setTimeout(function () { switch (buttonPressedCounter) { // Counter equals 1 - it's a single short press case 1: if (typeof action.singlePress === "object") { if (typeof action.singlePress.func === "function") { action.singlePress.func.apply(this, action.singlePress.prop); } } // log(">>>>>> short press - single <<<<<<"); break; // Counter equals 2 - it's a double short press case 2: if (typeof action.doublePress === "object") { if (typeof action.doublePress.func === "function") { action.doublePress.func.apply(this, action.doublePress.prop); } } // log(">>>>>> short press - double <<<<<<"); break; } // Reset the counter buttonPressedCounter = 0; }, timeToNextPress); } // Catch button released after long press else { if (typeof action.longRelease === "object") { if (typeof action.longRelease.func === "function") { if (typeof action.longRelease.prop === "array") { action.longRelease.func.apply(this, action.longRelease.prop); } else { action.longRelease.func.apply(this, []); } } } isLongPress = false; } } }
});
};
// export as Node module / AMD module / browser variable
if (typeof exports === ‘object’ && typeof module !== ‘undefined’) {
module.exports = ActionButtons;
} else if (typeof define === ‘function’ && define.amd) {
define(ActionButtons);
} else {
global.ActionButtons = ActionButtons;
}
}());
ActionButtons.onButtonPress(
“wb-gpio/EXT1_IN14”, //Вход, за которым следим.
{
singlePress: {
func: switchRelay,
prop: [“R1”, “K1”]
},
doublePress: {
//func: switchRelay, prop: [“D1”, “K1”]
func: switchDimmerRGB,
//prop: [“K8”,"/RGB",“White”]
prop: [“K8”,“RGB”,“White”]
},
longPress: {
func: switchRelay, prop: [“R1”, “K2”]
// func: switchDimmerRGB,
// prop: ["K1", "RGB"]
}
},
300, 1000
);
/**
- Helper Functions
*/
function switchRelay(device, control) { //Принимает в параметрах устройство и выход. Переключает состояние выхода на противоположное.
log.info(“LongPress switchRelay” ,device, control)//Это лог. Он попадает в /var/log/messages
dev[device][control] = !dev[device + “/” + control];
}
function switchDimmerRGB(relayDevice, relayControl, dimmerDevice) {
dev[relayDevice][relayControl] = true;
if ((dev[relayDevice + “/RGB”] !== “0;0;0”) || (dev[relayDevice + “//White”] !== “0”)){
dev[relayDevice + “/RGB”] = “0;0;0”,
dev[relayDevice + “/White”] = 0;
}
else {
dev[dimmerDevice][“RGB”] = “255;0;0”,
dev[dimmerDevice][“White”] = 200;
}
}
function setRandomRGB(relayDevice, relayControl, dimmerDevice) {
dev[relayDevice][relayControl] = true;
dev[relayDevice + “/RGB”] = “” + Math.floor(Math.random() * 255) + “;” + Math.floor(Math.random() * 255) + “;” + Math.floor(Math.random() * 255);
dev[relayDevice + “/White”] = Math.floor(Math.random() * 255);
dev[dimmerDevice][“RGB”] = dev[relayDevice + “/RGB”];
dev[dimmerDevice][“White”] = dev[relayDevice + “/White”];
}
Моежет вам установить nodeRed? Там все визуально делается, кода практически не нужно писать